ed25519

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 4 Imported by: 3

Documentation

Overview

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

Index

Constants

View Source
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
)

Variables

This section is empty.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL