Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeETHDomain(domain phase0.DomainType, fork phase0.Version) (phase0.Domain, error)
- func ComputeETHSigningRoot(root phase0.Root, domain phase0.Domain) (phase0.Root, error)
- func ComputeSigningRoot(data Root, domain SignatureDomain) ([]byte, error)
- func Decrypt(sk *rsa.PrivateKey, cipherText []byte) ([]byte, error)
- func Encrypt(pk *rsa.PublicKey, plainText []byte) ([]byte, error)
- func GenerateETHDepositData(validatorPK, withdrawalCredentials []byte, fork phase0.Version, ...) ([]byte, *phase0.DepositData, error)
- func GenerateKey() ([]byte, []byte, error)
- func GetPublicKeyPem(sk *rsa.PrivateKey) ([]byte, error)
- func InitBLS()
- func PemToPrivateKey(skPem []byte) (*rsa.PrivateKey, error)
- func PemToPublicKey(pkPem []byte) (*rsa.PublicKey, error)
- func PrivateKeyToPem(sk *rsa.PrivateKey) []byte
- func ReconstructSignatures(signatures map[OperatorID][]byte) (*bls.Sign, error)
- func VerifyReconstructedSignature(sig *bls.Sign, validatorPubKey, root []byte) error
- type AggregatorCalls
- type AttesterCalls
- type BeaconNetwork
- func (n BeaconNetwork) EstimatedCurrentEpoch() spec.Epoch
- func (n BeaconNetwork) EstimatedCurrentSlot() spec.Slot
- func (n BeaconNetwork) EstimatedEpochAtSlot(slot spec.Slot) spec.Epoch
- func (n BeaconNetwork) EstimatedSlotAtTime(time int64) spec.Slot
- func (n BeaconNetwork) ForkVersion() [4]byte
- func (n BeaconNetwork) MinGenesisTime() uint64
- func (n BeaconNetwork) SlotDurationSec() time.Duration
- func (n BeaconNetwork) SlotsPerEpoch() uint64
- type BeaconRole
- type BeaconSigner
- type ConsensusData
- type ContributionsMap
- type DKGSigner
- type DomainType
- type Duty
- type Encoder
- type EncryptionCalls
- type KeyManager
- type MessageID
- type MessageSignature
- type MsgType
- type Operator
- type OperatorID
- type ProposerCalls
- type Root
- type SSVMessage
- type SSVSigner
- type Share
- type Signature
- func (s Signature) Aggregate(other Signature) (Signature, error)
- func (s Signature) ECRecover(data Root, domain DomainType, sigType SignatureType, address common.Address) error
- func (s Signature) Verify(data Root, domain DomainType, sigType SignatureType, pkByts []byte) error
- func (s Signature) VerifyByOperators(data MessageSignature, domain DomainType, sigType SignatureType, ...) error
- func (s Signature) VerifyMultiPubKey(data Root, domain DomainType, sigType SignatureType, pks [][]byte) error
- type SignatureDomain
- type SignatureType
- type SyncCommitteeCalls
- type SyncCommitteeContributionCalls
- type ThreadSafeF
- type Validate
- type ValidatorPK
Constants ¶
const BLSWithdrawalPrefixByte = byte(0)
BLSWithdrawalPrefixByte is the BLS withdrawal prefix
const MaxEffectiveBalanceInGwei uint64 = 32000000000
MaxEffectiveBalanceInGwei is the max effective balance
Variables ¶
var ( // PrimusTestnet is the domain for primus testnet PrimusTestnet = DomainType("primus_testnet") // ShifuTestnet is the domain for shifu testnet ShifuTestnet = DomainType("shifu") )
var DomainDeposit = [4]byte{0x03, 0x00, 0x00, 0x00}
Functions ¶
func ComputeETHDomain ¶
ComputeETHDomain returns computed domain
func ComputeETHSigningRoot ¶
func ComputeSigningRoot ¶
func ComputeSigningRoot(data Root, domain SignatureDomain) ([]byte, error)
func Decrypt ¶ added in v0.2.2
func Decrypt(sk *rsa.PrivateKey, cipherText []byte) ([]byte, error)
Decrypt with secret key (base64) and bytes, return the encrypted key string
func Encrypt ¶ added in v0.2.2
Encrypt with secret key (base64) the bytes, return the encrypted key string
func GenerateETHDepositData ¶
func GenerateETHDepositData( validatorPK, withdrawalCredentials []byte, fork phase0.Version, domain phase0.DomainType) ([]byte, *phase0.DepositData, error)
GenerateETHDepositData returns un-signed deposit data and deposit data root for signature
func GenerateKey ¶ added in v0.2.2
GenerateKey using rsa random generate keys
func GetPublicKeyPem ¶ added in v0.2.2
func GetPublicKeyPem(sk *rsa.PrivateKey) ([]byte, error)
GetPublicKeyPem get public key from private key and return []byte represent the public key
func PemToPrivateKey ¶ added in v0.2.2
func PemToPrivateKey(skPem []byte) (*rsa.PrivateKey, error)
PemToPrivateKey return rsa private key from pem
func PemToPublicKey ¶ added in v0.2.2
PemToPublicKey return rsa public key from pem
func PrivateKeyToPem ¶ added in v0.2.2
func PrivateKeyToPem(sk *rsa.PrivateKey) []byte
PrivateKeyToPem converts privateKey to pem encoded
func ReconstructSignatures ¶
func ReconstructSignatures(signatures map[OperatorID][]byte) (*bls.Sign, error)
ReconstructSignatures receives a map of user indexes and serialized bls.Sign. It then reconstructs the original threshold signature using lagrange interpolation
Types ¶
type AggregatorCalls ¶
type AggregatorCalls interface { // SignSlotWithSelectionProof signs slot for aggregator selection proof SignSlotWithSelectionProof(slot spec.Slot, pk []byte) (Signature, []byte, error) // SignAggregateAndProof returns a signed aggregate and proof msg SignAggregateAndProof(msg *spec.AggregateAndProof, duty *Duty, pk []byte) (*spec.SignedAggregateAndProof, []byte, error) }
type AttesterCalls ¶
type AttesterCalls interface { // SignAttestation signs the given attestation SignAttestation(data *spec.AttestationData, duty *Duty, pk []byte) (*spec.Attestation, []byte, error) // IsAttestationSlashable returns error if attestation is slashable IsAttestationSlashable(data *spec.AttestationData) error }
type BeaconNetwork ¶
type BeaconNetwork string
BeaconNetwork represents the network.
const ( // PraterNetwork represents the Prater test network. PraterNetwork BeaconNetwork = "prater" // MainNetwork represents the main network. MainNetwork BeaconNetwork = "mainnet" // NowTestNetwork is a simple test network with genesis time always equal to now, meaning now is slot 0 NowTestNetwork BeaconNetwork = "now_test_network" )
Available networks.
func NetworkFromString ¶
func NetworkFromString(n string) BeaconNetwork
NetworkFromString returns network from the given string value
func (BeaconNetwork) EstimatedCurrentEpoch ¶
func (n BeaconNetwork) EstimatedCurrentEpoch() spec.Epoch
EstimatedCurrentEpoch estimates the current epoch https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
func (BeaconNetwork) EstimatedCurrentSlot ¶
func (n BeaconNetwork) EstimatedCurrentSlot() spec.Slot
EstimatedCurrentSlot returns the estimation of the current slot
func (BeaconNetwork) EstimatedEpochAtSlot ¶
func (n BeaconNetwork) EstimatedEpochAtSlot(slot spec.Slot) spec.Epoch
EstimatedEpochAtSlot estimates epoch at the given slot
func (BeaconNetwork) EstimatedSlotAtTime ¶
func (n BeaconNetwork) EstimatedSlotAtTime(time int64) spec.Slot
EstimatedSlotAtTime estimates slot at the given time
func (BeaconNetwork) ForkVersion ¶
func (n BeaconNetwork) ForkVersion() [4]byte
ForkVersion returns the fork version of the network.
func (BeaconNetwork) MinGenesisTime ¶
func (n BeaconNetwork) MinGenesisTime() uint64
MinGenesisTime returns min genesis time value
func (BeaconNetwork) SlotDurationSec ¶
func (n BeaconNetwork) SlotDurationSec() time.Duration
SlotDurationSec returns slot duration
func (BeaconNetwork) SlotsPerEpoch ¶
func (n BeaconNetwork) SlotsPerEpoch() uint64
SlotsPerEpoch returns number of slots per one epoch
type BeaconRole ¶
type BeaconRole int
BeaconRole type of the validator role for a specific duty
const ( BNRoleAttester BeaconRole = iota BNRoleAggregator BNRoleProposer BNRoleSyncCommittee BNRoleSyncCommitteeContribution )
List of roles
type BeaconSigner ¶
type BeaconSigner interface { AttesterCalls ProposerCalls AggregatorCalls SyncCommitteeCalls SyncCommitteeContributionCalls }
type ConsensusData ¶
type ConsensusData struct { Duty *Duty AttestationData *phase0.AttestationData BlockData *altair.BeaconBlock AggregateAndProof *phase0.AggregateAndProof SyncCommitteeBlockRoot phase0.Root // SyncCommitteeContribution map holds as key the selection proof for the contribution SyncCommitteeContribution ContributionsMap }
ConsensusData holds all relevant duty and data Decided on by consensus
func (*ConsensusData) Decode ¶
func (cid *ConsensusData) Decode(data []byte) error
func (*ConsensusData) Encode ¶
func (cid *ConsensusData) Encode() ([]byte, error)
type ContributionsMap ¶
type ContributionsMap map[phase0.BLSSignature]*altair.SyncCommitteeContribution
func (*ContributionsMap) MarshalJSON ¶
func (cm *ContributionsMap) MarshalJSON() ([]byte, error)
func (*ContributionsMap) UnmarshalJSON ¶
func (cm *ContributionsMap) UnmarshalJSON(input []byte) error
type DKGSigner ¶
type DKGSigner interface { SSVSigner // SignDKGOutput signs output according to the SIP https://docs.google.com/document/d/1TRVUHjFyxINWW2H9FYLNL2pQoLy6gmvaI62KL_4cREQ/edit SignDKGOutput(output Root, address common.Address) (Signature, error) // SignETHDepositRoot signs an ethereum deposit root SignETHDepositRoot(root []byte, address common.Address) (Signature, error) }
type DomainType ¶
type DomainType []byte
DomainType is a unique identifier for signatures, 2 identical pieces of data signed with different domains will result in different sigs
func GetDefaultDomain ¶ added in v0.2.2
func GetDefaultDomain() DomainType
GetDefaultDomain returns the global domain
type Duty ¶
type Duty struct { // Type is the duty type (attest, propose) Type BeaconRole // PubKey is the public key of the validator that should attest. PubKey spec.BLSPubKey // Slot is the slot in which the validator should attest. Slot spec.Slot // ValidatorIndex is the index of the validator that should attest. ValidatorIndex spec.ValidatorIndex // CommitteeIndex is the index of the committee in which the attesting validator has been placed. CommitteeIndex spec.CommitteeIndex // CommitteeLength is the length of the committee in which the attesting validator has been placed. CommitteeLength uint64 // CommitteesAtSlot is the number of committees in the slot. CommitteesAtSlot uint64 // ValidatorCommitteeIndex is the index of the validator in the list of validators in the committee. ValidatorCommitteeIndex uint64 }
Duty represent data regarding the duty type with the duty data
type EncryptionCalls ¶
type EncryptionCalls interface { // Decrypt given a rsa pubkey and a PKCS1v15 cipher text byte array, returns the decrypted data Decrypt(pk *rsa.PublicKey, cipher []byte) ([]byte, error) // Encrypt given a rsa pubkey and data returns an PKCS1v15 encrypted cipher Encrypt(pk *rsa.PublicKey, data []byte) ([]byte, error) }
EncryptionCalls captures all RSA share encryption calls
type KeyManager ¶
type KeyManager interface { BeaconSigner SSVSigner AddShare(shareKey *bls.SecretKey) error RemoveShare(pubKey string) error }
KeyManager is an interface responsible for all key manager functions
type MessageID ¶
type MessageID [52]byte
MessageID is used to identify and route messages to the right validator and Runner
func NewMsgID ¶
func NewMsgID(pk []byte, role BeaconRole) MessageID
func (MessageID) GetRoleType ¶
func (msg MessageID) GetRoleType() BeaconRole
type MessageSignature ¶
type MessageSignature interface { Root GetSignature() Signature GetSigners() []OperatorID // MatchedSigners returns true if the provided signer ids are equal to GetSignerIds() without order significance MatchedSigners(ids []OperatorID) bool // Aggregate will aggregate the signed message if possible (unique signers, same digest, valid) Aggregate(signedMsg MessageSignature) error }
MessageSignature includes all functions relevant for a signed message (QBFT message, post consensus msg, etc)
type MsgType ¶
type MsgType uint64
const ( // SSVConsensusMsgType are all QBFT consensus related messages SSVConsensusMsgType MsgType = iota // SSVDecidedMsgType are all QBFT decided messages SSVDecidedMsgType // SSVPartialSignatureMsgType are all partial signatures msgs over beacon chain specific signatures SSVPartialSignatureMsgType // DKGMsgType represent all DKG related messages DKGMsgType )
type Operator ¶
type Operator struct { OperatorID OperatorID PubKey []byte }
Operator represents an SSV operator node
func (*Operator) GetPublicKey ¶
GetPublicKey returns the public key with which the node is identified with
type OperatorID ¶
type OperatorID uint64
OperatorID is a unique ID for the node, used to create shares and verify msgs
type ProposerCalls ¶
type ProposerCalls interface { // SignRandaoReveal signs randao SignRandaoReveal(epoch spec.Epoch, pk []byte) (Signature, []byte, error) // IsBeaconBlockSlashable returns true if the given block is slashable IsBeaconBlockSlashable(block *altair.BeaconBlock) error // SignBeaconBlock signs the given beacon block SignBeaconBlock(block *altair.BeaconBlock, duty *Duty, pk []byte) (*altair.SignedBeaconBlock, []byte, error) }
type SSVMessage ¶
SSVMessage is the main message passed within the SSV network, it can contain different types of messages (QBTF, Sync, etc.)
func (*SSVMessage) Decode ¶
func (msg *SSVMessage) Decode(data []byte) error
Decode returns error if decoding failed
func (*SSVMessage) Encode ¶
func (msg *SSVMessage) Encode() ([]byte, error)
Encode returns a msg encoded bytes or error
func (*SSVMessage) GetData ¶
func (msg *SSVMessage) GetData() []byte
GetData returns message Data as byte slice
func (*SSVMessage) GetID ¶
func (msg *SSVMessage) GetID() MessageID
GetID returns a unique msg ID that is used to identify to which validator should the message be sent for processing
func (*SSVMessage) GetType ¶
func (msg *SSVMessage) GetType() MsgType
type SSVSigner ¶
type SSVSigner interface { EncryptionCalls SignRoot(data Root, sigType SignatureType, pk []byte) (Signature, error) }
SSVSigner used for all SSV specific signing
type Share ¶
type Share struct {
Share holds all info about the QBFT/ SSV Committee for msg signing and verification
func (*Share) HasPartialQuorum ¶
HasPartialQuorum returns true if at least f+1 items present (cnt is the number of items). It assumes nothing about those items, not their type or structure. https://github.com/ConsenSys/qbft-formal-spec-and-verification/blob/main/dafny/spec/L1/node_auxiliary_functions.dfy#L244
func (*Share) HasQuorum ¶
HasQuorum returns true if at least 2f+1 items are present (cnt is the number of items). It assumes nothing about those items, not their type or structure https://github.com/ConsenSys/qbft-formal-spec-and-verification/blob/main/dafny/spec/L1/node_auxiliary_functions.dfy#L259
type Signature ¶
type Signature []byte
func (Signature) ECRecover ¶
func (s Signature) ECRecover(data Root, domain DomainType, sigType SignatureType, address common.Address) error
func (Signature) Verify ¶
func (s Signature) Verify(data Root, domain DomainType, sigType SignatureType, pkByts []byte) error
func (Signature) VerifyByOperators ¶
func (s Signature) VerifyByOperators(data MessageSignature, domain DomainType, sigType SignatureType, operators []*Operator) error
VerifyByOperators verifies signature by the provided operators
func (Signature) VerifyMultiPubKey ¶
func (s Signature) VerifyMultiPubKey(data Root, domain DomainType, sigType SignatureType, pks [][]byte) error
type SignatureDomain ¶
type SignatureDomain []byte
func ComputeSignatureDomain ¶
func ComputeSignatureDomain(domain DomainType, sigType SignatureType) SignatureDomain
type SignatureType ¶
type SignatureType [4]byte
var ( QBFTSignatureType SignatureType = [4]byte{1, 0, 0, 0} PartialSignatureType SignatureType = [4]byte{2, 0, 0, 0} DKGSignatureType SignatureType = [4]byte{3, 0, 0, 0} )
func (SignatureType) Equal ¶
func (sigType SignatureType) Equal(other SignatureType) bool
type SyncCommitteeCalls ¶
type SyncCommitteeContributionCalls ¶
type SyncCommitteeContributionCalls interface { // SignContributionProof signs contribution proof SignContributionProof(slot spec.Slot, index uint64, pk []byte) (Signature, []byte, error) // SignContribution signs a SyncCommitteeContribution SignContribution(contribution *altair.ContributionAndProof, pk []byte) (*altair.SignedContributionAndProof, []byte, error) }
type ThreadSafeF ¶
type ThreadSafeF struct {
// contains filtered or unexported fields
}
ThreadSafeF makes function execution thread safe
func NewThreadSafeF ¶
func NewThreadSafeF() *ThreadSafeF
NewThreadSafeF returns a new instance of NewThreadSafeF
func (*ThreadSafeF) Run ¶
func (safeF *ThreadSafeF) Run(f func() interface{}) interface{}
Run runs the provided function
type Validate ¶
type Validate interface { // Validate returns error if msg validation doesn't pass. // Msg validation checks the msg, it's variables for validity. Validate() error }
type ValidatorPK ¶
type ValidatorPK []byte
ValidatorPK is an eth2 validator public key
func (ValidatorPK) MessageIDBelongs ¶
func (vid ValidatorPK) MessageIDBelongs(msgID MessageID) bool
MessageIDBelongs returns true if message ID belongs to validator