types

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 4

README

go-eth2-types

Tag License GoDoc Travis CI codecov.io

Go library providing Ethereum 2 types.

** Please note that this library uses standards that are not yet final, and as such may result in changes that alter public and private keys. Do not use this library for production use just yet **

Table of Contents

Install

go-eth2-types is a standard Go module which can be installed with:

go get github.com/wealdtech/go-eth2-types

Usage

Please read the Go documentation for this library.

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0 © 2019 Weald Technology Trading Ltd

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DomainBeaconProposer is a domain constant.
	DomainBeaconProposer = []byte{0, 0, 0, 0}
	// DomainBeaconAttester is a domain constant.
	DomainBeaconAttester = []byte{1, 0, 0, 0}
	// DomainRANDAO is a domain constant.
	DomainRANDAO = []byte{2, 0, 0, 0}
	// DomainDeposit is a domain constant.
	DomainDeposit = []byte{3, 0, 0, 0}
	// DomainVoluntaryExit is a domain constant.
	DomainVoluntaryExit = []byte{4, 0, 0, 0}
)
View Source
var ErrMalformed = errors.New("malformed representation")

ErrMalformed is returned when an external representation cannot be turned in to a native representation

Functions

func Domain

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

Domain returns a uint64 domain

Types

type BLSPrivateKey

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

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

func BLSPrivateKeyFromBytes

func BLSPrivateKeyFromBytes(priv []byte) (*BLSPrivateKey, error)

BLSPrivateKeyFromBytes creates a BLS private key from a byte slice.

func GenerateBLSPrivateKey

func GenerateBLSPrivateKey() (*BLSPrivateKey, error)

GenerateBLSPrivateKey generates a random BLS private key.

func (*BLSPrivateKey) Marshal

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

Marshal a secret key into a byte slice.

func (*BLSPrivateKey) PublicKey

func (p *BLSPrivateKey) PublicKey() PublicKey

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

func (*BLSPrivateKey) Sign

func (p *BLSPrivateKey) Sign(msg []byte, domain uint64) Signature

Sign a message using a secret key.

type BLSPublicKey

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

BLSPublicKey used in the BLS signature scheme.

func BLSPublicKeyFromBytes

func BLSPublicKeyFromBytes(pub []byte) (*BLSPublicKey, error)

BLSPublicKeyFromBytes creates a BLS public key from a byte slice.

func (*BLSPublicKey) Aggregate

func (p *BLSPublicKey) Aggregate(other PublicKey) PublicKey

Aggregate two public keys.

func (*BLSPublicKey) Marshal

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

Marshal a BLS public key into a byte slice.

type BLSSignature

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

BLSSignature is a BLS signature.

func (*BLSSignature) Marshal

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

Marshal a signature into a byte slice.

func (*BLSSignature) Verify

func (s *BLSSignature) Verify(msg []byte, pubKey PublicKey, domain uint64) bool

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

func (*BLSSignature) VerifyAggregate

func (s *BLSSignature) VerifyAggregate(msgs [][32]byte, pubKeys []PublicKey, domain uint64) bool

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

func (*BLSSignature) VerifyAggregateCommon

func (s *BLSSignature) VerifyAggregateCommon(msg []byte, pubKeys []PublicKey, domain uint64) bool

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

type PrivateKey

type PrivateKey interface {
	PublicKey() PublicKey
	Sign(msg []byte, domain uint64) Signature
	Marshal() []byte
}

PrivateKey is a private key in Ethereum 2.

type PublicKey

type PublicKey interface {
	Marshal() []byte
	Aggregate(p2 PublicKey) PublicKey
}

PublicKey is an interface for public keys

type Signature

type Signature interface {
	Verify(msg []byte, pub PublicKey, domain uint64) bool
	VerifyAggregate(msgs [][32]byte, pubKeys []PublicKey, domain uint64) bool
	VerifyAggregateCommon(msg []byte, pubKeys []PublicKey, domain uint64) bool
	Marshal() []byte
}

func AggregateSignatures

func AggregateSignatures(sigs []Signature) Signature

AggregateSignatures aggregates a slice of signatures.

func BLSSignatureFromBytes

func BLSSignatureFromBytes(data []byte) (Signature, error)

BLSSignatureFromBytes creates a BLS signature from a byte slice.

Jump to

Keyboard shortcuts

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