bls12381

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package bls12381 provides high-performance BLS12-381 operations using BLST. This implementation uses the supranational/blst library for optimal performance.

Index

Constants

View Source
const DefaultDST = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_"

DefaultDST is the default domain separation tag for signatures

Variables

View Source
var (
	// ErrInvalidPoint is returned when a point is invalid
	ErrInvalidPoint = errors.New("invalid point")
	// ErrInvalidScalar is returned when a scalar is invalid
	ErrInvalidScalar = errors.New("invalid scalar")
	// ErrInvalidPublicKey is returned when a public key is invalid
	ErrInvalidPublicKey = errors.New("invalid public key")
	// ErrInvalidSignature is returned when a signature is invalid
	ErrInvalidSignature = errors.New("invalid signature")
	// ErrEmptyInput is returned when input is empty
	ErrEmptyInput = errors.New("empty input")
)

Common errors

Functions

func AggregateVerify

func AggregateVerify(pubkeys []*PublicKey, messages [][]byte, signature *Signature, dst []byte) bool

AggregateVerify verifies an aggregated signature for different messages

func BatchVerify

func BatchVerify(pubkeys []*PublicKey, messages [][]byte, signatures []*Signature, dst []byte) bool

BatchVerify verifies multiple signatures in a batch

func FastAggregateVerify

func FastAggregateVerify(pubkeys []*PublicKey, message []byte, signature *Signature, dst []byte) bool

FastAggregateVerify verifies an aggregated signature for the same message

Types

type AggregatePublicKey

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

AggregatePublicKey represents an aggregated public key

func AggregatePubKeys

func AggregatePubKeys(pubkeys []*PublicKey) (*AggregatePublicKey, error)

AggregatePubKeys aggregates multiple public keys

type AggregateSignature

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

AggregateSignature represents an aggregated signature

func AggregateSignatures

func AggregateSignatures(signatures []*Signature) (*AggregateSignature, error)

AggregateSignatures aggregates multiple signatures

type PublicKey

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

PublicKey represents a BLS public key (G1 point)

func NewPublicKey

func NewPublicKey(data []byte) (*PublicKey, error)

NewPublicKey creates a new public key from bytes

func (*PublicKey) Deserialize

func (pk *PublicKey) Deserialize(data []byte) error

Deserialize deserializes a public key from compressed format

func (*PublicKey) Equal

func (pk *PublicKey) Equal(other *PublicKey) bool

Equal checks if two public keys are equal

func (*PublicKey) Serialize

func (pk *PublicKey) Serialize() []byte

Serialize serializes a public key to compressed format

func (*PublicKey) Verify

func (pk *PublicKey) Verify(message []byte, signature *Signature, dst []byte) bool

Verify verifies a signature against a public key and message

type SecretKey

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

SecretKey represents a BLS secret key

func GenerateKey

func GenerateKey() (*SecretKey, error)

GenerateKey generates a new random secret key

func GenerateKeyFromSeed

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

GenerateKeyFromSeed generates a secret key from a seed

func NewSecretKey

func NewSecretKey(data []byte) (*SecretKey, error)

NewSecretKey creates a new secret key from bytes

func (*SecretKey) Deserialize

func (sk *SecretKey) Deserialize(data []byte) error

Deserialize deserializes a secret key

func (*SecretKey) GetPublicKey

func (sk *SecretKey) GetPublicKey() *PublicKey

GetPublicKey derives the public key from a secret key

func (*SecretKey) Serialize

func (sk *SecretKey) Serialize() []byte

Serialize serializes a secret key

func (*SecretKey) Sign

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

Sign signs a message with the secret key

type Signature

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

Signature represents a BLS signature (G2 point)

func NewSignature

func NewSignature(data []byte) (*Signature, error)

NewSignature creates a new signature from bytes

func (*Signature) Deserialize

func (sig *Signature) Deserialize(data []byte) error

Deserialize deserializes a signature from compressed format

func (*Signature) Equal

func (sig *Signature) Equal(other *Signature) bool

Equal checks if two signatures are equal

func (*Signature) Serialize

func (sig *Signature) Serialize() []byte

Serialize serializes a signature to compressed format

Jump to

Keyboard shortcuts

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