Imports #
"crypto"
"crypto/internal/fips140/ed25519"
"crypto/internal/fips140only"
cryptorand "crypto/rand"
"crypto/subtle"
"errors"
"io"
"strconv"
"crypto"
"crypto/internal/fips140/ed25519"
"crypto/internal/fips140only"
cryptorand "crypto/rand"
"crypto/subtle"
"errors"
"io"
"strconv"
PrivateKeySize is the size, in bytes, of private keys as used in this package.
const PrivateKeySize = 64PublicKeySize is the size, in bytes, of public keys as used in this package.
const PublicKeySize = 32SeedSize is the size, in bytes, of private key seeds. These are the private key representations used by RFC 8032.
const SeedSize = 32SignatureSize is the size, in bytes, of signatures generated and verified by this package.
const SignatureSize = 64PrivateKey is the type of Ed25519 private keys. It implements [crypto.Signer].
type PrivateKey []bytePublicKey is the type of Ed25519 public keys.
type PublicKey []byteOptions can be used with [PrivateKey.Sign] or [VerifyWithOptions] to select Ed25519 variants.
type Options struct {
Hash crypto.Hash
Context string
}Equal reports whether priv and x have the same value.
func (priv PrivateKey) Equal(x crypto.PrivateKey) boolEqual reports whether pub and x have the same value.
func (pub PublicKey) Equal(x crypto.PublicKey) boolGenerateKey generates a public/private key pair using entropy from rand. If rand is nil, [crypto/rand.Reader] will be used. The output of this function is deterministic, and equivalent to reading [SeedSize] bytes from rand, and passing them to [NewKeyFromSeed].
func GenerateKey(rand io.Reader) (PublicKey, PrivateKey, error)HashFunc returns o.Hash.
func (o *Options) HashFunc() crypto.HashNewKeyFromSeed 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 NewKeyFromSeed(seed []byte) PrivateKeyPublic returns the [PublicKey] corresponding to priv.
func (priv PrivateKey) Public() crypto.PublicKeySeed 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) Seed() []byteSign signs the given message with priv. rand is ignored and can be nil. If opts.HashFunc() is [crypto.SHA512], the pre-hashed variant Ed25519ph is used and message is expected to be a SHA-512 hash, otherwise opts.HashFunc() must be [crypto.Hash](0) and the message must not be hashed, as Ed25519 performs two passes over messages to be signed. A value of type [Options] can be used as opts, or crypto.Hash(0) or crypto.SHA512 directly to select plain Ed25519 or Ed25519ph, respectively.
func (priv PrivateKey) Sign(rand io.Reader, message []byte, opts crypto.SignerOpts) (signature []byte, err error)Sign signs the message with privateKey and returns a signature. It will panic if len(privateKey) is not [PrivateKeySize].
func Sign(privateKey PrivateKey, message []byte) []byteVerify reports whether sig is a valid signature of message by publicKey. It will panic if len(publicKey) is not [PublicKeySize]. The inputs are not considered confidential, and may leak through timing side channels, or if an attacker has control of part of the inputs.
func Verify(publicKey PublicKey, message []byte, sig []byte) boolVerifyWithOptions reports whether sig is a valid signature of message by publicKey. A valid signature is indicated by returning a nil error. It will panic if len(publicKey) is not [PublicKeySize]. If opts.Hash is [crypto.SHA512], the pre-hashed variant Ed25519ph is used and message is expected to be a SHA-512 hash, otherwise opts.Hash must be [crypto.Hash](0) and the message must not be hashed, as Ed25519 performs two passes over messages to be signed. The inputs are not considered confidential, and may leak through timing side channels, or if an attacker has control of part of the inputs.
func VerifyWithOptions(publicKey PublicKey, message []byte, sig []byte, opts *Options) errorfunc newKeyFromSeed(privateKey []byte, seed []byte)func sign(signature []byte, privateKey PrivateKey, message []byte)Generated with Arrow