bls

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitBLS

func InitBLS() error

InitBLS initialises the BLS library with the appropriate curve and parameters for Ethereum 2.

Types

type ID

type ID struct {
	Id bls.ID
}

func (*ID) GetHexString

func (id *ID) GetHexString() string

func (*ID) SetDec

func (id *ID) SetDec(dec uint64) error

type PrivateKey

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

PrivateKey is a private key in Ethereum 2. It is a point on the BLS12-381 curve.

func EmptyPrivateKey

func EmptyPrivateKey() *PrivateKey

func GeneratePrivateKey

func GeneratePrivateKey() (*PrivateKey, error)

GeneratePrivateKey generates a random BLS private key.

func PrivateKeyFromBytes

func PrivateKeyFromBytes(priv []byte) (*PrivateKey, error)

PrivateKeyFromBytes creates a BLS private key from a byte slice.

func (*PrivateKey) Marshal

func (p *PrivateKey) Marshal() []byte

Marshal a secret key into a byte slice.

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() *PublicKey

PublicKey obtains the public key corresponding to the BLS secret key.

func (*PrivateKey) SerializeToHexStr

func (p *PrivateKey) SerializeToHexStr() string

func (*PrivateKey) Set

func (p *PrivateKey) Set(pkeys []*PrivateKey, id *ID) error

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(msg []byte) *Signature

Sign a message using a secret key.

type PublicKey

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

PublicKey used in the BLS signature scheme.

func EmptyPublicKey

func EmptyPublicKey() *PublicKey

func PublicKeyFromBytes

func PublicKeyFromBytes(pub []byte) (*PublicKey, error)

PublicKeyFromBytes creates a BLS public key from a byte slice.

func (*PublicKey) Aggregate

func (k *PublicKey) Aggregate(other *PublicKey)

Aggregate two public keys. This updates the value of the existing key.

func (*PublicKey) Copy

func (k *PublicKey) Copy() *PublicKey

Copy creates a copy of the public key.

func (*PublicKey) Marshal

func (k *PublicKey) Marshal() []byte

Marshal a BLS public key into a byte slice.

func (*PublicKey) SerializeToHexStr

func (p *PublicKey) SerializeToHexStr() string

func (*PublicKey) Set

func (p *PublicKey) Set(pkeys []*PublicKey, id *ID) error

type Signature

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

Signature is a BLS signature.

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) *Signature

AggregateSignatures aggregates signatures.

func SignatureFromBytes

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

SignatureFromBytes creates a BLS signature from a byte slice.

func SignatureFromSig

func SignatureFromSig(sig bls.Sign) (*Signature, error)

SignatureFromSig creates a BLS signature from an existing signature.

func (*Signature) Marshal

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

Marshal a signature into a byte slice.

func (*Signature) Verify

func (s *Signature) Verify(msg []byte, pubKey *PublicKey) bool

Verify a bls signature given a public key and a message.

func (*Signature) VerifyAggregate

func (s *Signature) VerifyAggregate(msgs [][]byte, pubKeys []*PublicKey) bool

VerifyAggregate verifies each public key against its respective message. Note: this is vulnerable to a rogue public-key attack.

func (*Signature) VerifyAggregateCommon

func (s *Signature) VerifyAggregateCommon(msg []byte, pubKeys []*PublicKey) bool

VerifyAggregateCommon verifies each public key against a single message. Note: this is vulnerable to a rogue public-key attack.

Jump to

Keyboard shortcuts

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