Documentation ¶
Index ¶
- Variables
- func Domain(domainType []byte, forkVersion []byte) uint64
- type BLSPrivateKey
- type BLSPublicKey
- type BLSSignature
- func (s *BLSSignature) Marshal() []byte
- func (s *BLSSignature) Verify(msg []byte, pubKey PublicKey, domain uint64) bool
- func (s *BLSSignature) VerifyAggregate(msgs [][32]byte, pubKeys []PublicKey, domain uint64) bool
- func (s *BLSSignature) VerifyAggregateCommon(msg []byte, pubKeys []PublicKey, domain uint64) bool
- type PrivateKey
- type PublicKey
- type Signature
Constants ¶
This section is empty.
Variables ¶
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} )
var ErrMalformed = errors.New("malformed representation")
ErrMalformed is returned when an external representation cannot be turned in to a native representation
Functions ¶
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.
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 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 ¶
AggregateSignatures aggregates a slice of signatures.
func BLSSignatureFromBytes ¶
BLSSignatureFromBytes creates a BLS signature from a byte slice.