bls381

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateVerify

func AggregateVerify(publicKeys []*PublicKey, messages [][]byte, aggSignature *Signature) (bool, error)

AggregateVerify verifies an aggregated signature against multiple public keys and multiple messages

func BatchVerify

func BatchVerify(publicKeys []*PublicKey, message []byte, signatures []*Signature) (bool, error)

BatchVerify verifies multiple signatures in a single batch operation Each signature corresponds to the same message signed by different public keys

func GenerateKeyPair

func GenerateKeyPair() (*PrivateKey, *PublicKey, error)

GenerateKeyPair creates a new random private key and the corresponding public key

func GenerateKeyPairEIP2333

func GenerateKeyPairEIP2333(seed []byte, path []uint32) (*PrivateKey, *PublicKey, error)

GenerateKeyPairEIP2333 creates a deterministic private key and the corresponding public key using the EIP-2333 standard Implements the EIP-2333 hierarchical deterministic key generation for BLS signatures See: https://eips.ethereum.org/EIPS/eip-2333

func GenerateKeyPairFromSeed

func GenerateKeyPairFromSeed(seed []byte) (*PrivateKey, *PublicKey, error)

GenerateKeyPairFromSeed creates a deterministic private key and the corresponding public key from a seed

Types

type PrivateKey

type PrivateKey struct {
	ScalarBytes []byte
	// contains filtered or unexported fields
}

PrivateKey represents a BLS private key

func NewPrivateKeyFromBytes

func NewPrivateKeyFromBytes(data []byte) (*PrivateKey, error)

NewPrivateKeyFromBytes creates a private key from bytes

func NewPrivateKeyFromHexString added in v0.0.2

func NewPrivateKeyFromHexString(hexStr string) (*PrivateKey, error)

NewPrivateKeyFromHexString creates a private key from a hex string

func (*PrivateKey) Bytes

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

Bytes returns the private key as a byte slice

func (*PrivateKey) Public

func (pk *PrivateKey) Public() *PublicKey

Public returns the public key corresponding to the private key

func (*PrivateKey) Sign

func (pk *PrivateKey) Sign(message []byte) (*Signature, error)

Sign signs a message using the private key

func (*PrivateKey) ToHex added in v0.0.2

func (pk *PrivateKey) ToHex() (string, error)

ToHex returns the private key as a hex string

type PublicKey

type PublicKey struct {
	PointBytes []byte
	// contains filtered or unexported fields
}

PublicKey represents a BLS public key

func NewPublicKeyFromBytes

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

NewPublicKeyFromBytes creates a public key from bytes

func NewPublicKeyFromHexString

func NewPublicKeyFromHexString(pubHex string) (*PublicKey, error)

func (*PublicKey) Bytes

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

Bytes returns the public key as a byte slice

func (*PublicKey) GetG1Point

func (pk *PublicKey) GetG1Point() *bls12381.G1Affine

GetG1Point returns the G1 point of the public key

func (*PublicKey) GetG2Point

func (pk *PublicKey) GetG2Point() *bls12381.G2Affine

GetG2Point returns the G2 point of the public key

type Scheme

type Scheme struct{}

Scheme implements the SigningScheme interface for BLS381

func NewScheme

func NewScheme() *Scheme

NewScheme creates a new BLS381 signing scheme

func (*Scheme) AggregateSignatures

func (s *Scheme) AggregateSignatures(signatures []signing.Signature) (signing.Signature, error)

AggregateSignatures combines multiple signatures into a single signature

func (*Scheme) AggregateVerify

func (s *Scheme) AggregateVerify(publicKeys []signing.PublicKey, messages [][]byte, aggSignature signing.Signature) (bool, error)

AggregateVerify verifies an aggregated signature against multiple public keys and multiple messages

func (*Scheme) BatchVerify

func (s *Scheme) BatchVerify(publicKeys []signing.PublicKey, message []byte, signatures []signing.Signature) (bool, error)

BatchVerify verifies multiple signatures in a single batch operation

func (*Scheme) GenerateKeyPair

func (s *Scheme) GenerateKeyPair() (signing.PrivateKey, signing.PublicKey, error)

GenerateKeyPair creates a new random private key and the corresponding public key

func (*Scheme) GenerateKeyPairEIP2333

func (s *Scheme) GenerateKeyPairEIP2333(seed []byte, path []uint32) (signing.PrivateKey, signing.PublicKey, error)

GenerateKeyPairEIP2333 creates a deterministic private key and the corresponding public key using the EIP-2333 standard

func (*Scheme) GenerateKeyPairFromSeed

func (s *Scheme) GenerateKeyPairFromSeed(seed []byte) (signing.PrivateKey, signing.PublicKey, error)

GenerateKeyPairFromSeed creates a deterministic private key and the corresponding public key from a seed

func (*Scheme) NewPrivateKeyFromBytes

func (s *Scheme) NewPrivateKeyFromBytes(data []byte) (signing.PrivateKey, error)

NewPrivateKeyFromBytes creates a private key from bytes

func (*Scheme) NewPrivateKeyFromHexString added in v0.0.2

func (s *Scheme) NewPrivateKeyFromHexString(hex string) (signing.PrivateKey, error)

NewPrivateKeyFromHexString creates a private key from a hex string

func (*Scheme) NewPublicKeyFromBytes

func (s *Scheme) NewPublicKeyFromBytes(data []byte) (signing.PublicKey, error)

NewPublicKeyFromBytes creates a public key from bytes

func (*Scheme) NewPublicKeyFromHexString

func (s *Scheme) NewPublicKeyFromHexString(hex string) (signing.PublicKey, error)

func (*Scheme) NewSignatureFromBytes

func (s *Scheme) NewSignatureFromBytes(data []byte) (signing.Signature, error)

NewSignatureFromBytes creates a signature from bytes

type Signature

type Signature struct {
	SigBytes []byte
	// contains filtered or unexported fields
}

Signature represents a BLS signature

func AggregateSignatures

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

AggregateSignatures combines multiple signatures into a single signature

func NewSignatureFromBytes

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

NewSignatureFromBytes creates a signature from bytes

func (*Signature) Add added in v0.0.4

func (s *Signature) Add(other *Signature) *Signature

Add adds another signature to this one

func (*Signature) Bytes

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

Bytes returns the signature as a byte slice

func (*Signature) Verify

func (s *Signature) Verify(publicKey *PublicKey, message []byte) (bool, error)

Verify verifies a signature against a message and public key

func (*Signature) VerifySolidityCompatible added in v0.0.4

func (sig *Signature) VerifySolidityCompatible(publicKey *PublicKey, messageHash [32]byte) (bool, error)

Jump to

Keyboard shortcuts

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