genesis

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MinBlockRateMs          = 100
	DefaultBlockRateMs      = 900
	MinConsensusTimeout     = 2000
	DefaultConsensusTimeout = 10000
)
View Source
const (
	RootRound uint64 = 1
	Timestamp uint64 = 1668208271000 // 11.11.2022 @ 11:11:11
)

Variables

View Source
var (
	ErrGenesisPartitionRecordIsNil = errors.New("genesis partition record is nil")
	ErrNodesAreMissing             = errors.New("nodes are missing")
	ErrTrustBaseIsNil              = errors.New("trust base is nil")
)
View Source
var (
	ErrRootValidatorsSize = errors.New("registered root nodes do not match consensus total root nodes")
	ErrGenesisRootIssNil  = errors.New("root genesis record is nil")
	ErrNoRootValidators   = errors.New("root nodes not set")
	ErrConsensusIsNil     = errors.New("consensus is nil")
)
View Source
var (
	ErrPartitionGenesisIsNil            = errors.New("partition genesis is nil")
	ErrKeysAreMissing                   = errors.New("partition keys are missing")
	ErrMissingRootValidators            = errors.New("missing root nodes")
	ErrPartitionUnicityCertificateIsNil = errors.New("partition unicity certificate is nil")
)
View Source
var (
	ErrPartitionNodeIsNil           = errors.New("partition node is nil")
	ErrNodeIdentifierIsEmpty        = errors.New("node identifier is empty")
	ErrSigningPublicKeyIsInvalid    = errors.New("signing public key is invalid")
	ErrEncryptionPublicKeyIsInvalid = errors.New("encryption public key is invalid")
)
View Source
var (
	ErrValidatorPublicInfoIsEmpty    = errors.New("public key info is empty")
	ErrPubKeyNodeIdentifierIsEmpty   = errors.New("public key info node identifier is empty")
	ErrPubKeyInfoSigningKeyIsInvalid = errors.New("public key info singing key is invalid")
	ErrPubKeyInfoEncryptionIsInvalid = errors.New("public key info encryption key is invalid")
)
View Source
var (
	ErrConsensusParamsIsNil          = errors.New("consensus record is nil")
	ErrInvalidNumberOfRootValidators = errors.New("invalid number of root nodes")
	ErrBlockRateTooSmall             = errors.New("block rate too small")
	ErrUnknownHashAlgorithm          = errors.New("unknown hash algorithm")
	ErrInvalidConsensusTimeout       = errors.New("invalid consensus timeout")
	ErrSignerIsNil                   = errors.New("signer is nil")
	ErrRootValidatorInfoMissing      = errors.New("missing root node public info")
)
View Source
var (
	ErrRootGenesisIsNil       = errors.New("root genesis is nil")
	ErrRootGenesisRecordIsNil = errors.New("root genesis record is nil")
	ErrPartitionsNotFound     = errors.New("root genesis has no partitions records")
)

Functions

func CheckPartitionPartitionIdentifiersUnique

func CheckPartitionPartitionIdentifiersUnique[T PartitionDescriptionRecordGetter](records []T) error

func NewValidatorTrustBase

func NewValidatorTrustBase(publicKeyInfo []*PublicKeyInfo) (map[string]abcrypto.Verifier, error)

NewValidatorTrustBase creates a verifier to node id map from public key info using the signing public key.

func ValidatorInfoUnique

func ValidatorInfoUnique(validators []*PublicKeyInfo) error

ValidatorInfoUnique checks for duplicates in the slice, makes sure that there are no validators that share the same id or public key. There is one exception, currently a validator can use the same key for encryption and signing.

Types

type ConsensusParams

type ConsensusParams struct {
	Version             types.ABVersion      `json:"version"`
	TotalRootValidators uint32               `json:"totalRootValidators"` // Number of root validator nodes in the root cluster
	BlockRateMs         uint32               `json:"blockRateMs"`         // Block rate
	ConsensusTimeoutMs  uint32               `json:"consensusTimeoutMs"`  // Time to abandon proposal and vote for timeout (only used in distributed implementation)
	HashAlgorithm       uint32               `json:"hashAlgorithm"`       // Hash algorithm for UnicityTree calculation
	Signatures          map[string]hex.Bytes `json:"signatures"`          // Signed hash of all fields excluding signatures
	// contains filtered or unexported fields
}

func (*ConsensusParams) GetVersion

func (x *ConsensusParams) GetVersion() types.ABVersion

func (*ConsensusParams) IsValid

func (x *ConsensusParams) IsValid() error

func (*ConsensusParams) MarshalCBOR

func (x *ConsensusParams) MarshalCBOR() ([]byte, error)

func (*ConsensusParams) SigBytes

func (x *ConsensusParams) SigBytes() ([]byte, error)

func (*ConsensusParams) Sign

func (x *ConsensusParams) Sign(id string, signer crypto.Signer) error

func (*ConsensusParams) UnmarshalCBOR

func (x *ConsensusParams) UnmarshalCBOR(data []byte) error

func (*ConsensusParams) Verify

func (x *ConsensusParams) Verify(verifiers map[string]crypto.Verifier) error

type EvmPartitionParams

type EvmPartitionParams struct {
	BlockGasLimit uint64
	GasUnitPrice  uint64
	// contains filtered or unexported fields
}

type GenesisPartitionRecord

type GenesisPartitionRecord struct {
	Version              types.ABVersion                   `json:"version"`
	Nodes                []*PartitionNode                  `json:"nodes"`
	Certificate          *types.UnicityCertificate         `json:"certificate"`
	PartitionDescription *types.PartitionDescriptionRecord `json:"partitionDescriptionRecord"`
	// contains filtered or unexported fields
}

func (*GenesisPartitionRecord) GetPartitionDescriptionRecord

func (x *GenesisPartitionRecord) GetPartitionDescriptionRecord() *types.PartitionDescriptionRecord

func (*GenesisPartitionRecord) GetVersion

func (x *GenesisPartitionRecord) GetVersion() types.ABVersion

func (*GenesisPartitionRecord) IsValid

func (x *GenesisPartitionRecord) IsValid(trustBase types.RootTrustBase, hashAlgorithm crypto.Hash) error

func (*GenesisPartitionRecord) MarshalCBOR

func (x *GenesisPartitionRecord) MarshalCBOR() ([]byte, error)

func (*GenesisPartitionRecord) UnmarshalCBOR

func (x *GenesisPartitionRecord) UnmarshalCBOR(data []byte) error

type GenesisRootRecord

type GenesisRootRecord struct {
	Version        types.ABVersion  `json:"version"`
	RootValidators []*PublicKeyInfo `json:"rootValidators"`
	Consensus      *ConsensusParams `json:"consensus"`
	// contains filtered or unexported fields
}

func (*GenesisRootRecord) FindPubKeyById

func (x *GenesisRootRecord) FindPubKeyById(id string) *PublicKeyInfo

FindPubKeyById returns matching PublicKeyInfo matching node id or nil if not found

func (*GenesisRootRecord) GetVersion

func (x *GenesisRootRecord) GetVersion() types.ABVersion

func (*GenesisRootRecord) IsValid

func (x *GenesisRootRecord) IsValid() error

IsValid only validates Consensus structure and that it signed by the listed root nodes

func (*GenesisRootRecord) MarshalCBOR

func (x *GenesisRootRecord) MarshalCBOR() ([]byte, error)

func (*GenesisRootRecord) UnmarshalCBOR

func (x *GenesisRootRecord) UnmarshalCBOR(data []byte) error

func (*GenesisRootRecord) Verify

func (x *GenesisRootRecord) Verify() error

Verify calls IsValid and makes sure that consensus total number of validators matches number of registered root validators and number of signatures in consensus structure

type MoneyPartitionParams

type MoneyPartitionParams struct {
	Partitions []*types.PartitionDescriptionRecord
	// contains filtered or unexported fields
}

type OrchestrationPartitionParams

type OrchestrationPartitionParams struct {
	OwnerPredicate types.PredicateBytes
	// contains filtered or unexported fields
}

type PartitionDescriptionRecordGetter

type PartitionDescriptionRecordGetter interface {
	GetPartitionDescriptionRecord() *types.PartitionDescriptionRecord
}

type PartitionGenesis

type PartitionGenesis struct {
	PartitionDescription *types.PartitionDescriptionRecord `json:"partitionDescriptionRecord"`
	Certificate          *types.UnicityCertificate         `json:"certificate"`
	RootValidators       []*PublicKeyInfo                  `json:"rootValidators"`
	Keys                 []*PublicKeyInfo                  `json:"keys"`
	Params               hex.Bytes                         `json:"params,omitempty"`
	// contains filtered or unexported fields
}

func (*PartitionGenesis) FindRootPubKeyInfoById

func (x *PartitionGenesis) FindRootPubKeyInfoById(id string) *PublicKeyInfo

func (*PartitionGenesis) GenerateRootTrustBase

func (x *PartitionGenesis) GenerateRootTrustBase() (types.RootTrustBase, error)

GenerateRootTrustBase generates trust base from partition genesis.

func (*PartitionGenesis) IsValid

func (x *PartitionGenesis) IsValid(trustBase types.RootTrustBase, hashAlgorithm gocrypto.Hash) error

type PartitionNode

type PartitionNode struct {
	Version                    types.ABVersion                          `json:"version"`
	NodeIdentifier             string                                   `json:"nodeIdentifier"`
	SigningPublicKey           hex.Bytes                                `json:"signingPublicKey"`
	EncryptionPublicKey        hex.Bytes                                `json:"encryptionPublicKey"`
	BlockCertificationRequest  *certification.BlockCertificationRequest `json:"blockCertificationRequest"`
	PartitionDescriptionRecord types.PartitionDescriptionRecord         `json:"partitionDescriptionRecord"`
	Params                     hex.Bytes                                `json:"params,omitempty"`
	// contains filtered or unexported fields
}

func (*PartitionNode) GetVersion

func (x *PartitionNode) GetVersion() types.ABVersion

func (*PartitionNode) IsValid

func (x *PartitionNode) IsValid() error

func (*PartitionNode) MarshalCBOR

func (x *PartitionNode) MarshalCBOR() ([]byte, error)

func (*PartitionNode) UnmarshalCBOR

func (x *PartitionNode) UnmarshalCBOR(data []byte) error

type PartitionRecord

type PartitionRecord struct {
	PartitionDescription *types.PartitionDescriptionRecord `json:"partitionDescriptionRecord"`
	Validators           []*PartitionNode                  `json:"validators"`
	// contains filtered or unexported fields
}

func (*PartitionRecord) GetPartitionDescriptionRecord

func (x *PartitionRecord) GetPartitionDescriptionRecord() *types.PartitionDescriptionRecord

func (*PartitionRecord) GetPartitionIdentifier

func (x *PartitionRecord) GetPartitionIdentifier() types.PartitionID

func (*PartitionRecord) GetPartitionNode

func (x *PartitionRecord) GetPartitionNode(id string) *PartitionNode

func (*PartitionRecord) IsValid

func (x *PartitionRecord) IsValid() error

type PublicKeyInfo

type PublicKeyInfo struct {
	NodeIdentifier      string    `json:"nodeIdentifier"`
	SigningPublicKey    hex.Bytes `json:"signingPublicKey"`
	EncryptionPublicKey hex.Bytes `json:"encryptionPublicKey"`
	// contains filtered or unexported fields
}

func (*PublicKeyInfo) IsValid

func (x *PublicKeyInfo) IsValid() error

IsValid validates that all fields are correctly set and public keys are correct.

func (*PublicKeyInfo) NodeID

func (x *PublicKeyInfo) NodeID() (peer.ID, error)

NodeID - returns node identifier as peer.ID from encryption public key The NodeIdentifier (string) could also be used with Decode(), but there are a lot of unit tests that init the field as "test" or to some other invalid id

type RootGenesis

type RootGenesis struct {
	Version    types.ABVersion           `json:"version"`
	Root       *GenesisRootRecord        `json:"root"`
	Partitions []*GenesisPartitionRecord `json:"partitions"`
	// contains filtered or unexported fields
}

func (*RootGenesis) GenerateTrustBase

func (x *RootGenesis) GenerateTrustBase(opts ...types.Option) (*types.RootTrustBaseV1, error)

GenerateTrustBase generates root trust base. The final trust base must be generated from the combined root genesis file.

func (*RootGenesis) GetPartitionGenesis

func (x *RootGenesis) GetPartitionGenesis(partitionID types.PartitionID) (*GenesisPartitionRecord, error)

func (*RootGenesis) GetPartitionRecords

func (x *RootGenesis) GetPartitionRecords() []*PartitionRecord

func (*RootGenesis) GetRoundHash

func (x *RootGenesis) GetRoundHash() []byte

func (*RootGenesis) GetRoundNumber

func (x *RootGenesis) GetRoundNumber() uint64

func (*RootGenesis) GetVersion

func (x *RootGenesis) GetVersion() types.ABVersion

func (*RootGenesis) IsValid

func (x *RootGenesis) IsValid() error

IsValid verifies that the genesis file is signed by the generator and that the public key is included

func (*RootGenesis) MarshalCBOR

func (x *RootGenesis) MarshalCBOR() ([]byte, error)

func (*RootGenesis) NodeIDs

func (x *RootGenesis) NodeIDs() ([]peer.ID, error)

NodeIDs returns IDs of all root validator nodes.

func (*RootGenesis) UnmarshalCBOR

func (x *RootGenesis) UnmarshalCBOR(data []byte) error

func (*RootGenesis) Verify

func (x *RootGenesis) Verify() error

Verify basically same as IsValid, but verifies that the consensus structure and UC Seals are signed by all root validators

type TokensPartitionParams

type TokensPartitionParams struct {
	AdminOwnerPredicate []byte
	FeelessMode         bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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