Documentation ¶
Index ¶
- Variables
- func UseIstanbulHeaderHashInTest(t *testing.T, signer Signer)
- type AggregatedSeal
- type BLSKeyManager
- func (s *BLSKeyManager) Address() types.Address
- func (s *BLSKeyManager) Ecrecover(sig, digest []byte) (types.Address, error)
- func (s *BLSKeyManager) GenerateCommittedSeals(sealMap map[types.Address][]byte, set validators.Validators) (Seals, error)
- func (s *BLSKeyManager) NewEmptyCommittedSeals() Seals
- func (s *BLSKeyManager) NewEmptyValidators() validators.Validators
- func (s *BLSKeyManager) SignCommittedSeal(data []byte) ([]byte, error)
- func (s *BLSKeyManager) SignIBFTMessage(msg []byte) ([]byte, error)
- func (s *BLSKeyManager) SignProposerSeal(data []byte) ([]byte, error)
- func (s *BLSKeyManager) Type() validators.ValidatorType
- func (s *BLSKeyManager) VerifyCommittedSeal(set validators.Validators, addr types.Address, rawSignature []byte, ...) error
- func (s *BLSKeyManager) VerifyCommittedSeals(rawCommittedSeal Seals, message []byte, vals validators.Validators) (int, error)
- type ECDSAKeyManager
- func (s *ECDSAKeyManager) Address() types.Address
- func (s *ECDSAKeyManager) Ecrecover(sig, digest []byte) (types.Address, error)
- func (s *ECDSAKeyManager) GenerateCommittedSeals(sealMap map[types.Address][]byte, _ validators.Validators) (Seals, error)
- func (s *ECDSAKeyManager) NewEmptyCommittedSeals() Seals
- func (s *ECDSAKeyManager) NewEmptyValidators() validators.Validators
- func (s *ECDSAKeyManager) SignCommittedSeal(message []byte) ([]byte, error)
- func (s *ECDSAKeyManager) SignIBFTMessage(msg []byte) ([]byte, error)
- func (s *ECDSAKeyManager) SignProposerSeal(message []byte) ([]byte, error)
- func (s *ECDSAKeyManager) Type() validators.ValidatorType
- func (s *ECDSAKeyManager) VerifyCommittedSeal(vals validators.Validators, address types.Address, signature []byte, ...) error
- func (s *ECDSAKeyManager) VerifyCommittedSeals(rawCommittedSeal Seals, digest []byte, vals validators.Validators) (int, error)
- type IstanbulExtra
- type KeyManager
- func NewBLSKeyManager(manager secrets.SecretsManager) (KeyManager, error)
- func NewBLSKeyManagerFromKeys(ecdsaKey *ecdsa.PrivateKey, blsKey *bls_sig.SecretKey) KeyManager
- func NewECDSAKeyManager(manager secrets.SecretsManager) (KeyManager, error)
- func NewECDSAKeyManagerFromKey(key *ecdsa.PrivateKey) KeyManager
- func NewKeyManagerFromType(secretManager secrets.SecretsManager, validatorType validators.ValidatorType) (KeyManager, error)
- type Seals
- type SerializedSeal
- type Signer
- type SignerImpl
- func (s *SignerImpl) Address() types.Address
- func (s *SignerImpl) CalculateHeaderHash(header *types.Header) (types.Hash, error)
- func (s *SignerImpl) CreateCommittedSeal(hash []byte) ([]byte, error)
- func (s *SignerImpl) EcrecoverFromHeader(header *types.Header) (types.Address, error)
- func (s *SignerImpl) EcrecoverFromIBFTMessage(signature, digest []byte) (types.Address, error)
- func (s *SignerImpl) FilterHeaderForHash(header *types.Header) (*types.Header, error)
- func (s *SignerImpl) GetIBFTExtra(header *types.Header) (*IstanbulExtra, error)
- func (s *SignerImpl) GetParentCommittedSeals(header *types.Header) (Seals, error)
- func (s *SignerImpl) GetValidators(header *types.Header) (validators.Validators, error)
- func (s *SignerImpl) InitIBFTExtra(header *types.Header, validators validators.Validators, ...)
- func (s *SignerImpl) SignIBFTMessage(msg []byte) ([]byte, error)
- func (s *SignerImpl) Type() validators.ValidatorType
- func (s *SignerImpl) VerifyCommittedSeal(validators validators.Validators, signer types.Address, signature, hash []byte) error
- func (s *SignerImpl) VerifyCommittedSeals(hash types.Hash, committedSeals Seals, validators validators.Validators, ...) error
- func (s *SignerImpl) VerifyParentCommittedSeals(parentHash types.Hash, header *types.Header, ...) error
- func (s *SignerImpl) WriteCommittedSeals(header *types.Header, roundNumber uint64, sealMap map[types.Address][]byte) (*types.Header, error)
- func (s *SignerImpl) WriteProposerSeal(header *types.Header) (*types.Header, error)
Constants ¶
This section is empty.
Variables ¶
var ( // IstanbulDigest represents a hash of "Istanbul practical byzantine fault tolerance" // to identify whether the block is from Istanbul consensus engine IstanbulDigest = types.StringToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365") // IstanbulExtraVanity represents a fixed number of extra-data bytes reserved for proposer vanity IstanbulExtraVanity = 32 // IstanbulExtraSeal represents the fixed number of extra-data bytes reserved for proposer seal IstanbulExtraSeal = 65 )
var ( ErrEmptyCommittedSeals = errors.New("empty committed seals") ErrEmptyParentCommittedSeals = errors.New("empty parent committed seals") ErrInvalidCommittedSealLength = errors.New("invalid committed seal length") ErrInvalidCommittedSealType = errors.New("invalid committed seal type") ErrRepeatedCommittedSeal = errors.New("repeated seal in committed seals") ErrNonValidatorCommittedSeal = errors.New("found committed seal signed by non validator") ErrNotEnoughCommittedSeals = errors.New("not enough seals to seal block") ErrSignerMismatch = errors.New("mismatch address between signer and message sender") ErrValidatorNotFound = errors.New("validator not found in validator set") ErrInvalidValidators = errors.New("invalid validators type") ErrInvalidValidator = errors.New("invalid validator type") ErrInvalidSignature = errors.New("invalid signature") )
Functions ¶
func UseIstanbulHeaderHashInTest ¶
UseIstanbulHeaderHashInTest is a helper function for the test
Types ¶
type AggregatedSeal ¶
func (*AggregatedSeal) MarshalRLPWith ¶
func (s *AggregatedSeal) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
func (*AggregatedSeal) Num ¶
func (s *AggregatedSeal) Num() int
func (*AggregatedSeal) UnmarshalRLPFrom ¶
type BLSKeyManager ¶
type BLSKeyManager struct {
// contains filtered or unexported fields
}
BLSKeyManager is a module that holds ECDSA and BLS keys and implements methods of signing by these keys
func (*BLSKeyManager) Address ¶
func (s *BLSKeyManager) Address() types.Address
Address returns the address of KeyManager
func (*BLSKeyManager) Ecrecover ¶
func (s *BLSKeyManager) Ecrecover(sig, digest []byte) (types.Address, error)
func (*BLSKeyManager) GenerateCommittedSeals ¶
func (s *BLSKeyManager) GenerateCommittedSeals( sealMap map[types.Address][]byte, set validators.Validators, ) (Seals, error)
func (*BLSKeyManager) NewEmptyCommittedSeals ¶
func (s *BLSKeyManager) NewEmptyCommittedSeals() Seals
NewEmptyCommittedSeals returns empty CommittedSeals BLSKeyManager uses
func (*BLSKeyManager) NewEmptyValidators ¶
func (s *BLSKeyManager) NewEmptyValidators() validators.Validators
NewEmptyValidators returns empty validator collection BLSKeyManager uses
func (*BLSKeyManager) SignCommittedSeal ¶
func (s *BLSKeyManager) SignCommittedSeal(data []byte) ([]byte, error)
func (*BLSKeyManager) SignIBFTMessage ¶
func (s *BLSKeyManager) SignIBFTMessage(msg []byte) ([]byte, error)
func (*BLSKeyManager) SignProposerSeal ¶
func (s *BLSKeyManager) SignProposerSeal(data []byte) ([]byte, error)
func (*BLSKeyManager) Type ¶
func (s *BLSKeyManager) Type() validators.ValidatorType
Type returns the validator type KeyManager supports
func (*BLSKeyManager) VerifyCommittedSeal ¶
func (s *BLSKeyManager) VerifyCommittedSeal( set validators.Validators, addr types.Address, rawSignature []byte, hash []byte, ) error
func (*BLSKeyManager) VerifyCommittedSeals ¶
func (s *BLSKeyManager) VerifyCommittedSeals( rawCommittedSeal Seals, message []byte, vals validators.Validators, ) (int, error)
type ECDSAKeyManager ¶
type ECDSAKeyManager struct {
// contains filtered or unexported fields
}
ECDSAKeyManager is a module that holds ECDSA key and implements methods of signing by this key
func (*ECDSAKeyManager) Address ¶
func (s *ECDSAKeyManager) Address() types.Address
Address returns the address of KeyManager
func (*ECDSAKeyManager) Ecrecover ¶
func (s *ECDSAKeyManager) Ecrecover(sig, digest []byte) (types.Address, error)
func (*ECDSAKeyManager) GenerateCommittedSeals ¶
func (s *ECDSAKeyManager) GenerateCommittedSeals( sealMap map[types.Address][]byte, _ validators.Validators, ) (Seals, error)
func (*ECDSAKeyManager) NewEmptyCommittedSeals ¶
func (s *ECDSAKeyManager) NewEmptyCommittedSeals() Seals
NewEmptyCommittedSeals returns empty CommittedSeals ECDSAKeyManager uses
func (*ECDSAKeyManager) NewEmptyValidators ¶
func (s *ECDSAKeyManager) NewEmptyValidators() validators.Validators
NewEmptyValidators returns empty validator collection ECDSAKeyManager uses
func (*ECDSAKeyManager) SignCommittedSeal ¶
func (s *ECDSAKeyManager) SignCommittedSeal(message []byte) ([]byte, error)
SignProposerSeal signs the given message by ECDSA key the ECDSAKeyManager holds for committed seal
func (*ECDSAKeyManager) SignIBFTMessage ¶
func (s *ECDSAKeyManager) SignIBFTMessage(msg []byte) ([]byte, error)
func (*ECDSAKeyManager) SignProposerSeal ¶
func (s *ECDSAKeyManager) SignProposerSeal(message []byte) ([]byte, error)
SignProposerSeal signs the given message by ECDSA key the ECDSAKeyManager holds for ProposerSeal
func (*ECDSAKeyManager) Type ¶
func (s *ECDSAKeyManager) Type() validators.ValidatorType
Type returns the validator type KeyManager supports
func (*ECDSAKeyManager) VerifyCommittedSeal ¶
func (s *ECDSAKeyManager) VerifyCommittedSeal( vals validators.Validators, address types.Address, signature []byte, message []byte, ) error
VerifyCommittedSeal verifies a committed seal
func (*ECDSAKeyManager) VerifyCommittedSeals ¶
func (s *ECDSAKeyManager) VerifyCommittedSeals( rawCommittedSeal Seals, digest []byte, vals validators.Validators, ) (int, error)
type IstanbulExtra ¶
type IstanbulExtra struct { Validators validators.Validators ProposerSeal []byte CommittedSeals Seals ParentCommittedSeals Seals RoundNumber *uint64 }
IstanbulExtra defines the structure of the extra field for Istanbul
func (*IstanbulExtra) MarshalRLPTo ¶
func (i *IstanbulExtra) MarshalRLPTo(dst []byte) []byte
MarshalRLPTo defines the marshal function wrapper for IstanbulExtra
func (*IstanbulExtra) MarshalRLPWith ¶
func (i *IstanbulExtra) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith defines the marshal function implementation for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLP ¶
func (i *IstanbulExtra) UnmarshalRLP(input []byte) error
UnmarshalRLP defines the unmarshal function wrapper for IstanbulExtra
func (*IstanbulExtra) UnmarshalRLPFrom ¶
UnmarshalRLPFrom defines the unmarshal implementation for IstanbulExtra
type KeyManager ¶
type KeyManager interface { // Type returns Validator type signer supports Type() validators.ValidatorType // Address returns an address of signer Address() types.Address // NewEmptyValidators creates empty validator collection the Signer expects NewEmptyValidators() validators.Validators // NewEmptyCommittedSeals creates empty committed seals the Signer expects NewEmptyCommittedSeals() Seals // SignProposerSeal creates a signature for ProposerSeal SignProposerSeal(hash []byte) ([]byte, error) // SignCommittedSeal creates a signature for committed seal SignCommittedSeal(hash []byte) ([]byte, error) // VerifyCommittedSeal verifies a committed seal VerifyCommittedSeal(vals validators.Validators, signer types.Address, sig, hash []byte) error // GenerateCommittedSeals creates CommittedSeals from committed seals GenerateCommittedSeals(sealsByValidator map[types.Address][]byte, vals validators.Validators) (Seals, error) // VerifyCommittedSeals verifies CommittedSeals VerifyCommittedSeals(seals Seals, hash []byte, vals validators.Validators) (int, error) // SignIBFTMessage signs for arbitrary bytes message SignIBFTMessage(msg []byte) ([]byte, error) // Ecrecover recovers address from signature and message Ecrecover(sig []byte, msg []byte) (types.Address, error) }
KeyManager is a delegated module that signs data
func NewBLSKeyManager ¶
func NewBLSKeyManager(manager secrets.SecretsManager) (KeyManager, error)
NewBLSKeyManager initializes BLSKeyManager by the ECDSA key and BLS key which are loaded from SecretsManager
func NewBLSKeyManagerFromKeys ¶
func NewBLSKeyManagerFromKeys(ecdsaKey *ecdsa.PrivateKey, blsKey *bls_sig.SecretKey) KeyManager
NewBLSKeyManagerFromKeys initializes BLSKeyManager from the given ECDSA and BLS keys
func NewECDSAKeyManager ¶
func NewECDSAKeyManager(manager secrets.SecretsManager) (KeyManager, error)
NewECDSAKeyManager initializes ECDSAKeyManager by the ECDSA key loaded from SecretsManager
func NewECDSAKeyManagerFromKey ¶
func NewECDSAKeyManagerFromKey(key *ecdsa.PrivateKey) KeyManager
NewECDSAKeyManagerFromKey initializes ECDSAKeyManager from the given ECDSA key
func NewKeyManagerFromType ¶
func NewKeyManagerFromType( secretManager secrets.SecretsManager, validatorType validators.ValidatorType, ) (KeyManager, error)
NewKeyManagerFromType creates KeyManager based on the given type
type SerializedSeal ¶
type SerializedSeal [][]byte
func (*SerializedSeal) MarshalRLPWith ¶
func (s *SerializedSeal) MarshalRLPWith(ar *fastrlp.Arena) *fastrlp.Value
func (*SerializedSeal) Num ¶
func (s *SerializedSeal) Num() int
func (*SerializedSeal) UnmarshalRLPFrom ¶
type Signer ¶
type Signer interface { Type() validators.ValidatorType Address() types.Address // IBFT Extra InitIBFTExtra(*types.Header, validators.Validators, Seals) GetIBFTExtra(*types.Header) (*IstanbulExtra, error) GetValidators(*types.Header) (validators.Validators, error) // ProposerSeal WriteProposerSeal(*types.Header) (*types.Header, error) EcrecoverFromHeader(*types.Header) (types.Address, error) // CommittedSeal CreateCommittedSeal([]byte) ([]byte, error) VerifyCommittedSeal(validators.Validators, types.Address, []byte, []byte) error // CommittedSeals WriteCommittedSeals( header *types.Header, roundNumber uint64, sealMap map[types.Address][]byte, ) (*types.Header, error) VerifyCommittedSeals( hash types.Hash, committedSeals Seals, validators validators.Validators, quorumSize int, ) error // ParentCommittedSeals VerifyParentCommittedSeals( parentHash types.Hash, header *types.Header, parentValidators validators.Validators, quorum int, mustExist bool, ) error // IBFTMessage SignIBFTMessage([]byte) ([]byte, error) EcrecoverFromIBFTMessage([]byte, []byte) (types.Address, error) // Hash of Header CalculateHeaderHash(*types.Header) (types.Hash, error) FilterHeaderForHash(*types.Header) (*types.Header, error) }
Signer is responsible for signing for blocks and messages in IBFT
type SignerImpl ¶
type SignerImpl struct {
// contains filtered or unexported fields
}
SignerImpl is an implementation that meets Signer
func NewSigner ¶
func NewSigner( keyManager KeyManager, parentKeyManager KeyManager, ) *SignerImpl
NewSigner is a constructor of SignerImpl
func (*SignerImpl) Address ¶
func (s *SignerImpl) Address() types.Address
Address returns the signer's address
func (*SignerImpl) CalculateHeaderHash ¶
CalculateHeaderHash calculates header hash for IBFT Extra
func (*SignerImpl) CreateCommittedSeal ¶
func (s *SignerImpl) CreateCommittedSeal(hash []byte) ([]byte, error)
CreateCommittedSeal returns CommittedSeal from given hash
func (*SignerImpl) EcrecoverFromHeader ¶
EcrecoverFromIBFTMessage recovers signer address from given signature and header hash
func (*SignerImpl) EcrecoverFromIBFTMessage ¶
func (s *SignerImpl) EcrecoverFromIBFTMessage(signature, digest []byte) (types.Address, error)
EcrecoverFromIBFTMessage recovers signer address from given signature and digest
func (*SignerImpl) FilterHeaderForHash ¶ added in v0.8.0
filterHeaderForHash removes unnecessary fields from IBFT Extra of the header for hash calculation
func (*SignerImpl) GetIBFTExtra ¶
func (s *SignerImpl) GetIBFTExtra(header *types.Header) (*IstanbulExtra, error)
GetIBFTExtra extracts IBFT Extra from the given header
func (*SignerImpl) GetParentCommittedSeals ¶
func (s *SignerImpl) GetParentCommittedSeals(header *types.Header) (Seals, error)
GetParentCommittedSeals extracts Parent Committed Seals from IBFT Extra in Header
func (*SignerImpl) GetValidators ¶
func (s *SignerImpl) GetValidators(header *types.Header) (validators.Validators, error)
func (*SignerImpl) InitIBFTExtra ¶
func (s *SignerImpl) InitIBFTExtra( header *types.Header, validators validators.Validators, parentCommittedSeals Seals, )
InitIBFTExtra initializes the extra field in the given header based on given validators and parent committed seals
func (*SignerImpl) SignIBFTMessage ¶
func (s *SignerImpl) SignIBFTMessage(msg []byte) ([]byte, error)
SignIBFTMessage signs arbitrary message
func (*SignerImpl) Type ¶
func (s *SignerImpl) Type() validators.ValidatorType
Type returns that validator type the signer expects
func (*SignerImpl) VerifyCommittedSeal ¶
func (s *SignerImpl) VerifyCommittedSeal( validators validators.Validators, signer types.Address, signature, hash []byte, ) error
CreateCommittedSeal verifies a CommittedSeal
func (*SignerImpl) VerifyCommittedSeals ¶
func (s *SignerImpl) VerifyCommittedSeals( hash types.Hash, committedSeals Seals, validators validators.Validators, quorumSize int, ) error
VerifyCommittedSeals verifies CommittedSeals in IBFT Extra of the header
func (*SignerImpl) VerifyParentCommittedSeals ¶
func (s *SignerImpl) VerifyParentCommittedSeals( parentHash types.Hash, header *types.Header, parentValidators validators.Validators, quorum int, mustExist bool, ) error
VerifyParentCommittedSeals verifies ParentCommittedSeals in IBFT Extra of the header
func (*SignerImpl) WriteCommittedSeals ¶
func (s *SignerImpl) WriteCommittedSeals( header *types.Header, roundNumber uint64, sealMap map[types.Address][]byte, ) (*types.Header, error)
WriteCommittedSeals builds and writes CommittedSeals into IBFT Extra of the header
func (*SignerImpl) WriteProposerSeal ¶
WriteProposerSeal signs and set ProposerSeal into IBFT Extra of the header