bls

package
v1.17.27 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: BSD-3-Clause Imports: 3 Imported by: 64

Documentation

Index

Constants

View Source
const (
	SecretKeyLen = 32
	PublicKeyLen = 48 // Compressed G1 point
	SignatureLen = 96 // Compressed G2 point
)

Variables

View Source
var (
	ErrNoPublicKeys               = errors.New("no public keys")
	ErrFailedPublicKeyDecompress  = errors.New("couldn't decompress public key")
	ErrInvalidPublicKey           = errors.New("invalid public key")
	ErrFailedPublicKeyAggregation = errors.New("couldn't aggregate public keys")
	ErrFailedSignatureDecompress  = errors.New("couldn't decompress signature")
	ErrInvalidSignature           = errors.New("invalid signature")
	ErrNoSignatures               = errors.New("no signatures")
	ErrFailedSignatureAggregation = errors.New("couldn't aggregate signatures")
	ErrFailedSecretKeyDeserialize = errors.New("couldn't deserialize secret key")
)

Functions

func AggregatePublicKeyToBytes added in v1.1.2

func AggregatePublicKeyToBytes(apk *AggregatePublicKey) []byte

AggregatePublicKeyToBytes converts an aggregate public key to bytes

func AggregateSignatureToBytes added in v1.1.2

func AggregateSignatureToBytes(asig *AggregateSignature) []byte

AggregateSignatureToBytes converts an aggregate signature to bytes

func PublicKeyBytes added in v1.1.2

func PublicKeyBytes(pk *PublicKey) []byte

PublicKeyBytes is a helper that returns the compressed bytes of a public key

func PublicKeyToCompressedBytes

func PublicKeyToCompressedBytes(pk *PublicKey) []byte

PublicKeyToCompressedBytes returns the compressed big-endian format of the public key.

func PublicKeyToUncompressedBytes

func PublicKeyToUncompressedBytes(key *PublicKey) []byte

PublicKeyToUncompressedBytes returns the uncompressed big-endian format of the public key.

func SecretKeyToBytes added in v0.1.3

func SecretKeyToBytes(sk *SecretKey) []byte

SecretKeyToBytes returns the big-endian format of the secret key.

func SignatureToBytes

func SignatureToBytes(sig *Signature) []byte

SignatureToBytes returns the compressed big-endian format of the signature.

func Verify

func Verify(pk *PublicKey, sig *Signature, msg []byte) bool

Verify the [sig] of [msg] against the [pk].

func VerifyAggregate added in v1.1.2

func VerifyAggregate(apk *AggregatePublicKey, asig *AggregateSignature, msg []byte) bool

VerifyAggregate verifies an aggregate signature

func VerifyAggregateProofOfPossession added in v1.1.2

func VerifyAggregateProofOfPossession(apk *AggregatePublicKey, asig *AggregateSignature, msg []byte) bool

VerifyAggregateProofOfPossession verifies an aggregate proof of possession

func VerifyProofOfPossession

func VerifyProofOfPossession(pk *PublicKey, sig *Signature, msg []byte) bool

VerifyProofOfPossession verifies the possession of the secret pre-image of [sk]

Types

type AggregatePublicKey

type AggregatePublicKey = PublicKey

Types wrapping the blst BLS types

func AggregatePublicKeyFromBytes added in v1.1.2

func AggregatePublicKeyFromBytes(pkBytes []byte) (*AggregatePublicKey, error)

AggregatePublicKeyFromBytes converts bytes to an aggregate public key

type AggregateSignature

type AggregateSignature = Signature

Types wrapping the blst BLS types

func AggregateSignatureFromBytes added in v1.1.2

func AggregateSignatureFromBytes(sigBytes []byte) (*AggregateSignature, error)

AggregateSignatureFromBytes converts bytes to an aggregate signature

type Ciphersuite

type Ciphersuite int
const (
	CiphersuiteSignature Ciphersuite = iota
	CiphersuiteProofOfPossession
)

func (Ciphersuite) Bytes

func (c Ciphersuite) Bytes() []byte

func (Ciphersuite) String

func (c Ciphersuite) String() string

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

Types wrapping the blst BLS types

func AggregatePublicKeys

func AggregatePublicKeys(pks []*PublicKey) (*PublicKey, error)

AggregatePublicKeys aggregates a non-zero number of public keys into a single aggregated public key.

func PublicFromSecretKey added in v1.1.2

func PublicFromSecretKey(sk *SecretKey) *PublicKey

PublicFromSecretKey returns the public key associated with sk

func PublicKeyFromCompressedBytes

func PublicKeyFromCompressedBytes(pkBytes []byte) (*PublicKey, error)

PublicKeyFromCompressedBytes parses the compressed big-endian format of the public key into a public key.

func PublicKeyFromValidUncompressedBytes

func PublicKeyFromValidUncompressedBytes(pkBytes []byte) *PublicKey

PublicKeyFromValidUncompressedBytes parses the uncompressed big-endian format of the public key into a public key. It is assumed that the provided bytes are valid.

type SecretKey added in v0.1.3

type SecretKey struct {
	// contains filtered or unexported fields
}

Types wrapping the blst BLS types

func NewSecretKey added in v0.1.3

func NewSecretKey() (*SecretKey, error)

NewSecretKey generates a new secret key from the local source of cryptographically secure randomness.

func SecretKeyFromBytes added in v0.1.3

func SecretKeyFromBytes(skBytes []byte) (*SecretKey, error)

SecretKeyFromBytes parses the big-endian format of the secret key into a secret key.

func SecretKeyFromSeed added in v1.17.27

func SecretKeyFromSeed(seed []byte) (*SecretKey, error)

SecretKeyFromSeed derives a secret key from a seed using proper BLS key derivation. The seed is passed through HKDF internally by blst.KeyGen, so any 32+ byte input will produce a valid secret key.

func (*SecretKey) PublicKey added in v0.1.3

func (sk *SecretKey) PublicKey() *PublicKey

PublicKey returns the public key associated with the secret key.

func (*SecretKey) Sign added in v0.1.3

func (sk *SecretKey) Sign(msg []byte) (*Signature, error)

Sign [msg] to authorize that this private key signed [msg].

func (*SecretKey) SignProofOfPossession added in v0.1.3

func (sk *SecretKey) SignProofOfPossession(msg []byte) (*Signature, error)

SignProofOfPossession signs a [msg] to prove the ownership of this secret key.

type Signature

type Signature struct {
	// contains filtered or unexported fields
}

Types wrapping the blst BLS types

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) (*Signature, error)

AggregateSignatures aggregates a non-zero number of signatures into a single aggregated signature.

func Sign added in v1.1.2

func Sign(sk *SecretKey, msg []byte) *Signature

Sign signs a message with a secret key

func SignProofOfPossession added in v1.1.2

func SignProofOfPossession(sk *SecretKey, msg []byte) *Signature

SignProofOfPossession signs msg to prove ownership of sk

func SignatureFromBytes

func SignatureFromBytes(sigBytes []byte) (*Signature, error)

SignatureFromBytes parses the compressed big-endian format of the signature into a signature.

type Signer

type Signer interface {
	PublicKey() *PublicKey
	Sign(msg []byte) (*Signature, error)
	SignProofOfPossession(msg []byte) (*Signature, error)
}

Directories

Path Synopsis
signer

Jump to

Keyboard shortcuts

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