Documentation ¶
Index ¶
Constants ¶
const ( PrivKeyName = "tendermint/PrivKeyEd25519" PubKeyName = "tendermint/PubKeyEd25519" // PubKeySize is is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. PrivateKeySize = 64 // Size of an Edwards25519 signature. Namely the size of a compressed // Edwards25519 point, and a field element. Both of which are 32 bytes. SignatureSize = 64 // SeedSize is the size, in bytes, of private key seeds. These are the // private key representations used by RFC 8032. SeedSize = 32 KeyType = "ed25519" )
Variables ¶
var ( ErrNotEd25519Key = errors.New("ed25519: pubkey is not Ed25519") ErrInvalidSignature = errors.New("ed25519: invalid signature") )
Functions ¶
func NewBatchVerifier ¶
func NewBatchVerifier() crypto.BatchVerifier
Types ¶
type BatchVerifier ¶
type BatchVerifier struct {
*ed25519.BatchVerifier
}
BatchVerifier implements batch verification for ed25519.
func (*BatchVerifier) Add ¶
func (b *BatchVerifier) Add(key crypto.PubKey, msg, signature []byte) error
func (*BatchVerifier) Verify ¶
func (b *BatchVerifier) Verify() (bool, []bool)
type ErrInvalidKeyLen ¶
type ErrInvalidKeyLen struct {
Got, Want int
}
ErrInvalidKeyLen describes an error resulting from an passing in a key with an invalid key in the call to BatchVerifier.Add.
func (ErrInvalidKeyLen) Error ¶
func (e ErrInvalidKeyLen) Error() string
type PrivKey ¶
type PrivKey []byte
PrivKey implements crypto.PrivKey.
func GenPrivKey ¶
func GenPrivKey() PrivKey
GenPrivKey generates a new ed25519 private key. It uses OS randomness in conjunction with the current global random seed in cometbft/libs/rand to generate the private key.
func GenPrivKeyFromSecret ¶
GenPrivKeyFromSecret hashes the secret with SHA2, and uses that 32 byte output to create the private key. NOTE: secret should be the output of a KDF like bcrypt, if it's derived from user input.
func (PrivKey) Equals ¶
Equals - you probably don't need to use this. Runs in constant time based on length of the keys.
func (PrivKey) PubKey ¶
PubKey gets the corresponding public key from the private key.
Panics if the private key is not initialized.
func (PrivKey) Sign ¶
Sign produces a signature on the provided message. This assumes the privkey is wellformed in the golang format. The first 32 bytes should be random, corresponding to the normal ed25519 private key. The latter 32 bytes should be the compressed public key. If these conditions aren't met, Sign will panic or produce an incorrect signature.