bls

package
v0.0.0-...-0e3e10b Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 License: GPL-3.0 Imports: 4 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

This section is empty.

Variables

This section is empty.

Functions

func Domain

func Domain(domainType []byte, forkVersion []byte) uint64

Domain returns the bls domain given by the domain type and the operation 4 byte fork version.

Spec pseudocode definition:

def get_domain(state: MasternodeState, domain_type: DomainType, message_epoch: Epoch=None) -> Domain:
  """
  Return the signature domain (fork version concatenated with domain type) of a message.
  """
  epoch = get_current_epoch(state) if message_epoch is None else message_epoch
  fork_version = state.fork.previous_version if epoch < state.fork.epoch else state.fork.current_version
  return compute_domain(domain_type, fork_version)

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 byte slice.

func (*PublicKey) Aggregate

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

Aggregate two public keys.

func (*PublicKey) Marshal

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

Marshal a public key into a byte slice.

type SecretKey

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

SecretKey used in the BLS signature scheme.

func RandKey

func RandKey(r io.Reader) (*SecretKey, error)

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 byte slice.

func (*SecretKey) Marshal

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

Marshal a secret key into a 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, domain uint64) *Signature

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

type Signature

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

Signature used in the BLS signature scheme.

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) *Signature

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

func SignatureFromBytes

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

SignatureFromBytes creates a BLS signature from a byte slice.

func (*Signature) Marshal

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

Marshal a signature into a byte slice.

func (*Signature) Verify

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

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

func (*Signature) VerifyAggregate

func (s *Signature) VerifyAggregate(pubKeys []*PublicKey, msg []byte, domain uint64) bool

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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