Documentation ¶
Overview ¶
Package curve implements elliptic curve cryptography functions used for the protocol.
Index ¶
Constants ¶
const ( PublicKeySize = curve25519.PublicKeySize SignatureSize = curve25519.SignatureSize )
const PrivateKeySize = curve25519.PrivateKeySize
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DJBPrivateKey ¶
type DJBPrivateKey struct {
// contains filtered or unexported fields
}
DJBPrivateKey represents an elliptic curve private key.
func (*DJBPrivateKey) Bytes ¶
func (d *DJBPrivateKey) Bytes() []byte
func (*DJBPrivateKey) PublicKey ¶
func (d *DJBPrivateKey) PublicKey() PublicKey
type DJBPublicKey ¶
type DJBPublicKey struct {
// contains filtered or unexported fields
}
DJBPublicKey represents an elliptic curve public key.
func (*DJBPublicKey) Bytes ¶
func (d *DJBPublicKey) Bytes() []byte
func (*DJBPublicKey) Equal ¶
func (d *DJBPublicKey) Equal(key PublicKey) bool
func (*DJBPublicKey) KeyBytes ¶
func (d *DJBPublicKey) KeyBytes() []byte
func (*DJBPublicKey) VerifySignature ¶
func (d *DJBPublicKey) VerifySignature(signature []byte, messages ...[]byte) (bool, error)
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair represents a related pair of public and private keys.
func GenerateKeyPair ¶
GenerateKeyPair returns a public/private key pair using the given reader.
It is recommended to use a cryptographic random reader. If random is nil, then crypto/rand.Reader is used.
func NewKeyPair ¶
NewKeyPair returns a public/private key pair from the given pair.
The given pair is expected to represent a valid curve.PrivateKey and curve.PublicKey, respectively.
func (*KeyPair) Agreement ¶
Agreement calculates and returns the shared secret between the key pair's private key and the given public key.
func (*KeyPair) PrivateKey ¶
func (k *KeyPair) PrivateKey() PrivateKey
PrivateKey returns the pair's private key.
type KeyType ¶
type KeyType byte
KeyType represents a type of public or private key.
const (
DJB KeyType = 0x05
)
type PrivateKey ¶
type PrivateKey interface { // Bytes returns an encoding of the private key. Bytes() []byte // PublicKey returns the private key's related public key. PublicKey() PublicKey // Agreement calculates and returns the shared secret between the private key // and the given public key. Agreement(key PublicKey) ([]byte, error) // Sign calculates the digital signature of the messages. Sign(random io.Reader, messages ...[]byte) ([]byte, error) }
PrivateKey represents an elliptic curve private key.
func GeneratePrivateKey ¶
func GeneratePrivateKey(random io.Reader) (PrivateKey, error)
GeneratePrivateKey generates a private key using the given random reader.
It is recommended to use a cryptographic random reader. If random is nil, then crypto/rand.Reader is used.
func NewPrivateKey ¶
func NewPrivateKey(key []byte) (PrivateKey, error)
NewPrivateKey returns a PrivateKey based on the given key.
type PublicKey ¶
type PublicKey interface { // Bytes returns an encoding of the public key. Bytes() []byte // KeyBytes returns an encoding of the public key without the type prefix. KeyBytes() []byte // Equal reports whether the given public key is the same as this public key. // // This check is performed in constant time as long as the keys have the same type. Equal(key PublicKey) bool // VerifySignature verifies the signature is a valid signature // of the messages by the public key. VerifySignature(signature []byte, messages ...[]byte) (bool, error) // contains filtered or unexported methods }
PublicKey represents an elliptic curve public key.
func NewPublicKey ¶
NewPublicKey returns a PublicKey based on the given key.
The first byte of the given key is expected to identify the type of the key.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package curve25519 implements the XEd25519 signature scheme.
|
Package curve25519 implements the XEd25519 signature scheme. |