Documentation ¶
Overview ¶
Package ecc provides a way to generate, sign, and use Elliptic-Curve X25519 Cryptography keys.
Index ¶
- Constants
- func CalculateSignature(signingKey ECPrivateKeyable, message []byte) [64]byte
- func CalculateSignatureAsync(signingKey ECPrivateKeyable, message []byte, ...)
- func VerifySignature(signingKey ECPublicKeyable, message []byte, signature [64]byte) bool
- func VerifySignatureAsync(signingKey ECPublicKeyable, message []byte, signature [64]byte, ...)
- type DjbECPrivateKey
- type DjbECPublicKey
- type ECKeyPair
- type ECPrivateKeyable
- type ECPublicKeyable
Constants ¶
const DjbType = 0x05
DjbType is the Diffie-Hellman curve type (curve25519) created by D. J. Bernstein.
const KeySize int = 33
KeySize is the size of EC keys (32) with the EC type byte prepended to it.
Variables ¶
This section is empty.
Functions ¶
func CalculateSignature ¶
func CalculateSignature(signingKey ECPrivateKeyable, message []byte) [64]byte
CalculateSignature signs a message with the given private key.
func CalculateSignatureAsync ¶
func CalculateSignatureAsync(signingKey ECPrivateKeyable, message []byte, completion complete.Completionable)
CalculateSignatureAsync signs a message with the given private key asyncronously.
func VerifySignature ¶
func VerifySignature(signingKey ECPublicKeyable, message []byte, signature [64]byte) bool
VerifySignature verifies that the message was signed with the given key.
func VerifySignatureAsync ¶
func VerifySignatureAsync(signingKey ECPublicKeyable, message []byte, signature [64]byte, completion complete.Completionable)
VerifySignatureAsync verifies that a message was signed with the given key asyncronously.
Types ¶
type DjbECPrivateKey ¶
type DjbECPrivateKey struct {
// contains filtered or unexported fields
}
DjbECPrivateKey implements the ECPrivateKey interface and uses Curve25519.
func NewDjbECPrivateKey ¶
func NewDjbECPrivateKey(key [32]byte) *DjbECPrivateKey
NewDjbECPrivateKey returns a new EC private key with the given bytes.
func (*DjbECPrivateKey) PrivateKey ¶
func (d *DjbECPrivateKey) PrivateKey() [32]byte
PrivateKey returns the private key as a byte-array.
func (*DjbECPrivateKey) Serialize ¶
func (d *DjbECPrivateKey) Serialize() [32]byte
Serialize returns the private key as a byte-array.
type DjbECPublicKey ¶
type DjbECPublicKey struct {
// contains filtered or unexported fields
}
DjbECPublicKey implements the ECPublicKey interface and uses Curve25519.
func NewDjbECPublicKey ¶
func NewDjbECPublicKey(publicKey [32]byte) *DjbECPublicKey
NewDjbECPublicKey creates a new Curve25519 public key with the given bytes.
func (*DjbECPublicKey) PublicKey ¶
func (d *DjbECPublicKey) PublicKey() [32]byte
PublicKey returns the EC public key as a byte array.
func (*DjbECPublicKey) Serialize ¶
func (d *DjbECPublicKey) Serialize() []byte
Serialize returns the public key prepended by the DjbType value.
type ECKeyPair ¶
type ECKeyPair struct {
// contains filtered or unexported fields
}
ECKeyPair is a combination of both public and private elliptic curve keys.
func GenerateKeyPair ¶
GenerateKeyPair returns an EC Key Pair.
func NewECKeyPair ¶
func NewECKeyPair(publicKey ECPublicKeyable, privateKey ECPrivateKeyable) *ECKeyPair
NewECKeyPair returns a new elliptic curve keypair given the specified public and private keys.
func (*ECKeyPair) PrivateKey ¶
func (e *ECKeyPair) PrivateKey() ECPrivateKeyable
PrivateKey returns the private key from the key pair.
func (*ECKeyPair) PublicKey ¶
func (e *ECKeyPair) PublicKey() ECPublicKeyable
PublicKey returns the public key from the key pair.
type ECPrivateKeyable ¶
ECPrivateKeyable is an interface for all elliptic curve private keys.
type ECPublicKeyable ¶
ECPublicKeyable is an interface for all elliptic curve public keys.
func DecodePoint ¶
func DecodePoint(bytes []byte, offset int) (ECPublicKeyable, error)
DecodePoint will take the given bytes and offset and return an ECPublicKeyable object. This is used to check the byte at the given offset in the byte array for a special "type" byte that will determine the key type. Currently only DJB EC keys are supported.