ed25519

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 15 Imported by: 4

Documentation

Overview

Package is our ed25519 wrapper type which also conforms to our generic interfaces for signature schemes.

Index

Constants

View Source
const (
	// PublicKeySize is the size of a serialized PublicKey in bytes (32 bytes).
	PublicKeySize = ed25519.PublicKeySize

	// PrivateKeySize is the size of a serialized PrivateKey in bytes (64 bytes).
	PrivateKeySize = ed25519.PrivateKeySize

	// SignatureSize is the size of a serialized Signature in bytes (64 bytes).
	SignatureSize = ed25519.SignatureSize

	// KeySeedSize is the seed size used by NewKeyFromSeed to generate
	// a new key deterministically.
	KeySeedSize = 32
)
View Source
const (
	// BlindFactorSize is the size in bytes of the blinding factors.
	BlindFactorSize = ed25519.PublicKeySize
)

Variables

This section is empty.

Functions

func CheckPublicKey

func CheckPublicKey(pk *PublicKey) bool

Sanity checking of public keys. We do NOT do check for small-order points here or otherwise validate the point. This function is just here to catch accidentally-bad keys, basically. Checks that p != G Checks that p != 1 Checks that p != 0 Checks that L*p = 1

func NewKeyFromSeed added in v0.0.7

func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)

func NewKeypair

func NewKeypair(r io.Reader) (*PrivateKey, *PublicKey, error)

NewKeypair generates a new PrivateKey sampled from the provided entropy source.

func Scheme

func Scheme() *scheme

Scheme returns a sign Scheme interface.

Types

type BlindedPrivateKey

type BlindedPrivateKey struct {
	// contains filtered or unexported fields
}

BlindedPrivateKey encapsulates a blinded PrivateKey.

func (*BlindedPrivateKey) Blind

func (k *BlindedPrivateKey) Blind(factor []byte) *BlindedPrivateKey

changes the *value* of the slice factor, which points at new bytes and does not modify the caller's copy of factor.

func (*BlindedPrivateKey) Identity

func (b *BlindedPrivateKey) Identity() []byte

Identity returns the key's identity, in this case it's our public key in bytes.

func (*BlindedPrivateKey) KeyType

func (b *BlindedPrivateKey) KeyType() string

KeyType returns the key type string, in this case the constant variable whose value is "ed25519".

func (BlindedPrivateKey) MarshalBinary

func (k BlindedPrivateKey) MarshalBinary() (data []byte, err error)

Marshal a secret key to 32 bytes.

func (*BlindedPrivateKey) PublicKey

func (b *BlindedPrivateKey) PublicKey() *PublicKey

PublicKey returns a PublicKey.

func (*BlindedPrivateKey) Sign

func (b *BlindedPrivateKey) Sign(message []byte) []byte

Sign signs the message msg with the BlindedPrivateKey and returns the signature.

func (*BlindedPrivateKey) UnmarshalBinary

func (k *BlindedPrivateKey) UnmarshalBinary(data []byte) error

Unmarshal 32 bytes to a private key. Rederives the public key.

type PrivateKey

type PrivateKey struct {
	// contains filtered or unexported fields
}

func NewEmptyPrivateKey added in v0.0.10

func NewEmptyPrivateKey() *PrivateKey

func (*PrivateKey) Blind

func (k *PrivateKey) Blind(factor []byte) *BlindedPrivateKey

Blind performs the blinding operation on the private key and returns the BlindedPrivateKey. This function does not mutate the PrivateKey.

func (*PrivateKey) Bytes

func (p *PrivateKey) Bytes() []byte

func (*PrivateKey) Equal added in v0.0.7

func (p *PrivateKey) Equal(key crypto.PrivateKey) bool

func (*PrivateKey) FromBytes

func (p *PrivateKey) FromBytes(b []byte) error

FromBytes deserializes the byte slice b into the PrivateKey.

func (*PrivateKey) Identity

func (p *PrivateKey) Identity() []byte

Identity returns the key's identity, in this case it's our public key in bytes.

func (*PrivateKey) InternalPtr

func (p *PrivateKey) InternalPtr() *ed25519.PrivateKey

InternalPtr returns a pointer to the internal (`golang.org/x/crypto/ed25519`) data structure. Most people should not use this.

func (*PrivateKey) KeyType

func (p *PrivateKey) KeyType() string

func (*PrivateKey) MarshalBinary added in v0.0.7

func (p *PrivateKey) MarshalBinary() ([]byte, error)

func (*PrivateKey) Public added in v0.0.7

func (p *PrivateKey) Public() crypto.PublicKey

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() *PublicKey

PublicKey returns the PublicKey corresponding to the PrivateKey.

func (*PrivateKey) Reset

func (p *PrivateKey) Reset()

func (*PrivateKey) Scheme added in v0.0.7

func (p *PrivateKey) Scheme() sign.Scheme

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)

func (*PrivateKey) SignMessage added in v0.0.7

func (p *PrivateKey) SignMessage(message []byte) (signature []byte)

func (*PrivateKey) UnmarshalBinary added in v0.0.11

func (p *PrivateKey) UnmarshalBinary(b []byte) error

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey is the EdDSA public key using ed25519.

func (*PublicKey) Blind

func (k *PublicKey) Blind(factor []byte) *PublicKey

Blind performs the blinding operations on the public key and returns the blinded public key. This function does not mutate the PublicKey.

func (*PublicKey) ByteArray

func (p *PublicKey) ByteArray() [PublicKeySize]byte

ByteArray returns the raw public key as an array suitable for use as a map key.

func (*PublicKey) Bytes

func (p *PublicKey) Bytes() []byte

func (*PublicKey) Equal

func (p *PublicKey) Equal(pubKey crypto.PublicKey) bool

func (*PublicKey) FromBytes

func (p *PublicKey) FromBytes(data []byte) error

func (*PublicKey) InternalPtr

func (k *PublicKey) InternalPtr() *ed25519.PublicKey

InternalPtr returns a pointer to the internal (`golang.org/x/crypto/ed25519`) data structure. Most people should not use this.

func (*PublicKey) KeyType

func (p *PublicKey) KeyType() string

func (*PublicKey) MarshalBinary

func (p *PublicKey) MarshalBinary() ([]byte, error)

func (*PublicKey) MarshalText

func (p *PublicKey) MarshalText() (text []byte, err error)

func (*PublicKey) Reset

func (p *PublicKey) Reset()

func (*PublicKey) Scheme added in v0.0.7

func (p *PublicKey) Scheme() sign.Scheme

func (*PublicKey) Sum256

func (p *PublicKey) Sum256() [32]byte

func (*PublicKey) ToECDH

func (p *PublicKey) ToECDH() *x25519.PublicKey

ToECDH converts the PublicKey to the corresponding ecdh.PublicKey.

func (*PublicKey) UnmarshalBinary

func (p *PublicKey) UnmarshalBinary(data []byte) error

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(text []byte) error

func (*PublicKey) Verify

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

Jump to

Keyboard shortcuts

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