bls

package
v1.17.28 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Overview

Package bls implements BLS threshold signatures.

BLS threshold signatures provide:

  • Non-interactive signature aggregation
  • Constant-size signatures regardless of threshold
  • Efficient verification

This implementation uses Shamir's Secret Sharing for key distribution and Lagrange interpolation for signature combination.

Index

Constants

View Source
const (
	// KeyShareSize is the serialized size of a BLS key share.
	// 32 bytes secret + 48 bytes public share + 48 bytes group key + 4 bytes metadata
	KeyShareSize = 132

	// SignatureShareSize is the serialized size of a signature share.
	// 96 bytes signature + 4 bytes index
	SignatureShareSize = 100

	// SignatureSize is the serialized size of the final signature.
	SignatureSize = 96

	// PublicKeySize is the serialized size of the group public key.
	PublicKeySize = 48
)

Constants for BLS threshold scheme.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

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

Aggregator combines BLS signature shares.

func (*Aggregator) Aggregate

func (a *Aggregator) Aggregate(ctx context.Context, message []byte, shares []threshold.SignatureShare, commitments []threshold.NonceCommitment) (threshold.Signature, error)

Aggregate combines signature shares into a final signature using Lagrange interpolation. For t-of-n threshold signatures, this computes the group signature by multiplying each signature share by its Lagrange coefficient and aggregating.

func (*Aggregator) GroupKey

func (a *Aggregator) GroupKey() threshold.PublicKey

GroupKey returns the group public key.

func (*Aggregator) VerifyShare

func (a *Aggregator) VerifyShare(message []byte, share threshold.SignatureShare, publicShare []byte) error

VerifyShare verifies a single signature share.

type DKG

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

DKG implements distributed key generation for BLS threshold.

func (*DKG) GroupKey

func (d *DKG) GroupKey() threshold.PublicKey

GroupKey returns the group public key after DKG completes.

func (*DKG) NumRounds

func (d *DKG) NumRounds() int

NumRounds returns the number of DKG rounds.

func (*DKG) Round1

func (d *DKG) Round1(ctx context.Context) (threshold.DKGMessage, error)

Round1 generates the first round DKG message.

func (*DKG) Round2

func (d *DKG) Round2(ctx context.Context, round1Messages map[int]threshold.DKGMessage) (threshold.DKGMessage, error)

Round2 processes Round1 messages and generates Round2 messages.

func (*DKG) Round3

func (d *DKG) Round3(ctx context.Context, round2Messages map[int]threshold.DKGMessage) (threshold.KeyShare, error)

Round3 processes Round2 messages and generates the final key share.

type DKGMessage

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

DKGMessage represents a DKG protocol message.

func (*DKGMessage) Bytes

func (m *DKGMessage) Bytes() []byte

Bytes serializes the message.

func (*DKGMessage) FromParty

func (m *DKGMessage) FromParty() int

FromParty returns the sender's party index.

func (*DKGMessage) Round

func (m *DKGMessage) Round() int

Round returns the round number.

type KeyShare

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

KeyShare represents a party's BLS key share.

func (*KeyShare) Bytes

func (ks *KeyShare) Bytes() []byte

Bytes serializes the key share.

func (*KeyShare) GroupKey

func (ks *KeyShare) GroupKey() threshold.PublicKey

GroupKey returns the group public key.

func (*KeyShare) Index

func (ks *KeyShare) Index() int

Index returns the party index.

func (*KeyShare) PublicShare

func (ks *KeyShare) PublicShare() []byte

PublicShare returns this party's public key share.

func (*KeyShare) SchemeID

func (ks *KeyShare) SchemeID() threshold.SchemeID

SchemeID returns the scheme identifier.

func (*KeyShare) Threshold

func (ks *KeyShare) Threshold() int

Threshold returns the signing threshold.

func (*KeyShare) TotalParties

func (ks *KeyShare) TotalParties() int

TotalParties returns the total number of parties.

type PublicKey

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

PublicKey represents a BLS threshold group public key.

func (*PublicKey) Bytes

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

Bytes serializes the public key.

func (*PublicKey) Equal

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

Equal returns true if the public keys are identical.

func (*PublicKey) SchemeID

func (pk *PublicKey) SchemeID() threshold.SchemeID

SchemeID returns the scheme identifier.

type Scheme

type Scheme struct{}

Scheme implements the BLS threshold signature scheme.

func (*Scheme) ID

func (s *Scheme) ID() threshold.SchemeID

ID returns the scheme identifier.

func (*Scheme) KeyShareSize

func (s *Scheme) KeyShareSize() int

KeyShareSize returns the serialized key share size.

func (*Scheme) Name

func (s *Scheme) Name() string

Name returns the human-readable name.

func (*Scheme) NewAggregator

func (s *Scheme) NewAggregator(groupKey threshold.PublicKey) (threshold.Aggregator, error)

NewAggregator creates a signature aggregator for the given group key.

func (*Scheme) NewDKG

func (s *Scheme) NewDKG(config threshold.DKGConfig) (threshold.DKG, error)

NewDKG creates a new distributed key generation instance.

func (*Scheme) NewSigner

func (s *Scheme) NewSigner(share threshold.KeyShare) (threshold.Signer, error)

NewSigner creates a signer from a key share.

func (*Scheme) NewTrustedDealer

func (s *Scheme) NewTrustedDealer(config threshold.DealerConfig) (threshold.TrustedDealer, error)

NewTrustedDealer creates a trusted dealer for centralized key generation.

func (*Scheme) NewVerifier

func (s *Scheme) NewVerifier(groupKey threshold.PublicKey) (threshold.Verifier, error)

NewVerifier creates a signature verifier for the given group key.

func (*Scheme) ParseKeyShare

func (s *Scheme) ParseKeyShare(data []byte) (threshold.KeyShare, error)

ParseKeyShare deserializes a key share from bytes.

func (*Scheme) ParsePublicKey

func (s *Scheme) ParsePublicKey(data []byte) (threshold.PublicKey, error)

ParsePublicKey deserializes a group public key from bytes.

func (*Scheme) ParseSignature

func (s *Scheme) ParseSignature(data []byte) (threshold.Signature, error)

ParseSignature deserializes a final signature from bytes.

func (*Scheme) ParseSignatureShare

func (s *Scheme) ParseSignatureShare(data []byte) (threshold.SignatureShare, error)

ParseSignatureShare deserializes a signature share from bytes.

func (*Scheme) PublicKeySize

func (s *Scheme) PublicKeySize() int

PublicKeySize returns the serialized public key size.

func (*Scheme) SignatureShareSize

func (s *Scheme) SignatureShareSize() int

SignatureShareSize returns the serialized signature share size.

func (*Scheme) SignatureSize

func (s *Scheme) SignatureSize() int

SignatureSize returns the serialized final signature size.

type Signature

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

Signature represents a final BLS threshold signature.

func (*Signature) Bytes

func (s *Signature) Bytes() []byte

Bytes serializes the signature.

func (*Signature) SchemeID

func (s *Signature) SchemeID() threshold.SchemeID

SchemeID returns the scheme identifier.

type SignatureShare

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

SignatureShare represents a BLS signature share.

func (*SignatureShare) Bytes

func (ss *SignatureShare) Bytes() []byte

Bytes serializes the signature share.

func (*SignatureShare) Index

func (ss *SignatureShare) Index() int

Index returns the party index.

func (*SignatureShare) SchemeID

func (ss *SignatureShare) SchemeID() threshold.SchemeID

SchemeID returns the scheme identifier.

type Signer

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

Signer creates BLS signature shares.

func (*Signer) Index

func (s *Signer) Index() int

Index returns the party index.

func (*Signer) KeyShare

func (s *Signer) KeyShare() threshold.KeyShare

KeyShare returns the underlying key share.

func (*Signer) NonceGen

NonceGen generates a nonce commitment. BLS threshold doesn't require nonces for aggregation.

func (*Signer) PublicShare

func (s *Signer) PublicShare() []byte

PublicShare returns this party's public key share.

func (*Signer) SignShare

func (s *Signer) SignShare(ctx context.Context, message []byte, signers []int, nonce threshold.NonceState) (threshold.SignatureShare, error)

SignShare creates a signature share for the given message.

type TrustedDealer

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

TrustedDealer generates key shares using a trusted dealer.

func (*TrustedDealer) GenerateShares

func (d *TrustedDealer) GenerateShares(ctx context.Context) ([]threshold.KeyShare, threshold.PublicKey, error)

GenerateShares creates all key shares and the group public key.

type Verifier

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

Verifier verifies BLS threshold signatures.

func (*Verifier) GroupKey

func (v *Verifier) GroupKey() threshold.PublicKey

GroupKey returns the group public key.

func (*Verifier) Verify

func (v *Verifier) Verify(message []byte, signature threshold.Signature) bool

Verify checks if a signature is valid.

func (*Verifier) VerifyBytes

func (v *Verifier) VerifyBytes(message, signature []byte) bool

VerifyBytes verifies a serialized signature.

Jump to

Keyboard shortcuts

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