bls

package
v0.0.0-...-d79950a Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bls implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme. This package exposes a public API for verifying and aggregating BLS signatures used by Ethereum 2.0.

Index

Constants

View Source
const CurveOrder = "52435875175126190479447740508185965837690552500527637822603658699938581184513"

CurveOrder for the BLS12-381 curve.

View Source
const DomainByteLength = 4

DomainByteLength length of domain byte array.

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicKey

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

PublicKey used in the BLS signature scheme.

func PublicKeyFromBytes

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

PublicKeyFromBytes creates a BLS public key from a BigEndian byte slice.

func (*PublicKey) Aggregate

func (p *PublicKey) Aggregate(p2 *PublicKey) *PublicKey

Aggregate two public keys.

func (*PublicKey) Copy

func (p *PublicKey) Copy() (*PublicKey, error)

Copy the public key to a new pointer reference.

func (*PublicKey) Marshal

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

Marshal a public key into a LittleEndian byte slice.

type SecretKey

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

SecretKey used in the BLS signature scheme.

func RandKey

func RandKey() *SecretKey

RandKey creates a new private key using a random method provided as an io.Reader.

func SecretKeyFromBytes

func SecretKeyFromBytes(priv []byte) (*SecretKey, error)

SecretKeyFromBytes creates a BLS private key from a BigEndian byte slice.

func (*SecretKey) Marshal

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

Marshal a secret key into a LittleEndian byte slice.

func (*SecretKey) PublicKey

func (s *SecretKey) PublicKey() *PublicKey

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

func (*SecretKey) Sign

func (s *SecretKey) Sign(msg []byte) *Signature

Sign a message using a secret key - in a beacon/validator client.

In IETF draft BLS specification: Sign(SK, message) -> signature: a signing algorithm that generates

a deterministic signature given a secret key SK and a message.

In ETH2.0 specification: def Sign(SK: int, message: Bytes) -> BLSSignature

type Signature

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

Signature used in the BLS signature scheme.

func Aggregate

func Aggregate(sigs []*Signature) *Signature

Aggregate is an alias for AggregateSignatures, defined to conform to BLS specification.

In IETF draft BLS specification: Aggregate(signature_1, ..., signature_n) -> signature: an

aggregation algorithm that compresses a collection of signatures
into a single signature.

In ETH2.0 specification: def Aggregate(signatures: Sequence[BLSSignature]) -> BLSSignature

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) *Signature

AggregateSignatures converts a list of signatures into a single, aggregated sig.

func NewAggregateSignature

func NewAggregateSignature() *Signature

NewAggregateSignature creates a blank aggregate signature.

func SignatureFromBytes

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

SignatureFromBytes creates a BLS signature from a LittleEndian byte slice.

func (*Signature) AggregateVerify

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

AggregateVerify verifies each public key against its respective message. This is vulnerable to rogue public-key attack. Each user must provide a proof-of-knowledge of the public key.

In IETF draft BLS specification: AggregateVerify((PK_1, message_1), ..., (PK_n, message_n),

signature) -> VALID or INVALID: an aggregate verification
algorithm that outputs VALID if signature is a valid aggregated
signature for a collection of public keys and messages, and
outputs INVALID otherwise.

In ETH2.0 specification: def AggregateVerify(pairs: Sequence[PK: BLSPubkey, message: Bytes], signature: BLSSignature) -> boo

func (*Signature) FastAggregateVerify

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

FastAggregateVerify verifies all the provided public keys with their aggregated signature.

In IETF draft BLS specification: FastAggregateVerify(PK_1, ..., PK_n, message, signature) -> VALID

or INVALID: a verification algorithm for the aggregate of multiple
signatures on the same message.  This function is faster than
AggregateVerify.

In ETH2.0 specification: def FastAggregateVerify(PKs: Sequence[BLSPubkey], message: Bytes, signature: BLSSignature) -> bool

func (*Signature) Marshal

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

Marshal a signature into a LittleEndian byte slice.

func (*Signature) Verify

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

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

In IETF draft BLS specification: Verify(PK, message, signature) -> VALID or INVALID: a verification

algorithm that outputs VALID if signature is a valid signature of
message under public key PK, and INVALID otherwise.

In ETH2.0 specification: def Verify(PK: BLSPubkey, message: Bytes, signature: BLSSignature) -> bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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