Documentation
¶
Index ¶
- Variables
- func DERHexFromSig(rHex, sHex string) (string, error)
- func DERHexToSig(hexSignature string) ([]byte, []byte, error)
- func Sha512Half(msg []byte) []byte
- type Algorithm
- type ED25519CryptoAlgorithm
- func (c ED25519CryptoAlgorithm) DeriveKeypair(decodedSeed []byte, validator bool) (string, string, error)
- func (c ED25519CryptoAlgorithm) FamilySeedPrefix() byte
- func (c ED25519CryptoAlgorithm) Prefix() byte
- func (c ED25519CryptoAlgorithm) Sign(msg, privKey string) (string, error)
- func (c ED25519CryptoAlgorithm) Validate(msg, pubkey, sig string) bool
- type SECP256K1CryptoAlgorithm
- func (c SECP256K1CryptoAlgorithm) DeriveKeypair(seed []byte, validator bool) (string, string, error)
- func (c SECP256K1CryptoAlgorithm) DerivePublicKeyFromPublicGenerator(pubKey []byte) ([]byte, error)
- func (c SECP256K1CryptoAlgorithm) FamilySeedPrefix() byte
- func (c SECP256K1CryptoAlgorithm) Prefix() byte
- func (c SECP256K1CryptoAlgorithm) Sign(msg, privKey string) (string, error)
- func (c SECP256K1CryptoAlgorithm) Validate(msg, pubkey, sig string) bool
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidHexString is returned when the hex string is invalid. ErrInvalidHexString = errors.New("invalid hex string") // ErrInvalidDERNotEnoughData is returned when the DER data is not enough. ErrInvalidDERNotEnoughData = errors.New("invalid DER: not enough data") // ErrInvalidDERIntegerTag is returned when the DER integer tag is invalid. ErrInvalidDERIntegerTag = errors.New("invalid DER: expected integer tag") // ErrInvalidDERSignature is returned when the DER signature is invalid. ErrInvalidDERSignature = errors.New("invalid signature: incorrect length") // ErrLeftoverBytes is returned when there are leftover bytes after parsing the DER signature. ErrLeftoverBytes = errors.New("invalid signature: left bytes after parsing") )
var ( // ErrValidatorKeypairDerivation is returned when a validator keypair is attempted to be derived ErrValidatorKeypairDerivation = errors.New("validator keypair derivation not supported") // ErrInvalidPrivateKey is returned when a private key is invalid ErrInvalidPrivateKey = errors.New("invalid private key") // ErrInvalidMessage is returned when a message is required but not provided ErrInvalidMessage = errors.New("message is required") )
var ( // ErrValidatorNotSupported is returned when a validator keypair is used with the ED25519 algorithm. ErrValidatorNotSupported = errors.New("validator keypairs can not use Ed25519") )
Functions ¶
func DERHexFromSig ¶
DERHexFromSig converts r and s hex strings to a DER-encoded signature hex string. It returns the DER-encoded signature as a hex string and an error if any occurred during the process.
func DERHexToSig ¶
DERHexToSig converts a DER-encoded signature hex string to r and s byte slices. It returns the r and s byte slices and an error if any occurred during the process.
func Sha512Half ¶
Returns the first 32 bytes of a sha512 hash of a message
Types ¶
type ED25519CryptoAlgorithm ¶
type ED25519CryptoAlgorithm struct {
// contains filtered or unexported fields
}
ED25519CryptoAlgorithm is the implementation of the ED25519 cryptographic algorithm.
func ED25519 ¶
func ED25519() ED25519CryptoAlgorithm
ED25519 returns the ED25519 cryptographic algorithm.
func (ED25519CryptoAlgorithm) DeriveKeypair ¶
func (c ED25519CryptoAlgorithm) DeriveKeypair(decodedSeed []byte, validator bool) (string, string, error)
DeriveKeypair derives a keypair from a seed.
func (ED25519CryptoAlgorithm) FamilySeedPrefix ¶
func (c ED25519CryptoAlgorithm) FamilySeedPrefix() byte
FamilySeedPrefix returns the family seed prefix for the ED25519 cryptographic algorithm.
func (ED25519CryptoAlgorithm) Prefix ¶
func (c ED25519CryptoAlgorithm) Prefix() byte
Prefix returns the prefix for the ED25519 cryptographic algorithm.
func (ED25519CryptoAlgorithm) Sign ¶
func (c ED25519CryptoAlgorithm) Sign(msg, privKey string) (string, error)
func (ED25519CryptoAlgorithm) Validate ¶
func (c ED25519CryptoAlgorithm) Validate(msg, pubkey, sig string) bool
Validate validates a signature for a message with a public key.
type SECP256K1CryptoAlgorithm ¶
type SECP256K1CryptoAlgorithm struct {
// contains filtered or unexported fields
}
SECP256K1CryptoAlgorithm is the implementation of the SECP256K1 algorithm.
func SECP256K1 ¶
func SECP256K1() SECP256K1CryptoAlgorithm
SECP256K1 returns a new SECP256K1CryptoAlgorithm instance.
func (SECP256K1CryptoAlgorithm) DeriveKeypair ¶
func (c SECP256K1CryptoAlgorithm) DeriveKeypair(seed []byte, validator bool) (string, string, error)
DeriveKeypair derives a keypair from a seed.
func (SECP256K1CryptoAlgorithm) DerivePublicKeyFromPublicGenerator ¶
func (c SECP256K1CryptoAlgorithm) DerivePublicKeyFromPublicGenerator(pubKey []byte) ([]byte, error)
DerivePublicKeyFromPublicGenerator derives a public key from a public generator.
func (SECP256K1CryptoAlgorithm) FamilySeedPrefix ¶
func (c SECP256K1CryptoAlgorithm) FamilySeedPrefix() byte
FamilySeedPrefix returns the family seed prefix for the SECP256K1 algorithm.
func (SECP256K1CryptoAlgorithm) Prefix ¶
func (c SECP256K1CryptoAlgorithm) Prefix() byte
Prefix returns the prefix for the SECP256K1 algorithm.
func (SECP256K1CryptoAlgorithm) Sign ¶
func (c SECP256K1CryptoAlgorithm) Sign(msg, privKey string) (string, error)
Sign signs a message with a private key.
func (SECP256K1CryptoAlgorithm) Validate ¶
func (c SECP256K1CryptoAlgorithm) Validate(msg, pubkey, sig string) bool
Validate validates a signature for a message with a public key.