const ( // ContextMaxSize is the maximum length (in bytes) allowed for context. ContextMaxSize = 255 // PublicKeySize is the length in bytes of Ed448 public keys. PublicKeySize = 57 // PrivateKeySize is the length in bytes of Ed448 private keys. PrivateKeySize = 114 // SignatureSize is the length in bytes of signatures. SignatureSize = 114 // SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032. SeedSize = 57 )
func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error)
GenerateKey generates a public/private key pair using entropy from rand. If rand is nil, crypto/rand.Reader will be used.
func Scheme() sign.Scheme
Scheme returns a signature interface.
func Sign(priv PrivateKey, message []byte, ctx string) []byte
Sign signs the message with privateKey and returns a signature. This function supports the signature variant defined in RFC-8032: Ed448, also known as the pure version of EdDSA. It will panic if len(privateKey) is not PrivateKeySize.
func SignPh(priv PrivateKey, message []byte, ctx string) []byte
SignPh creates a signature of a message given a keypair. This function supports the signature variant defined in RFC-8032: Ed448ph, meaning it internally hashes the message using SHAKE-256. Context could be passed to this function, which length should be no more than 255. It can be empty.
▹ Example
func Verify(public PublicKey, message, signature []byte, ctx string) bool
Verify returns true if the signature is valid. Failure cases are invalid signature, or when the public key cannot be decoded. This function supports the signature variant defined in RFC-8032: Ed448, also known as the pure version of EdDSA.
func VerifyAny(public PublicKey, message, signature []byte, opts crypto.SignerOpts) bool
VerifyAny returns true if the signature is valid. Failure cases are invalid signature, or when the public key cannot be decoded. This function supports all the two signature variants defined in RFC-8032, namely Ed448 (or pure EdDSA) and Ed448Ph. The opts.HashFunc() must return zero, this can be achieved by passing crypto.Hash(0) as the value for opts. Use a SignerOptions struct to pass a context string for signing.
func VerifyPh(public PublicKey, message, signature []byte, ctx string) bool
VerifyPh returns true if the signature is valid. Failure cases are invalid signature, or when the public key cannot be decoded. This function supports the signature variant defined in RFC-8032: Ed448ph, meaning it internally hashes the message using SHAKE-256. Context could be passed to this function, which length should be no more than 255. It can be empty.
PrivateKey is the type of Ed448 private keys. It implements crypto.Signer.
type PrivateKey []byte
func NewKeyFromSeed(seed []byte) PrivateKey
NewKeyFromSeed calculates a private key from a seed. It will panic if len(seed) is not SeedSize. This function is provided for interoperability with RFC 8032. RFC 8032's private keys correspond to seeds in this package.
func (priv PrivateKey) Equal(x crypto.PrivateKey) bool
Equal reports whether priv and x have the same value.
func (priv PrivateKey) MarshalBinary() (data []byte, err error)
func (priv PrivateKey) Public() crypto.PublicKey
Public returns the PublicKey corresponding to priv.
func (priv PrivateKey) Scheme() sign.Scheme
func (priv PrivateKey) Seed() []byte
Seed returns the private key seed corresponding to priv. It is provided for interoperability with RFC 8032. RFC 8032's private keys correspond to seeds in this package.
func (priv PrivateKey) Sign( rand io.Reader, message []byte, opts crypto.SignerOpts, ) (signature []byte, err error)
Sign creates a signature of a message given a key pair. This function supports all the two signature variants defined in RFC-8032, namely Ed448 (or pure EdDSA) and Ed448Ph. The opts.HashFunc() must return zero to the specify Ed448 variant. This can be achieved by passing crypto.Hash(0) as the value for opts. Use an Options struct to pass a bool indicating that the ed448Ph variant should be used. The struct can also be optionally used to pass a context string for signing.
PublicKey is the type of Ed448 public keys.
type PublicKey []byte
func (pub PublicKey) Equal(x crypto.PublicKey) bool
Equal reports whether pub and x have the same value.
func (pub PublicKey) MarshalBinary() (data []byte, err error)
func (pub PublicKey) Scheme() sign.Scheme
SchemeID is an identifier for each signature scheme.
type SchemeID uint
const ( ED448 SchemeID = iota ED448Ph )
SignerOptions implements crypto.SignerOpts and augments with parameters that are specific to the Ed448 signature schemes.
type SignerOptions struct { // Hash must be crypto.Hash(0) for both Ed448 and Ed448Ph. crypto.Hash // Context is an optional domain separation string for signing. // Its length must be less or equal than 255 bytes. Context string // Scheme is an identifier for choosing a signature scheme. Scheme SchemeID }