Documentation ¶
Overview ¶
Package is our ed25519 wrapper type which also conforms to our generic interfaces for signature schemes.
Index ¶
- Constants
- func CheckPublicKey(pk *PublicKey) bool
- func NewKeyFromSeed(seed []byte) (*PublicKey, *PrivateKey)
- func NewKeypair(r io.Reader) (*PrivateKey, *PublicKey, error)
- func Scheme() *scheme
- type BlindedPrivateKey
- func (k *BlindedPrivateKey) Blind(factor []byte) *BlindedPrivateKey
- func (b *BlindedPrivateKey) Identity() []byte
- func (b *BlindedPrivateKey) KeyType() string
- func (k BlindedPrivateKey) MarshalBinary() (data []byte, err error)
- func (b *BlindedPrivateKey) PublicKey() *PublicKey
- func (b *BlindedPrivateKey) Sign(message []byte) []byte
- func (k *BlindedPrivateKey) UnmarshalBinary(data []byte) error
- type PrivateKey
- func (k *PrivateKey) Blind(factor []byte) *BlindedPrivateKey
- func (p *PrivateKey) Bytes() []byte
- func (p *PrivateKey) Equal(key crypto.PrivateKey) bool
- func (p *PrivateKey) FromBytes(b []byte) error
- func (p *PrivateKey) Identity() []byte
- func (p *PrivateKey) InternalPtr() *ed25519.PrivateKey
- func (p *PrivateKey) KeyType() string
- func (p *PrivateKey) MarshalBinary() ([]byte, error)
- func (p *PrivateKey) Public() crypto.PublicKey
- func (p *PrivateKey) PublicKey() *PublicKey
- func (p *PrivateKey) Reset()
- func (p *PrivateKey) Scheme() sign.Scheme
- func (p *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)
- func (p *PrivateKey) SignMessage(message []byte) (signature []byte)
- func (p *PrivateKey) UnmarshalBinary(b []byte) error
- type PublicKey
- func (k *PublicKey) Blind(factor []byte) *PublicKey
- func (p *PublicKey) ByteArray() [PublicKeySize]byte
- func (p *PublicKey) Bytes() []byte
- func (p *PublicKey) Equal(pubKey crypto.PublicKey) bool
- func (p *PublicKey) FromBytes(data []byte) error
- func (k *PublicKey) InternalPtr() *ed25519.PublicKey
- func (p *PublicKey) KeyType() string
- func (p *PublicKey) MarshalBinary() ([]byte, error)
- func (p *PublicKey) MarshalText() (text []byte, err error)
- func (p *PublicKey) Reset()
- func (p *PublicKey) Scheme() sign.Scheme
- func (p *PublicKey) Sum256() [32]byte
- func (p *PublicKey) ToECDH() *x25519.PublicKey
- func (p *PublicKey) UnmarshalBinary(data []byte) error
- func (p *PublicKey) UnmarshalText(text []byte) error
- func (p *PublicKey) Verify(signature, message []byte) bool
Constants ¶
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 )
const ( // BlindFactorSize is the size in bytes of the blinding factors. BlindFactorSize = ed25519.PublicKeySize )
Variables ¶
This section is empty.
Functions ¶
func CheckPublicKey ¶
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.
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 ¶
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) InternalPtr ¶
InternalPtr returns a pointer to the internal (`golang.org/x/crypto/ed25519`) data structure. Most people should not use this.