...

Source file src/github.com/ProtonMail/go-crypto/openpgp/internal/ecc/curves.go

Documentation: github.com/ProtonMail/go-crypto/openpgp/internal/ecc

     1  // Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.
     2  package ecc
     3  
     4  import (
     5  	"io"
     6  	"math/big"
     7  )
     8  
     9  type Curve interface {
    10  	GetCurveName() string
    11  }
    12  
    13  type ECDSACurve interface {
    14  	Curve
    15  	MarshalIntegerPoint(x, y *big.Int) []byte
    16  	UnmarshalIntegerPoint([]byte) (x, y *big.Int)
    17  	MarshalIntegerSecret(d *big.Int) []byte
    18  	UnmarshalIntegerSecret(d []byte) *big.Int
    19  	GenerateECDSA(rand io.Reader) (x, y, secret *big.Int, err error)
    20  	Sign(rand io.Reader, x, y, d *big.Int, hash []byte) (r, s *big.Int, err error)
    21  	Verify(x, y *big.Int, hash []byte, r, s *big.Int) bool
    22  	ValidateECDSA(x, y *big.Int, secret []byte) error
    23  }
    24  
    25  type EdDSACurve interface {
    26  	Curve
    27  	MarshalBytePoint(x []byte) []byte
    28  	UnmarshalBytePoint([]byte) (x []byte)
    29  	MarshalByteSecret(d []byte) []byte
    30  	UnmarshalByteSecret(d []byte) []byte
    31  	MarshalSignature(sig []byte) (r, s []byte)
    32  	UnmarshalSignature(r, s []byte) (sig []byte)
    33  	GenerateEdDSA(rand io.Reader) (pub, priv []byte, err error)
    34  	Sign(publicKey, privateKey, message []byte) (sig []byte, err error)
    35  	Verify(publicKey, message, sig []byte) bool
    36  	ValidateEdDSA(publicKey, privateKey []byte) (err error)
    37  }
    38  type ECDHCurve interface {
    39  	Curve
    40  	MarshalBytePoint([]byte) (encoded []byte)
    41  	UnmarshalBytePoint(encoded []byte) []byte
    42  	MarshalByteSecret(d []byte) []byte
    43  	UnmarshalByteSecret(d []byte) []byte
    44  	GenerateECDH(rand io.Reader) (point []byte, secret []byte, err error)
    45  	Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecret []byte, err error)
    46  	Decaps(ephemeral, secret []byte) (sharedSecret []byte, err error)
    47  	ValidateECDH(public []byte, secret []byte) error
    48  }
    49  

View as plain text