bls

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bls implements Filecoin BLS12-381 signature verification using github.com/consensys/gnark-crypto/ecc/bls12-381. The Filecoin BLS Domain Separation Tag is

BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_

Filecoin uses the "minimum-pubkey-size" BLS variant: public keys live on G1, signatures on G2. Messages are hashed to G2 using the SSWU map with the DST above; verification computes the pairing equality

e(g1, sig) == e(pk, H(msg))

This package implements Verify and AggregateVerify with that scheme.

Index

Constants

View Source
const (
	PrivateKeyBytes = 32
	PublicKeyBytes  = 48
	SignatureBytes  = 96
)

Sizes of compressed serialized group elements, matching filecoin-ffi.

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

DST is the Filecoin BLS domain separation tag.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(sigs ...[]byte) ([]byte, error)

Aggregate combines a list of BLS signatures (each 96-byte compressed G2) into a single 96-byte aggregate signature via point addition on G2.

func HashVerify

func HashVerify(sig []byte, msgs [][]byte, pubkeys [][]byte) error

HashVerify checks an aggregated BLS signature over a sequence of (message, pubkey) pairs. Returns nil iff

e(G1, sig) == prod_i e(pk_i, H(msg_i)).

This mirrors filecoin-ffi's HashVerify, which is what Lotus uses to verify the BlockHeader.BLSAggregate field over the in-block BLS messages.

func Verify

func Verify(sig []byte, pubkey []byte, msg []byte) error

Verify checks that sig is a valid Filecoin BLS signature on msg under pubkey. pubkey is the compressed 48-byte G1 encoding, sig is the compressed 96-byte G2 encoding.

Types

This section is empty.

Jump to

Keyboard shortcuts

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