Documentation ¶
Index ¶
- Constants
- func NewBatchVerifier() crypto.BatchVerifier
- type BatchVerifier
- type ErrInvalidKey
- type ErrInvalidSignature
- type PrivKey
- func (privKey PrivKey) Bytes() []byte
- func (privKey PrivKey) Equals(other crypto.PrivKey) bool
- func (privKey PrivKey) MarshalJSON() ([]byte, error)
- func (privKey PrivKey) PubKey() crypto.PubKey
- func (privKey PrivKey) Sign(msg []byte) ([]byte, error)
- func (privKey PrivKey) Type() string
- func (privKey *PrivKey) UnmarshalJSON(data []byte) error
- type PubKey
Constants ¶
const ( PrivKeyName = "tendermint/PrivKeySr25519" PubKeyName = "tendermint/PubKeySr25519" )
const ( // PrivKeySize is the number of bytes in an Sr25519 private key. PrivKeySize = 32 KeyType = "sr25519" )
const ( // PubKeySize is the number of bytes in an Sr25519 public key. PubKeySize = 32 // SignatureSize is the size of a Sr25519 signature in bytes. SignatureSize = 64 )
Variables ¶
This section is empty.
Functions ¶
func NewBatchVerifier ¶ added in v0.38.0
func NewBatchVerifier() crypto.BatchVerifier
Types ¶
type BatchVerifier ¶ added in v0.38.0
type BatchVerifier struct {
*sr25519.BatchVerifier
}
BatchVerifier implements batch verification for sr25519.
func (*BatchVerifier) Add ¶ added in v0.38.0
func (b *BatchVerifier) Add(key crypto.PubKey, msg, signature []byte) error
func (*BatchVerifier) Verify ¶ added in v0.38.0
func (b *BatchVerifier) Verify() (bool, []bool)
type ErrInvalidKey ¶
type ErrInvalidKey struct {
Err error
}
ErrInvalidKey represents an error that could occur as a result of using an invalid private or public key. It wraps errors that could arise due to failures in serialization or the use of an incorrect key, i.e., uninitialised or not sr25519.
func (ErrInvalidKey) Error ¶
func (e ErrInvalidKey) Error() string
func (ErrInvalidKey) Unwrap ¶
func (e ErrInvalidKey) Unwrap() error
type ErrInvalidSignature ¶
type ErrInvalidSignature struct {
Err error
}
ErrInvalidSignature wraps an error that could occur as a result of generating an invalid signature.
func (ErrInvalidSignature) Error ¶
func (e ErrInvalidSignature) Error() string
func (ErrInvalidSignature) Unwrap ¶
func (e ErrInvalidSignature) Unwrap() error
type PrivKey ¶
type PrivKey struct {
// contains filtered or unexported fields
}
PrivKey implements crypto.PrivKey.
func GenPrivKey ¶
func GenPrivKey() PrivKey
GenPrivKey generates a new sr25519 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) MarshalJSON ¶ added in v0.38.0
func (*PrivKey) UnmarshalJSON ¶ added in v0.38.0
type PubKey ¶
type PubKey []byte
PubKey implements crypto.PubKey for the Sr25519 signature scheme.