package ed25519

import "github.com/ProtonMail/go-crypto/openpgp/ed25519"

Package ed25519 implements the ed25519 signature algorithm for OpenPGP as defined in the Open PGP crypto refresh.

Index

Constants

const (
	// PublicKeySize is the size, in bytes, of public keys in this package.
	PublicKeySize = ed25519lib.PublicKeySize
	// SeedSize is the size, in bytes, of private key seeds.
	// The private key representation used by RFC 8032.
	SeedSize = ed25519lib.SeedSize
	// SignatureSize is the size, in bytes, of signatures generated and verified by this package.
	SignatureSize = ed25519lib.SignatureSize
)

Functions

func ReadSignature

func ReadSignature(reader io.Reader) ([]byte, error)

ReadSignature decodes an ed25519 signature from a reader.

func Sign

func Sign(priv *PrivateKey, message []byte) ([]byte, error)

Sign signs a message with the ed25519 algorithm. priv MUST be a valid key! Check this with Validate() before use.

func Validate

func Validate(priv *PrivateKey) error

Validate checks if the ed25519 private key is valid.

func Verify

func Verify(pub *PublicKey, message []byte, signature []byte) bool

Verify verifies an ed25519 signature.

func WriteSignature

func WriteSignature(writer io.Writer, signature []byte) error

WriteSignature encodes and writes an ed25519 signature to writer.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	// Key the private key representation by RFC 8032,
	// encoded as seed | pub key point.
	Key []byte
}

func GenerateKey

func GenerateKey(rand io.Reader) (*PrivateKey, error)

GenerateKey generates a fresh private key with the provided randomness source.

func NewPrivateKey

func NewPrivateKey(key PublicKey) *PrivateKey

NewPrivateKey creates a new empty private key referencing the public key.

func (*PrivateKey) MarshalByteSecret

func (pk *PrivateKey) MarshalByteSecret() []byte

MarshalByteSecret returns the underlying 32 byte seed of the private key.

func (*PrivateKey) Seed

func (pk *PrivateKey) Seed() []byte

Seed returns the ed25519 private key secret seed. The private key representation by RFC 8032.

func (*PrivateKey) UnmarshalByteSecret

func (sk *PrivateKey) UnmarshalByteSecret(seed []byte) error

UnmarshalByteSecret computes the private key from the secret seed and stores it in the private key object.

type PublicKey

type PublicKey struct {
	// Point represents the elliptic curve point of the public key.
	Point []byte
}

func NewPublicKey

func NewPublicKey() *PublicKey

NewPublicKey creates a new empty ed25519 public key.

Source Files

ed25519.go

Version
v1.3.0 (latest)
Published
May 22, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
2 days ago

Tools for package owners.