bls12381

package
v0.13.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivKeyName = "tendermint/PrivKeyBLS12381"
	PubKeyName  = "tendermint/PubKeyBLS12381"
	// PubKeySize is is the size, in bytes, of public keys as used in this package.
	PubKeySize = 48
	// PrivateKeySize is the size, in bytes, of private keys as used in this package.
	PrivateKeySize = 32
	// SignatureSize of an BLS12381 signature.
	SignatureSize = 96
	// SeedSize is the size, in bytes, of private key seeds. These are the
	// private key representations used by RFC 8032.
	SeedSize = 32

	KeyType = "bls12381"
)

Variables

This section is empty.

Functions

func BasicScheme

func BasicScheme() *bls.BasicSchemeMPL

BasicScheme returns basic bls scheme

func RecoverThresholdPublicKeyFromPublicKeys

func RecoverThresholdPublicKeyFromPublicKeys(publicKeys []crypto.PubKey, blsIds [][]byte) (crypto.PubKey, error)

func RecoverThresholdSignatureFromShares

func RecoverThresholdSignatureFromShares(sigSharesData [][]byte, blsIds [][]byte) ([]byte, error)

RecoverThresholdSignatureFromShares BLS Ids are the Pro_tx_hashes from validators

func ReverseProTxHashes

func ReverseProTxHashes(proTxHashes []crypto.ProTxHash) []crypto.ProTxHash

Types

type PrivKey

type PrivKey []byte

PrivKey implements crypto.PrivKey.

func GenPrivKey

func GenPrivKey() PrivKey

GenPrivKey generates a new bls12381 private key. It uses OS randomness in conjunction with the current global random seed in tendermint/libs/common to generate the private key.

func GenPrivKeyFromSecret

func GenPrivKeyFromSecret(secret []byte) PrivKey

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) Bytes

func (privKey PrivKey) Bytes() []byte

Bytes returns the privkey byte format.

func (PrivKey) Equals

func (privKey PrivKey) Equals(other crypto.PrivKey) bool

Equals - you probably don't need to use this. Runs in constant time based on length of the keys.

func (PrivKey) PubKey

func (privKey PrivKey) PubKey() crypto.PubKey

PubKey gets the corresponding public key from the private key.

Panics if the private key is not initialized.

func (PrivKey) Sign

func (privKey PrivKey) Sign(msg []byte) ([]byte, error)

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 bls12381 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.

func (PrivKey) SignDigest

func (privKey PrivKey) SignDigest(msg []byte) ([]byte, error)

SignDigest 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 bls12381 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.

func (PrivKey) Type

func (privKey PrivKey) Type() string

func (PrivKey) TypeTag

func (PrivKey) TypeTag() string

TypeTag satisfies the jsontypes.Tagged interface.

func (PrivKey) TypeValue

func (privKey PrivKey) TypeValue() crypto.KeyType

type PubKey

type PubKey []byte

PubKey PubKeyBLS12381 implements crypto.PubKey for the bls12381 signature scheme.

func (PubKey) Address

func (pubKey PubKey) Address() crypto.Address

Address is the SHA256-20 of the raw pubkey bytes.

func (PubKey) Bytes

func (pubKey PubKey) Bytes() []byte

Bytes returns the PubKey byte format.

func (PubKey) Equals

func (pubKey PubKey) Equals(other crypto.PubKey) bool

func (PubKey) HexString

func (pubKey PubKey) HexString() string

HexString returns hex-string representation of pubkey

func (PubKey) String

func (pubKey PubKey) String() string

func (PubKey) Type

func (pubKey PubKey) Type() string

func (PubKey) TypeTag

func (PubKey) TypeTag() string

TypeTag satisfies the jsontypes.Tagged interface.

func (PubKey) TypeValue

func (pubKey PubKey) TypeValue() crypto.KeyType

func (PubKey) Validate

func (pubKey PubKey) Validate() error

Validate validates a public key value

func (PubKey) VerifySignature

func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool

func (PubKey) VerifySignatureDigest

func (pubKey PubKey) VerifySignatureDigest(hash []byte, sig []byte) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL