Documentation
¶
Overview ¶
crypto is a customized/convenience cryptography package for CometBFT.
It wraps select functionality of equivalent functions in the Go standard library, for easy usage with our libraries.
Keys:
All key generation functions return an instance of the PrivKey interface which implements methods:
type PrivKey interface {
Bytes() []byte
Sign(msg []byte) ([]byte, error)
PubKey() PubKey
Type() string
}
From the above method we can retrieve the public key if needed:
privKey, err := ed25519.GenPrivKey()
if err != nil {
panic(err)
}
pubKey := privKey.PubKey()
The resulting public key is an instance of the PubKey interface:
type PubKey interface {
Address() Address
Bytes() []byte
VerifySignature(msg []byte, sig []byte) bool
Type() string
}
Index ¶
Examples ¶
Constants ¶
const ( // AddressSize is the size of a pubkey address. AddressSize = tmhash.TruncatedSize )
const Version = "0.9.0-dev"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Address ¶
An address is a []byte, but hex-encoded even in JSON. []byte leaves us the option to change the address length. Use an alias so Unmarshal methods (with ptr receivers) are available too.
func AddressHash ¶
type BatchVerifier ¶
type BatchVerifier interface {
// Add appends an entry into the BatchVerifier.
Add(key PubKey, message, signature []byte) error
// Verify verifies all the entries in the BatchVerifier, and returns
// if every signature in the batch is valid, and a vector of bools
// indicating the verification status of each signature (in the order
// that signatures were added to the batch).
Verify() (bool, []bool)
}
If a new key type implements batch verification, the key type must be registered in github.com/ice-blockchain/cometbft/crypto/batch.