Documentation ¶
Overview ¶
Package types provides generic types for the Ethereum consensus system.
Code generated by fastssz. DO NOT EDIT. Hash: 8081802cb4896b4b267c7066039a5f7fd3ba8d657e72369339f506ac22bc50b4
Index ¶
- Variables
- func ComputeDomain(domainType DomainType, forkVersion []byte, genesisValidatorsRoot []byte) ([]byte, error)
- func Domain(domainType DomainType, forkVersion []byte, genesisValidatorsRoot []byte) []byte
- func InitBLS() error
- type BLSPrivateKey
- type BLSPublicKey
- type BLSSignature
- type DomainType
- type ForkData
- func (f *ForkData) GetTree() (*ssz.Node, error)
- func (f *ForkData) HashTreeRoot() ([32]byte, error)
- func (f *ForkData) HashTreeRootWith(hh ssz.HashWalker) (err error)
- func (f *ForkData) MarshalSSZ() ([]byte, error)
- func (f *ForkData) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (f *ForkData) SizeSSZ() (size int)
- func (f *ForkData) UnmarshalSSZ(buf []byte) error
- type PrivateKey
- type PublicKey
- type Signature
Constants ¶
This section is empty.
Variables ¶
var ( // DomainBeaconProposer is a domain constant. DomainBeaconProposer = DomainType{0, 0, 0, 0} // DomainBeaconAttester is a domain constant. DomainBeaconAttester = DomainType{1, 0, 0, 0} // DomainRANDAO is a domain constant. DomainRANDAO = DomainType{2, 0, 0, 0} // DomainDeposit is a domain constant. DomainDeposit = DomainType{3, 0, 0, 0} // DomainVoluntaryExit is a domain constant. DomainVoluntaryExit = DomainType{4, 0, 0, 0} // DomainSelectionProof is a domain constant. DomainSelectionProof = DomainType{5, 0, 0, 0} // DomainAggregateAndProof is a domain constant. DomainAggregateAndProof = DomainType{6, 0, 0, 0} // DomainSyncCommittee is a domain constant. DomainSyncCommittee = DomainType{7, 0, 0, 0} // DomainSyncCommitteeSelectionProof is a domain constant. DomainSyncCommitteeSelectionProof = DomainType{8, 0, 0, 0} // DomainContributionAndProof is a domain constant. DomainContributionAndProof = DomainType{9, 0, 0, 0} // DomainBlsToExecutionChange is a domain constant. DomainBlsToExecutionChange = DomainType{0x0A, 0, 0, 0} )
var ErrMalformed = errors.New("malformed representation")
ErrMalformed is returned when an external representation cannot be turned in to a native representation.
var ZeroForkVersion = []byte{0, 0, 0, 0}
ZeroForkVersion is an empty fork version.
var ZeroGenesisValidatorsRoot = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
ZeroGenesisValidatorsRoot is an empty genesis validators root.
Functions ¶
func ComputeDomain ¶ added in v2.5.1
func ComputeDomain(domainType DomainType, forkVersion []byte, genesisValidatorsRoot []byte) ([]byte, error)
ComputeDomain computes a 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) 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 (k *BLSPublicKey) Aggregate(other PublicKey)
Aggregate two public keys. This updates the value of the existing key.
func (*BLSPublicKey) Copy ¶
func (k *BLSPublicKey) Copy() PublicKey
Copy creates a copy of the public key.
func (*BLSPublicKey) Marshal ¶
func (k *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 AggregateSignatures ¶
func AggregateSignatures(sigs []Signature) *BLSSignature
AggregateSignatures aggregates signatures.
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) bool
Verify a bls signature given a public key and a message.
func (*BLSSignature) VerifyAggregate ¶
func (s *BLSSignature) 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 (*BLSSignature) VerifyAggregateCommon ¶
func (s *BLSSignature) 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.
type DomainType ¶ added in v2.1.0
type DomainType [4]byte
DomainType defines the type of the domain, as per https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#custom-types
type ForkData ¶ added in v2.5.1
type ForkData struct { CurrentVersion []byte `ssz-size:"4"` GenesisValidatorsRoot []byte `ssz-size:"32"` }
ForkData is a spec struct.
func (*ForkData) HashTreeRoot ¶ added in v2.5.1
HashTreeRoot ssz hashes the ForkData object
func (*ForkData) HashTreeRootWith ¶ added in v2.5.1
func (f *ForkData) HashTreeRootWith(hh ssz.HashWalker) (err error)
HashTreeRootWith ssz hashes the ForkData object with a hasher
func (*ForkData) MarshalSSZ ¶ added in v2.5.1
MarshalSSZ ssz marshals the ForkData object
func (*ForkData) MarshalSSZTo ¶ added in v2.5.1
MarshalSSZTo ssz marshals the ForkData object to a target array
func (*ForkData) SizeSSZ ¶ added in v2.5.1
SizeSSZ returns the ssz encoded size in bytes for the ForkData object
func (*ForkData) UnmarshalSSZ ¶ added in v2.5.1
UnmarshalSSZ ssz unmarshals the ForkData object
type PrivateKey ¶
PrivateKey is a private key in Ethereum 2.
type Signature ¶
type Signature interface { Verify(msg []byte, pub PublicKey) bool VerifyAggregate(msgs [][]byte, pubKeys []PublicKey) bool VerifyAggregateCommon(msg []byte, pubKeys []PublicKey) bool Marshal() []byte }
Signature is an interface for signatures.
func BLSSignatureFromBytes ¶
BLSSignatureFromBytes creates a BLS signature from a byte slice.