Documentation ¶
Index ¶
Constants ¶
const EcdsaSignatureLen = 64
EcdsaSignatureLen is 64 bytes
const PrivKeyBytesLen = 32
PrivKeyBytesLen are 32-bytes for all supported curvetypes
Variables ¶
var ( ErrPrivKeyUndecodable = errors.New("could not decode privkey") ErrPrivKeyLengthInvalid = errors.New("invalid privkey length") ErrPrivKeyZero = errors.New("privkey cannot be 0") ErrKeyGenSecp256k1Failed = errors.New( "keygen: error generating key pair for secp256k1 curve type", ) ErrKeyGenEdwards25519Failed = errors.New( "keygen: error generating key pair for edwards25519 curve type", ) ErrCurveTypeNotSupported = errors.New("not a supported CurveType") ErrSignUnsupportedPayloadSignatureType = errors.New( "sign: unexpected payload.SignatureType while signing", ) ErrSignUnsupportedSignatureType = errors.New( "sign: unexpected Signature type while signing", ) ErrSignFailed = errors.New("sign: unable to sign") ErrVerifyUnsupportedPayloadSignatureType = errors.New( "verify: unexpected payload.SignatureType while verifying", ) ErrVerifyUnsupportedSignatureType = errors.New( "verify: unexpected Signature type while verifying", ) ErrVerifyFailed = errors.New("verify: verify returned false") )
Named error types for Keys errors
Functions ¶
Types ¶
type KeyPair ¶
type KeyPair struct { PublicKey *types.PublicKey `json:"public_key"` PrivateKey []byte `json:"private_key"` }
KeyPair contains a PrivateKey and its associated PublicKey
func GenerateKeypair ¶
GenerateKeypair returns a Keypair of a specified CurveType
func ImportPrivateKey ¶
ImportPrivateKey returns a Keypair from a hex-encoded privkey string
func (*KeyPair) MarshalJSON ¶
MarshalJSON overrides the default JSON marshaler and encodes bytes as hex instead of base64.
func (*KeyPair) UnmarshalJSON ¶
UnmarshalJSON overrides the default JSON unmarshaler and decodes bytes from hex instead of base64.
type Signer ¶
type Signer interface { PublicKey() *types.PublicKey Sign(payload *types.SigningPayload, sigType types.SignatureType) (*types.Signature, error) Verify(signature *types.Signature) error }
Signer is an interface for different curve signers
type SignerEdwards25519 ¶
type SignerEdwards25519 struct {
KeyPair *KeyPair
}
SignerEdwards25519 is initialized from a keypair
func (*SignerEdwards25519) PublicKey ¶
func (s *SignerEdwards25519) PublicKey() *types.PublicKey
PublicKey returns the PublicKey of the signer
func (*SignerEdwards25519) Sign ¶
func (s *SignerEdwards25519) Sign( payload *types.SigningPayload, sigType types.SignatureType, ) (*types.Signature, error)
Sign arbitrary payloads using a KeyPair
type SignerSecp256k1 ¶
type SignerSecp256k1 struct {
KeyPair *KeyPair
}
SignerSecp256k1 is initialized from a keypair
func (*SignerSecp256k1) PublicKey ¶
func (s *SignerSecp256k1) PublicKey() *types.PublicKey
PublicKey returns the PublicKey of the signer
func (*SignerSecp256k1) Sign ¶
func (s *SignerSecp256k1) Sign( payload *types.SigningPayload, sigType types.SignatureType, ) (*types.Signature, error)
Sign arbitrary payloads using a KeyPair