Documentation ¶
Index ¶
- Constants
- Variables
- func AssertEqualIR(a, b *InputRecord) error
- func BlockHash(algorithm crypto.Hash, h *Header, txs []*TransactionRecord, stateHash []byte, ...) ([]byte, error)
- func CheckNonEquivocatingCertificates(prevUC, newUC *UnicityCertificate) error
- func EnsureVersion(data Versioned, actual, expected ABVersion) error
- func EqualIR(a, b *InputRecord) (bool, error)
- func ErrInvalidVersion(s Versioned) error
- func HashCBOR(data any, hashAlgorithm crypto.Hash) ([]byte, error)
- func NewTimestamp() uint64
- func VerifyTxProof(txRecordProof *TxRecordProof, tb RootTrustBase, hashAlgorithm crypto.Hash) error
- func VerifyUnitStateProof(u *UnitStateProof, algorithm crypto.Hash, unitData *StateUnitData, ...) error
- type ABTag
- type ABVersion
- type AuthProofSigData
- type Block
- func (b *Block) CalculateBlockHash(algorithm crypto.Hash) (*InputRecord, error)
- func (b *Block) GetBlockFees() (uint64, error)
- func (b *Block) GetProposerID() string
- func (b *Block) GetRoundNumber() (uint64, error)
- func (b *Block) HeaderHash(algorithm crypto.Hash) ([]byte, error)
- func (b *Block) InputRecord() (*InputRecord, error)
- func (b *Block) IsValid(algorithm crypto.Hash, systemDescriptionHash []byte) error
- func (b *Block) PartitionID() PartitionID
- func (b *Block) Size() (bs uint64, _ error)
- type ClientMetadata
- type FeeCreditBill
- type FeeProofSigData
- type GenericChainItem
- type Header
- type InputRecord
- func (x *InputRecord) AddToHasher(hasher abhash.Hasher)
- func (x *InputRecord) Bytes() ([]byte, error)
- func (x *InputRecord) GetVersion() ABVersion
- func (x *InputRecord) IsValid() error
- func (x *InputRecord) MarshalCBOR() ([]byte, error)
- func (x *InputRecord) NewRepeatIR() *InputRecord
- func (x *InputRecord) String() string
- func (x *InputRecord) UnmarshalCBOR(data []byte) error
- type NetworkID
- type NodeInfo
- type Option
- type PartitionDescriptionRecord
- func (pdr *PartitionDescriptionRecord) GetNetworkIdentifier() NetworkID
- func (pdr *PartitionDescriptionRecord) GetPartitionIdentifier() PartitionID
- func (pdr *PartitionDescriptionRecord) GetVersion() ABVersion
- func (pdr *PartitionDescriptionRecord) Hash(hashAlgorithm crypto.Hash) ([]byte, error)
- func (pdr *PartitionDescriptionRecord) IsValid() error
- func (pdr *PartitionDescriptionRecord) IsValidShard(id ShardID) error
- func (pdr *PartitionDescriptionRecord) MarshalCBOR() ([]byte, error)
- func (pdr *PartitionDescriptionRecord) UnitIdValidator(sid ShardID) func(unitID UnitID) error
- func (pdr *PartitionDescriptionRecord) UnmarshalCBOR(data []byte) error
- type PartitionID
- type Payload
- type PredicateBytes
- type RawCBOR
- type RootTrustBase
- type RootTrustBaseV1
- func (r *RootTrustBaseV1) GetMaxFaultyNodes() uint64
- func (r *RootTrustBaseV1) GetQuorumThreshold() uint64
- func (r *RootTrustBaseV1) GetVerifiers() (map[string]abcrypto.Verifier, error)
- func (r *RootTrustBaseV1) GetVersion() ABVersion
- func (r *RootTrustBaseV1) Hash(hashAlgo crypto.Hash) ([]byte, error)
- func (r *RootTrustBaseV1) MarshalCBOR() ([]byte, error)
- func (r RootTrustBaseV1) SigBytes() ([]byte, error)
- func (r *RootTrustBaseV1) Sign(nodeID string, signer abcrypto.Signer) error
- func (r *RootTrustBaseV1) UnmarshalCBOR(data []byte) error
- func (r *RootTrustBaseV1) VerifyQuorumSignatures(data []byte, signatures map[string]hex.Bytes) (error, []error)
- func (r *RootTrustBaseV1) VerifySignature(data []byte, sig []byte, nodeID string) (uint64, error)
- type ServerMetadata
- type ShardID
- func (id ShardID) AddToHasher(h abhash.Hasher)
- func (id ShardID) Bytes() []byte
- func (id ShardID) Comparator() func([]byte) bool
- func (id ShardID) Equal(v ShardID) bool
- func (id ShardID) Key() string
- func (id ShardID) Length() uint
- func (id ShardID) MarshalCBOR() ([]byte, error)
- func (id ShardID) MarshalText() ([]byte, error)
- func (id ShardID) Split() (ShardID, ShardID)
- func (id ShardID) String() (s string)
- func (id *ShardID) UnmarshalCBOR(data []byte) (err error)
- func (id *ShardID) UnmarshalText(src []byte) error
- type ShardTree
- type ShardTreeCertificate
- type ShardTreeInput
- type ShardingScheme
- type SignatureMap
- type StateLock
- type StateLockProofSigData
- type StateTreeCert
- type StateTreePathItem
- type StateUnitData
- type SystemTypeDescriptor
- type TaggedCBOR
- type TransactionOrder
- func (t *TransactionOrder) AuthProofSigBytes() ([]byte, error)
- func (t *TransactionOrder) FeeCreditRecordID() []byte
- func (t *TransactionOrder) FeeProofSigBytes() ([]byte, error)
- func (t *TransactionOrder) GetNetworkID() NetworkID
- func (t *TransactionOrder) GetPartitionID() PartitionID
- func (t *TransactionOrder) GetUnitID() UnitID
- func (t *TransactionOrder) GetVersion() ABVersion
- func (t *TransactionOrder) HasStateLock() bool
- func (t *TransactionOrder) Hash(algorithm crypto.Hash) ([]byte, error)
- func (t *TransactionOrder) MarshalCBOR() ([]byte, error)
- func (t *TransactionOrder) MaxFee() uint64
- func (t *TransactionOrder) ReferenceNumber() []byte
- func (t *TransactionOrder) SetAttributes(attr any) error
- func (t *TransactionOrder) SetAuthProof(authProof any) error
- func (t *TransactionOrder) StateLockProofSigBytes() ([]byte, error)
- func (t *TransactionOrder) Timeout() uint64
- func (t *TransactionOrder) UnmarshalAttributes(v any) error
- func (t *TransactionOrder) UnmarshalAuthProof(v any) error
- func (t *TransactionOrder) UnmarshalCBOR(data []byte) error
- type TransactionOrderCBOR
- type TransactionRecord
- func (t *TransactionRecord) Bytes() ([]byte, error)
- func (t *TransactionRecord) GetActualFee() uint64
- func (t *TransactionRecord) GetTransactionOrderV1() (*TransactionOrder, error)
- func (t *TransactionRecord) GetVersion() ABVersion
- func (t *TransactionRecord) Hash(algorithm crypto.Hash) ([]byte, error)
- func (t *TransactionRecord) IsSuccessful() bool
- func (t *TransactionRecord) IsValid() error
- func (t *TransactionRecord) MarshalCBOR() ([]byte, error)
- func (t *TransactionRecord) TargetUnits() []UnitID
- func (t *TransactionRecord) TxStatus() TxStatus
- func (t *TransactionRecord) UnmarshalCBOR(data []byte) error
- func (t *TransactionRecord) UnmarshalProcessingDetails(v any) error
- type TxProof
- type TxRecordProof
- type TxStatus
- type UnicityCertificate
- func (x *UnicityCertificate) GetFeeSum() uint64
- func (x *UnicityCertificate) GetPreviousStateHash() []byte
- func (x *UnicityCertificate) GetRootRoundNumber() uint64
- func (x *UnicityCertificate) GetRoundNumber() uint64
- func (x *UnicityCertificate) GetStateHash() []byte
- func (x *UnicityCertificate) GetSummaryValue() []byte
- func (x *UnicityCertificate) GetVersion() ABVersion
- func (x *UnicityCertificate) Hash(hash crypto.Hash) ([]byte, error)
- func (x *UnicityCertificate) IsDuplicate(prevUC *UnicityCertificate) bool
- func (x *UnicityCertificate) IsRepeat(prevUC *UnicityCertificate) (bool, error)
- func (x *UnicityCertificate) IsSuccessor(prevUC *UnicityCertificate) bool
- func (x *UnicityCertificate) IsValid(algorithm crypto.Hash, partitionID PartitionID, systemDescriptionHash []byte) error
- func (x *UnicityCertificate) MarshalCBOR() ([]byte, error)
- func (x *UnicityCertificate) UnmarshalCBOR(data []byte) error
- func (x *UnicityCertificate) Verify(tb RootTrustBase, algorithm crypto.Hash, partitionID PartitionID, ...) error
- type UnicityCertificateValidator
- type UnicitySeal
- func (x *UnicitySeal) AddToHasher(hasher abhash.Hasher)
- func (x *UnicitySeal) GetVersion() ABVersion
- func (x *UnicitySeal) IsValid() error
- func (x *UnicitySeal) MarshalCBOR() ([]byte, error)
- func (x UnicitySeal) SigBytes() ([]byte, error)
- func (x *UnicitySeal) Sign(id string, signer crypto.Signer) error
- func (x *UnicitySeal) UnmarshalCBOR(b []byte) error
- func (x *UnicitySeal) Verify(tb RootTrustBase) error
- type UnicityTree
- type UnicityTreeCertificate
- func (utc *UnicityTreeCertificate) AddToHasher(hasher abhash.Hasher)
- func (utc *UnicityTreeCertificate) EvalAuthPath(shardTreeRoot []byte, hashAlgorithm crypto.Hash) ([]byte, error)
- func (utc *UnicityTreeCertificate) GetVersion() ABVersion
- func (utc *UnicityTreeCertificate) IsValid(partition PartitionID, systemDescriptionHash []byte) error
- func (utc *UnicityTreeCertificate) MarshalCBOR() ([]byte, error)
- func (utc *UnicityTreeCertificate) UnmarshalCBOR(data []byte) error
- type UnicityTreeData
- type UnitData
- type UnitDataAndProof
- type UnitID
- type UnitStateProof
- type UnitTreeCert
- type Versioned
Constants ¶
const ( PartitionIdentifierLength = 4 NetworkIdentifierLength = 2 )
const ( UnicitySealTag RootGenesisTag GenesisRootRecordTag ConsensusParamsTag GenesisPartitionRecordTag PartitionNodeTag UnicityCertificateTag InputRecordTag TxProofTag UnitStateProofTag PartitionDescriptionRecordTag BlockTag RootTrustBaseTag UnicityTreeCertificateTag TransactionRecordTag TransactionOrderTag RootPartitionBlockDataTag RootPartitionRoundInfoTag )
const GenesisTime uint64 = 1681971084
GenesisTime min timestamp Thursday, April 20, 2023 6:11:24 AM GMT+00:00 Epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT)
Variables ¶
var ( ErrInputRecordIsNil = errors.New("input record is nil") ErrHashIsNil = errors.New("hash is nil") ErrBlockHashIsNil = errors.New("block hash is nil") ErrPreviousHashIsNil = errors.New("previous hash is nil") ErrSummaryValueIsNil = errors.New("summary value is nil") ErrInvalidPartitionRound = errors.New("partition round is 0") )
var ( ErrTransactionRecordIsNil = errors.New("transaction record is nil") ErrTransactionOrderIsNil = errors.New("transaction order is nil") ErrServerMetadataIsNil = errors.New("server metadata is nil") )
var ( ErrTxRecordProofIsNil = errors.New("transaction record proof is nil") ErrOutOfGas = errors.New("out of gas") )
var ( ErrUnicitySealIsNil = errors.New("unicity seal is nil") ErrSignerIsNil = errors.New("signer is nil") ErrUnicitySealHashIsNil = errors.New("hash is nil") ErrInvalidRootRound = errors.New("invalid root round number") ErrUnicitySealSignatureIsNil = errors.New("no signatures") ErrRootValidatorInfoMissing = errors.New("root node info is missing") ErrInvalidTimestamp = errors.New("invalid timestamp") )
var ( ErrUnicityTreeCertificateIsNil = errors.New("unicity tree certificate is nil") ErrUCIsNil = errors.New("new UC is nil") ErrLastUCIsNil = errors.New("last UC is nil") )
var (
Cbor = cborHandler{}
)
var (
ErrBlockIsNil = errors.New("block is nil")
)
var (
ErrSystemDescriptionIsNil = errors.New("system description record is nil")
)
var ErrUnicityCertificateIsNil = errors.New("unicity certificate is nil")
Functions ¶
func AssertEqualIR ¶
func AssertEqualIR(a, b *InputRecord) error
func BlockHash ¶
func BlockHash(algorithm crypto.Hash, h *Header, txs []*TransactionRecord, stateHash []byte, prevStateHash []byte) ([]byte, error)
BlockHash returns the hash of the block. Hash of a block is computed as hash of block header fields and tree hash of transactions.
func CheckNonEquivocatingCertificates ¶
func CheckNonEquivocatingCertificates(prevUC, newUC *UnicityCertificate) error
CheckNonEquivocatingCertificates checks if provided certificates are equivocating NB! order is important, also it is assumed that validity of both UCs is checked before The algorithm is based on Yellowpaper: "Algorithm 6 Checking two UC-s for equivocation"
func EnsureVersion ¶
func EqualIR ¶
func EqualIR(a, b *InputRecord) (bool, error)
func ErrInvalidVersion ¶
func HashCBOR ¶
HashCBOR encodes the provided "data" to CBOR and calculates hash using the provided "hashAlgorithm". The "data" parameter should be a CBOR struct with the "toarray" tag. The purpose of CBOR encoding before hashing is to avoid "field offset attacks" e.g. when two structs of the same type, but with different values, would yield the same hash if otherwise normally concatenated.
func NewTimestamp ¶
func NewTimestamp() uint64
NewTimestamp - returns timestamp in seconds from epoch
func VerifyTxProof ¶
func VerifyTxProof(txRecordProof *TxRecordProof, tb RootTrustBase, hashAlgorithm crypto.Hash) error
func VerifyUnitStateProof ¶
func VerifyUnitStateProof(u *UnitStateProof, algorithm crypto.Hash, unitData *StateUnitData, ucv UnicityCertificateValidator) error
Types ¶
type AuthProofSigData ¶
type Block ¶
type Block struct { Header *Header Transactions []*TransactionRecord UnicityCertificate TaggedCBOR // contains filtered or unexported fields }
func (*Block) CalculateBlockHash ¶
func (b *Block) CalculateBlockHash(algorithm crypto.Hash) (*InputRecord, error)
CalculateBlockHash calculates the block hash, updates UC and returns the updated input record with the block hash.
func (*Block) GetBlockFees ¶
func (*Block) GetProposerID ¶
func (*Block) GetRoundNumber ¶
func (*Block) InputRecord ¶
func (b *Block) InputRecord() (*InputRecord, error)
func (*Block) PartitionID ¶
func (b *Block) PartitionID() PartitionID
type ClientMetadata ¶
type ClientMetadata struct { Timeout uint64 MaxTransactionFee uint64 FeeCreditRecordID []byte ReferenceNumber []byte // contains filtered or unexported fields }
func (*ClientMetadata) GetFeeCreditRecordID ¶
func (c *ClientMetadata) GetFeeCreditRecordID() []byte
func (*ClientMetadata) GetMaxFee ¶
func (c *ClientMetadata) GetMaxFee() uint64
func (*ClientMetadata) GetReferenceNumber ¶
func (c *ClientMetadata) GetReferenceNumber() []byte
func (*ClientMetadata) GetTimeout ¶
func (c *ClientMetadata) GetTimeout() uint64
type FeeCreditBill ¶
type FeeCreditBill struct { UnitID UnitID `json:"unitId"` OwnerPredicate PredicateBytes `json:"ownerPredicate"` // contains filtered or unexported fields }
type FeeProofSigData ¶
type GenericChainItem ¶
type Header ¶
type Header struct { Version ABVersion PartitionID PartitionID ShardID ShardID ProposerID string PreviousBlockHash hex.Bytes // contains filtered or unexported fields }
func (*Header) GetVersion ¶
func (*Header) MarshalCBOR ¶
func (*Header) UnmarshalCBOR ¶
type InputRecord ¶
type InputRecord struct { Version ABVersion `json:"version"` PreviousHash hex.Bytes `json:"previousHash"` // previously certified state hash Hash hex.Bytes `json:"hash"` // state hash to be certified BlockHash hex.Bytes `json:"blockHash"` // hash of the block SummaryValue hex.Bytes `json:"summaryValue"` // summary value to certified Timestamp uint64 `json:"timestamp"` // reference time for transaction validation RoundNumber uint64 `json:"roundNumber"` // shard's round number Epoch uint64 `json:"epoch"` // shard’s epoch number SumOfEarnedFees uint64 `json:"sumOfEarnedFees"` // sum of the actual fees over all transaction records in the block // contains filtered or unexported fields }
Shard input record (IR) of a shard of a partition.
func (*InputRecord) AddToHasher ¶
func (x *InputRecord) AddToHasher(hasher abhash.Hasher)
func (*InputRecord) Bytes ¶
func (x *InputRecord) Bytes() ([]byte, error)
func (*InputRecord) GetVersion ¶
func (x *InputRecord) GetVersion() ABVersion
func (*InputRecord) IsValid ¶
func (x *InputRecord) IsValid() error
func (*InputRecord) MarshalCBOR ¶
func (x *InputRecord) MarshalCBOR() ([]byte, error)
func (*InputRecord) NewRepeatIR ¶
func (x *InputRecord) NewRepeatIR() *InputRecord
NewRepeatIR - creates new repeat IR from current IR
func (*InputRecord) String ¶
func (x *InputRecord) String() string
func (*InputRecord) UnmarshalCBOR ¶
func (x *InputRecord) UnmarshalCBOR(data []byte) error
type NodeInfo ¶
type NodeInfo struct { NodeID string `json:"nodeId"` // node identifier derived from node's encryption public key PublicKey hex.Bytes `json:"publicKey"` // the trust base signing public key Stake uint64 `json:"stake"` // amount of staked alpha for this node, currently unused as each nodes get equal votes regardless of stake // contains filtered or unexported fields }
func NewNodeInfo ¶
NewNodeInfo creates new NodeInfo, caching the verifier in private field.
type Option ¶
type Option func(c *trustBaseConf)
func WithQuorumThreshold ¶
WithQuorumThreshold overrides the default 2/3+1 quorum threshold.
type PartitionDescriptionRecord ¶
type PartitionDescriptionRecord struct { Version ABVersion `json:"version"` NetworkIdentifier NetworkID `json:"networkIdentifier"` PartitionIdentifier PartitionID `json:"partitionIdentifier"` // System Type Descriptor is only used (ie is not nil) when PartitionIdentifier == 0 SystemDescriptor *SystemTypeDescriptor `json:"systemTypeDescriptor,omitempty"` TypeIdLen uint32 `json:"typeIdLength"` UnitIdLen uint32 `json:"unitIdLength"` Shards ShardingScheme `json:"shardingScheme"` SummaryTrustBase hex.Bytes `json:"summaryTrustBase"` T2Timeout time.Duration `json:"t2timeout"` FeeCreditBill *FeeCreditBill `json:"feeCreditBill"` // contains filtered or unexported fields }
func (*PartitionDescriptionRecord) GetNetworkIdentifier ¶
func (pdr *PartitionDescriptionRecord) GetNetworkIdentifier() NetworkID
func (*PartitionDescriptionRecord) GetPartitionIdentifier ¶
func (pdr *PartitionDescriptionRecord) GetPartitionIdentifier() PartitionID
func (*PartitionDescriptionRecord) GetVersion ¶
func (pdr *PartitionDescriptionRecord) GetVersion() ABVersion
func (*PartitionDescriptionRecord) Hash ¶
func (pdr *PartitionDescriptionRecord) Hash(hashAlgorithm crypto.Hash) ([]byte, error)
func (*PartitionDescriptionRecord) IsValid ¶
func (pdr *PartitionDescriptionRecord) IsValid() error
func (*PartitionDescriptionRecord) IsValidShard ¶
func (pdr *PartitionDescriptionRecord) IsValidShard(id ShardID) error
IsValidShard checks if the argument is a valid shard ID in the Partition.
func (*PartitionDescriptionRecord) MarshalCBOR ¶
func (pdr *PartitionDescriptionRecord) MarshalCBOR() ([]byte, error)
func (*PartitionDescriptionRecord) UnitIdValidator ¶
func (pdr *PartitionDescriptionRecord) UnitIdValidator(sid ShardID) func(unitID UnitID) error
UnitIdValidator returns function which checks that unit ID passed as argument has correct length and that the unit belongs into the given shard.
func (*PartitionDescriptionRecord) UnmarshalCBOR ¶
func (pdr *PartitionDescriptionRecord) UnmarshalCBOR(data []byte) error
type PartitionID ¶
type PartitionID uint32
func BytesToPartitionID ¶
func BytesToPartitionID(b []byte) (PartitionID, error)
func (PartitionID) Bytes ¶
func (sid PartitionID) Bytes() []byte
func (PartitionID) String ¶
func (sid PartitionID) String() string
type Payload ¶
type Payload struct { NetworkID NetworkID PartitionID PartitionID UnitID UnitID Type uint16 Attributes RawCBOR // transaction type specific attributes StateLock *StateLock ClientMetadata *ClientMetadata // metadata about the transaction added by the client // contains filtered or unexported fields }
Payload helper struct for transaction signing. Includes all TransactionOrder fields except for the signatures themselves (StateUnlock, AuthProof and FeeProof). Payload is an embedded field of TransactionOrder so that the fields get "flattened" in CBOR encoding.
type PredicateBytes ¶
type RawCBOR ¶
type RawCBOR []byte
func (RawCBOR) MarshalCBOR ¶
MarshalCBOR returns r or CBOR nil if r is empty.
func (RawCBOR) MarshalText ¶
func (*RawCBOR) UnmarshalCBOR ¶
UnmarshalCBOR copies data into r unless it's CBOR "nil marker" - in that case r is set to empty slice.
func (*RawCBOR) UnmarshalText ¶
type RootTrustBase ¶
type RootTrustBaseV1 ¶
type RootTrustBaseV1 struct { Version ABVersion `json:"version"` Epoch uint64 `json:"epoch"` // current epoch number EpochStartRound uint64 `json:"epochStartRound"` // root chain round number when the epoch begins RootNodes map[string]*NodeInfo `json:"rootNodes"` // list of all root nodes for the current epoch QuorumThreshold uint64 `json:"quorumThreshold"` // amount of alpha required to reach consensus, currently each node gets equal amount of voting power i.e. +1 for each node StateHash hex.Bytes `json:"stateHash"` // unicity tree root hash ChangeRecordHash hex.Bytes `json:"changeRecordHash"` // epoch change request hash PreviousEntryHash hex.Bytes `json:"previousEntryHash"` // previous trust base entry hash Signatures map[string]hex.Bytes `json:"signatures"` // signatures of previous epoch validators, over all fields except for the signatures fields itself // contains filtered or unexported fields }
func NewTrustBaseFromFile ¶
func NewTrustBaseFromFile(trustBaseFile string) (*RootTrustBaseV1, error)
NewTrustBaseFromFile loads trust base from file and caches verifiers.
func NewTrustBaseGenesis ¶
func NewTrustBaseGenesis(nodes []*NodeInfo, unicityTreeRootHash []byte, opts ...Option) (*RootTrustBaseV1, error)
NewTrustBaseGenesis creates new unsigned root trust base with default genesis parameters.
func (*RootTrustBaseV1) GetMaxFaultyNodes ¶
func (r *RootTrustBaseV1) GetMaxFaultyNodes() uint64
GetMaxFaultyNodes returns max allowed faulty nodes, only works if one node == one vote.
func (*RootTrustBaseV1) GetQuorumThreshold ¶
func (r *RootTrustBaseV1) GetQuorumThreshold() uint64
GetQuorumThreshold returns the quorum threshold for the latest trust base entry.
func (*RootTrustBaseV1) GetVerifiers ¶
func (r *RootTrustBaseV1) GetVerifiers() (map[string]abcrypto.Verifier, error)
GetVerifiers returns the cached verifiers.
func (*RootTrustBaseV1) GetVersion ¶
func (r *RootTrustBaseV1) GetVersion() ABVersion
func (*RootTrustBaseV1) Hash ¶
func (r *RootTrustBaseV1) Hash(hashAlgo crypto.Hash) ([]byte, error)
Hash hashes the entire structure including the signatures.
func (*RootTrustBaseV1) MarshalCBOR ¶
func (r *RootTrustBaseV1) MarshalCBOR() ([]byte, error)
func (RootTrustBaseV1) SigBytes ¶
func (r RootTrustBaseV1) SigBytes() ([]byte, error)
SigBytes serializes all fields expect for the signatures field.
func (*RootTrustBaseV1) Sign ¶
func (r *RootTrustBaseV1) Sign(nodeID string, signer abcrypto.Signer) error
Sign signs the trust base entry, storing the signature to Signatures map.
func (*RootTrustBaseV1) UnmarshalCBOR ¶
func (r *RootTrustBaseV1) UnmarshalCBOR(data []byte) error
func (*RootTrustBaseV1) VerifyQuorumSignatures ¶
func (r *RootTrustBaseV1) VerifyQuorumSignatures(data []byte, signatures map[string]hex.Bytes) (error, []error)
VerifyQuorumSignatures verifies that the data is signed by enough root nodes so that quorum is reached, returns error if quorum is not reached, also returns list of any signature verification errors, regardless if quorum is reached or not.
func (*RootTrustBaseV1) VerifySignature ¶
VerifySignature verifies that the data is signed by the given root validator, returns the validator's stake if it is signed.
type ServerMetadata ¶
type ServerMetadata struct { ActualFee uint64 TargetUnits []UnitID SuccessIndicator TxStatus ProcessingDetails RawCBOR // contains filtered or unexported fields }
func (*ServerMetadata) ErrDetail ¶
func (sm *ServerMetadata) ErrDetail() error
func (*ServerMetadata) GetActualFee ¶
func (sm *ServerMetadata) GetActualFee() uint64
func (*ServerMetadata) GetTargetUnits ¶
func (sm *ServerMetadata) GetTargetUnits() []UnitID
func (*ServerMetadata) SetError ¶
func (sm *ServerMetadata) SetError(e error)
func (*ServerMetadata) TxStatus ¶
func (sm *ServerMetadata) TxStatus() TxStatus
func (*ServerMetadata) UnmarshalDetails ¶
func (sm *ServerMetadata) UnmarshalDetails(v any) error
type ShardID ¶
type ShardID struct {
// contains filtered or unexported fields
}
func (ShardID) AddToHasher ¶
func (ShardID) Comparator ¶
Comparator returns function which checks does the byte slice argument have the prefix which matches the shard ID. NB! It is callers responsibility to not pass shorter slice than the shard id!
func (ShardID) MarshalCBOR ¶
func (ShardID) MarshalText ¶
func (ShardID) Split ¶
Split increases shard ID length by one bit and returns the two new IDs. The original shard ID is not altered.
func (*ShardID) UnmarshalCBOR ¶
func (*ShardID) UnmarshalText ¶
type ShardTree ¶
func CreateShardTree ¶
func CreateShardTree(scheme ShardingScheme, states []ShardTreeInput, algo crypto.Hash) (ShardTree, error)
"states" must contain record for each shard in the "scheme".
func (ShardTree) Certificate ¶
func (tree ShardTree) Certificate(shardID ShardID) (ShardTreeCertificate, error)
Certificate returns Shard Tree Certificate for the shard.
type ShardTreeCertificate ¶
type ShardTreeCertificate struct { Shard ShardID SiblingHashes [][]byte // contains filtered or unexported fields }
func (ShardTreeCertificate) ComputeCertificateHash ¶
func (cert ShardTreeCertificate) ComputeCertificateHash(IR *InputRecord, TRHash []byte, algo crypto.Hash) ([]byte, error)
ComputeCertificateHash implements the "Compute Shard Tree Certificate" algorithm. Input:
IR - input record of the shard TRHash - hash of the TechnicalRecord
Output: Root hash
func (ShardTreeCertificate) IsValid ¶
func (cert ShardTreeCertificate) IsValid() error
type ShardTreeInput ¶
type ShardTreeInput struct { Shard ShardID IR *InputRecord TRHash []byte // hash of TechnicalRecord }
ShardTreeInput is source data for leaf node in a shard tree
type ShardingScheme ¶
type ShardingScheme []ShardID
func (ShardingScheme) All ¶
func (sh ShardingScheme) All() iter.Seq[ShardID]
All returns iterator over all shard IDs in the sharding scheme.
For a single shard scheme (empty list) single empty shard ID is returned.
func (ShardingScheme) IsValid ¶
func (sh ShardingScheme) IsValid() error
type SignatureMap ¶
type StateLock ¶
type StateLockProofSigData ¶
type StateTreeCert ¶
type StateTreeCert struct { LeftSummaryHash hex.Bytes `json:"leftSummaryHash"` LeftSummaryValue uint64 `json:"leftSummaryValue,string"` RightSummaryHash hex.Bytes `json:"rightSummaryHash"` RightSummaryValue uint64 `json:"rightSummaryValue,string"` Path []*StateTreePathItem `json:"path"` // contains filtered or unexported fields }
type StateTreePathItem ¶
type StateTreePathItem struct { UnitID UnitID `json:"unitId"` // (ι′) LogsHash hex.Bytes `json:"logsHash"` // (z) Value uint64 `json:"value,string"` // (V) SiblingSummaryHash hex.Bytes `json:"siblingSummaryHash"` SiblingSummaryValue uint64 `json:"siblingSummaryValue,string"` // contains filtered or unexported fields }
type StateUnitData ¶
type StateUnitData struct {
Data RawCBOR
}
func (*StateUnitData) UnmarshalData ¶
func (sd *StateUnitData) UnmarshalData(v any) error
type SystemTypeDescriptor ¶
type SystemTypeDescriptor struct { }
func (*SystemTypeDescriptor) AddToHasher ¶
func (std *SystemTypeDescriptor) AddToHasher(h abhash.Hasher)
type TaggedCBOR ¶
type TaggedCBOR = RawCBOR
type TransactionOrder ¶
type TransactionOrder struct { Version ABVersion Payload // the embedded Payload field is "flattened" in CBOR array StateUnlock []byte // two CBOR data items: [0|1]+[<state lock/rollback predicate input>] AuthProof RawCBOR // transaction type specific signatures/authorisation proofs FeeProof []byte // contains filtered or unexported fields }
func (*TransactionOrder) AuthProofSigBytes ¶
func (t *TransactionOrder) AuthProofSigBytes() ([]byte, error)
func (*TransactionOrder) FeeCreditRecordID ¶
func (t *TransactionOrder) FeeCreditRecordID() []byte
func (*TransactionOrder) FeeProofSigBytes ¶
func (t *TransactionOrder) FeeProofSigBytes() ([]byte, error)
func (*TransactionOrder) GetNetworkID ¶
func (t *TransactionOrder) GetNetworkID() NetworkID
func (*TransactionOrder) GetPartitionID ¶
func (t *TransactionOrder) GetPartitionID() PartitionID
func (*TransactionOrder) GetUnitID ¶
func (t *TransactionOrder) GetUnitID() UnitID
func (*TransactionOrder) GetVersion ¶
func (t *TransactionOrder) GetVersion() ABVersion
func (*TransactionOrder) HasStateLock ¶
func (t *TransactionOrder) HasStateLock() bool
func (*TransactionOrder) Hash ¶
func (t *TransactionOrder) Hash(algorithm crypto.Hash) ([]byte, error)
func (*TransactionOrder) MarshalCBOR ¶
func (t *TransactionOrder) MarshalCBOR() ([]byte, error)
func (*TransactionOrder) MaxFee ¶
func (t *TransactionOrder) MaxFee() uint64
func (*TransactionOrder) ReferenceNumber ¶
func (t *TransactionOrder) ReferenceNumber() []byte
func (*TransactionOrder) SetAttributes ¶
func (t *TransactionOrder) SetAttributes(attr any) error
SetAttributes serializes "attr" and assigns the result to payload's Attributes field. The "attr" is expected to be one of the transaction attribute structs but there is no validation! The TransactionOrder.UnmarshalAttributes can be used to decode the attributes.
func (*TransactionOrder) SetAuthProof ¶
func (t *TransactionOrder) SetAuthProof(authProof any) error
SetAuthProof converts provided authProof struct to CBOR and sets the AuthProof field.
func (*TransactionOrder) StateLockProofSigBytes ¶
func (t *TransactionOrder) StateLockProofSigBytes() ([]byte, error)
func (*TransactionOrder) Timeout ¶
func (t *TransactionOrder) Timeout() uint64
func (*TransactionOrder) UnmarshalAttributes ¶
func (t *TransactionOrder) UnmarshalAttributes(v any) error
func (*TransactionOrder) UnmarshalAuthProof ¶
func (t *TransactionOrder) UnmarshalAuthProof(v any) error
func (*TransactionOrder) UnmarshalCBOR ¶
func (t *TransactionOrder) UnmarshalCBOR(data []byte) error
type TransactionOrderCBOR ¶
type TransactionOrderCBOR = TaggedCBOR
type TransactionRecord ¶
type TransactionRecord struct { Version ABVersion TransactionOrder TransactionOrderCBOR ServerMetadata *ServerMetadata // contains filtered or unexported fields }
TransactionRecord is a transaction order with "server-side" metadata added to it. TransactionRecord is a structure that is added to the block.
func (*TransactionRecord) Bytes ¶
func (t *TransactionRecord) Bytes() ([]byte, error)
func (*TransactionRecord) GetActualFee ¶
func (t *TransactionRecord) GetActualFee() uint64
func (*TransactionRecord) GetTransactionOrderV1 ¶
func (t *TransactionRecord) GetTransactionOrderV1() (*TransactionOrder, error)
func (*TransactionRecord) GetVersion ¶
func (t *TransactionRecord) GetVersion() ABVersion
func (*TransactionRecord) Hash ¶
func (t *TransactionRecord) Hash(algorithm crypto.Hash) ([]byte, error)
func (*TransactionRecord) IsSuccessful ¶
func (t *TransactionRecord) IsSuccessful() bool
func (*TransactionRecord) IsValid ¶
func (t *TransactionRecord) IsValid() error
func (*TransactionRecord) MarshalCBOR ¶
func (t *TransactionRecord) MarshalCBOR() ([]byte, error)
func (*TransactionRecord) TargetUnits ¶
func (t *TransactionRecord) TargetUnits() []UnitID
func (*TransactionRecord) TxStatus ¶
func (t *TransactionRecord) TxStatus() TxStatus
func (*TransactionRecord) UnmarshalCBOR ¶
func (t *TransactionRecord) UnmarshalCBOR(data []byte) error
func (*TransactionRecord) UnmarshalProcessingDetails ¶
func (t *TransactionRecord) UnmarshalProcessingDetails(v any) error
type TxProof ¶
type TxProof struct { Version ABVersion BlockHeaderHash []byte Chain []*GenericChainItem UnicityCertificate TaggedCBOR // contains filtered or unexported fields }
TxProof is a transaction execution proof.
func (*TxProof) GetVersion ¶
func (*TxProof) MarshalCBOR ¶
func (*TxProof) UnmarshalCBOR ¶
type TxRecordProof ¶
type TxRecordProof struct { TxRecord *TransactionRecord TxProof *TxProof // contains filtered or unexported fields }
func NewTxRecordProof ¶
func (*TxRecordProof) ActualFee ¶
func (t *TxRecordProof) ActualFee() uint64
func (*TxRecordProof) GetTransactionOrderV1 ¶
func (t *TxRecordProof) GetTransactionOrderV1() (*TransactionOrder, error)
func (*TxRecordProof) IsValid ¶
func (t *TxRecordProof) IsValid() error
func (*TxRecordProof) TxStatus ¶
func (t *TxRecordProof) TxStatus() TxStatus
type TxStatus ¶
type TxStatus uint64
const ( // TxStatusFailed is the status code of a transaction if execution failed. TxStatusFailed TxStatus = 0 // TxStatusSuccessful is the status code of a transaction if execution succeeded. TxStatusSuccessful TxStatus = 1 // TxErrOutOfGas tx execution run out of gas, try with bigger 'MaxTransactionFee' TxErrOutOfGas TxStatus = 2 )
type UnicityCertificate ¶
type UnicityCertificate struct { Version ABVersion `json:"version"` InputRecord *InputRecord `json:"inputRecord"` TRHash hex.Bytes `json:"trHash"` // hash of the TechnicalRecord ShardTreeCertificate ShardTreeCertificate `json:"shardTreeCertificate"` UnicityTreeCertificate *UnicityTreeCertificate `json:"unicityTreeCertificate"` UnicitySeal *UnicitySeal `json:"unicitySeal"` // contains filtered or unexported fields }
func (*UnicityCertificate) GetFeeSum ¶
func (x *UnicityCertificate) GetFeeSum() uint64
func (*UnicityCertificate) GetPreviousStateHash ¶
func (x *UnicityCertificate) GetPreviousStateHash() []byte
func (*UnicityCertificate) GetRootRoundNumber ¶
func (x *UnicityCertificate) GetRootRoundNumber() uint64
func (*UnicityCertificate) GetRoundNumber ¶
func (x *UnicityCertificate) GetRoundNumber() uint64
func (*UnicityCertificate) GetStateHash ¶
func (x *UnicityCertificate) GetStateHash() []byte
func (*UnicityCertificate) GetSummaryValue ¶
func (x *UnicityCertificate) GetSummaryValue() []byte
func (*UnicityCertificate) GetVersion ¶
func (x *UnicityCertificate) GetVersion() ABVersion
func (*UnicityCertificate) Hash ¶
func (x *UnicityCertificate) Hash(hash crypto.Hash) ([]byte, error)
func (*UnicityCertificate) IsDuplicate ¶
func (x *UnicityCertificate) IsDuplicate(prevUC *UnicityCertificate) bool
func (*UnicityCertificate) IsRepeat ¶
func (x *UnicityCertificate) IsRepeat(prevUC *UnicityCertificate) (bool, error)
func (*UnicityCertificate) IsSuccessor ¶
func (x *UnicityCertificate) IsSuccessor(prevUC *UnicityCertificate) bool
func (*UnicityCertificate) IsValid ¶
func (x *UnicityCertificate) IsValid(algorithm crypto.Hash, partitionID PartitionID, systemDescriptionHash []byte) error
func (*UnicityCertificate) MarshalCBOR ¶
func (x *UnicityCertificate) MarshalCBOR() ([]byte, error)
func (*UnicityCertificate) UnmarshalCBOR ¶
func (x *UnicityCertificate) UnmarshalCBOR(data []byte) error
func (*UnicityCertificate) Verify ¶
func (x *UnicityCertificate) Verify(tb RootTrustBase, algorithm crypto.Hash, partitionID PartitionID, systemDescriptionHash []byte) error
type UnicityCertificateValidator ¶
type UnicityCertificateValidator interface {
Validate(uc *UnicityCertificate) error
}
type UnicitySeal ¶
type UnicitySeal struct { Version ABVersion `json:"version"` RootChainRoundNumber uint64 `json:"rootChainRoundNumber"` Timestamp uint64 `json:"timestamp"` PreviousHash hex.Bytes `json:"previousHash"` Hash hex.Bytes `json:"hash"` Signatures SignatureMap `json:"signatures"` // contains filtered or unexported fields }
func (*UnicitySeal) AddToHasher ¶
func (x *UnicitySeal) AddToHasher(hasher abhash.Hasher)
AddToHasher - add all UC data including signature bytes for hash calculation
func (*UnicitySeal) GetVersion ¶
func (x *UnicitySeal) GetVersion() ABVersion
func (*UnicitySeal) IsValid ¶
func (x *UnicitySeal) IsValid() error
func (*UnicitySeal) MarshalCBOR ¶
func (x *UnicitySeal) MarshalCBOR() ([]byte, error)
func (UnicitySeal) SigBytes ¶
func (x UnicitySeal) SigBytes() ([]byte, error)
SigBytes - serialize everything except signatures (used for sign and verify)
func (*UnicitySeal) UnmarshalCBOR ¶
func (x *UnicitySeal) UnmarshalCBOR(b []byte) error
func (*UnicitySeal) Verify ¶
func (x *UnicitySeal) Verify(tb RootTrustBase) error
type UnicityTree ¶
type UnicityTree struct {
// contains filtered or unexported fields
}
func NewUnicityTree ¶
func NewUnicityTree(hashAlgorithm crypto.Hash, data []*UnicityTreeData) (*UnicityTree, error)
NewUnicityTree creates a new unicity tree with given partitions.
NB! Sorts the "data" slice without making copy of it!
func (*UnicityTree) Certificate ¶
func (u *UnicityTree) Certificate(partition PartitionID) (*UnicityTreeCertificate, error)
Certificate returns an unicity tree certificate for given system identifier.
func (*UnicityTree) RootHash ¶
func (u *UnicityTree) RootHash() []byte
type UnicityTreeCertificate ¶
type UnicityTreeCertificate struct { Version ABVersion `json:"version"` Partition PartitionID `json:"partitionIdentifier"` HashSteps []*imt.PathItem `json:"hashSteps"` PDRHash hex.Bytes `json:"partitionDescriptionHash"` // contains filtered or unexported fields }
func (*UnicityTreeCertificate) AddToHasher ¶
func (utc *UnicityTreeCertificate) AddToHasher(hasher abhash.Hasher)
func (*UnicityTreeCertificate) EvalAuthPath ¶
func (utc *UnicityTreeCertificate) EvalAuthPath(shardTreeRoot []byte, hashAlgorithm crypto.Hash) ([]byte, error)
EvalAuthPath aka Compute Unicity Tree Certificate.
The shardTreeRoot is output of the CompShardTreeCert function.
func (*UnicityTreeCertificate) GetVersion ¶
func (utc *UnicityTreeCertificate) GetVersion() ABVersion
func (*UnicityTreeCertificate) IsValid ¶
func (utc *UnicityTreeCertificate) IsValid(partition PartitionID, systemDescriptionHash []byte) error
func (*UnicityTreeCertificate) MarshalCBOR ¶
func (utc *UnicityTreeCertificate) MarshalCBOR() ([]byte, error)
func (*UnicityTreeCertificate) UnmarshalCBOR ¶
func (utc *UnicityTreeCertificate) UnmarshalCBOR(data []byte) error
type UnicityTreeData ¶
type UnicityTreeData struct { Partition PartitionID ShardTreeRoot []byte // root hash of the partition shard tree PDRHash []byte // PartitionDescriptionRecord hash }
func (*UnicityTreeData) AddToHasher ¶
func (t *UnicityTreeData) AddToHasher(hasher abhash.Hasher)
func (*UnicityTreeData) Key ¶
func (t *UnicityTreeData) Key() []byte
type UnitData ¶
type UnitData interface { Write(hasher abhash.Hasher) SummaryValueInput() uint64 Copy() UnitData Owner() []byte }
UnitData is a generic data type for the unit state.
type UnitDataAndProof ¶
type UnitDataAndProof struct { UnitData *StateUnitData Proof *UnitStateProof // contains filtered or unexported fields }
func (*UnitDataAndProof) UnmarshalUnitData ¶
func (up *UnitDataAndProof) UnmarshalUnitData(v any) error
type UnitID ¶
type UnitID []byte
UnitID is the extended identifier, combining the type and the unit identifiers.
func (UnitID) MarshalText ¶
func (*UnitID) UnmarshalText ¶
type UnitStateProof ¶
type UnitStateProof struct { Version ABVersion `json:"version"` UnitID UnitID `json:"unitId"` UnitValue uint64 `json:"unitValue,string"` UnitLedgerHash hex.Bytes `json:"unitLedgerHash"` UnitTreeCert *UnitTreeCert `json:"unitTreeCert"` StateTreeCert *StateTreeCert `json:"stateTreeCert"` UnicityCertificate TaggedCBOR `json:"unicityCert"` // contains filtered or unexported fields }
func (*UnitStateProof) CalculateStateTreeOutput ¶
func (*UnitStateProof) GetVersion ¶
func (u *UnitStateProof) GetVersion() ABVersion
func (*UnitStateProof) MarshalCBOR ¶
func (u *UnitStateProof) MarshalCBOR() ([]byte, error)
func (*UnitStateProof) UnmarshalCBOR ¶
func (u *UnitStateProof) UnmarshalCBOR(data []byte) error
type UnitTreeCert ¶
Source Files ¶
- bitstring.go
- block.go
- cbor.go
- cbor_hash.go
- identifiers.go
- input_record.go
- partition_description.go
- root_trust_base.go
- shard_certificate.go
- sharding.go
- tx_order.go
- tx_proof.go
- tx_record.go
- unicity_certificate.go
- unicity_seal.go
- unicity_tree.go
- unicity_tree_certificate.go
- unit.go
- unit_proof.go
- versions.go