Documentation
¶
Index ¶
- Constants
- Variables
- func AssertEqualIR(a, b *InputRecord) error
- func CheckNonEquivocatingCertificates(prevUC, newUC *UnicityCertificate) error
- func EqualIR(a, b *InputRecord) bool
- func NewTimestamp() uint64
- func NewTxProof(block *Block, txIndex int, algorithm crypto.Hash) (*TxProof, *TransactionRecord, error)
- func VerifyTxProof(proof *TxProof, txRecord *TransactionRecord, ...) error
- func VerifyUnitStateProof(u *UnitStateProof, algorithm crypto.Hash, unitData *StateUnitData, ...) error
- type Block
- func (b *Block) GetBlockFees() uint64
- func (b *Block) GetProposerID() string
- func (b *Block) GetRoundNumber() uint64
- func (b *Block) Hash(algorithm crypto.Hash) ([]byte, error)
- func (b *Block) HeaderHash(algorithm crypto.Hash) []byte
- func (b *Block) InputRecord() (*InputRecord, error)
- func (b *Block) IsValid(v func(uc *UnicityCertificate) error) error
- func (b *Block) SystemID() SystemID
- type Bytes
- type ClientMetadata
- type GenericChainItem
- type Header
- type InputRecord
- type Payload
- type PredicateBytes
- type ProofGenerator
- type RawCBOR
- type ServerMetadata
- type SigBytesProvider
- type SignatureMap
- type StateTreeCert
- type StateTreePathItem
- type StateUnitData
- type SystemID
- type TransactionOrder
- func (t *TransactionOrder) GetClientFeeCreditRecordID() []byte
- func (t *TransactionOrder) GetClientMaxTxFee() uint64
- func (t *TransactionOrder) Hash(algorithm crypto.Hash) []byte
- func (t *TransactionOrder) PayloadBytes() ([]byte, error)
- func (t *TransactionOrder) PayloadType() string
- func (t *TransactionOrder) SetOwnerProof(proofer ProofGenerator) error
- func (t *TransactionOrder) SystemID() SystemID
- func (t *TransactionOrder) Timeout() uint64
- func (t *TransactionOrder) UnitID() UnitID
- func (t *TransactionOrder) UnmarshalAttributes(v any) error
- type TransactionRecord
- type TxProof
- type TxStatus
- type Uint64
- 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) Hash(hash gocrypto.Hash) []byte
- func (x *UnicityCertificate) IsRepeat(prevUC *UnicityCertificate) bool
- func (x *UnicityCertificate) IsValid(verifiers map[string]crypto.Verifier, algorithm gocrypto.Hash, ...) error
- type UnicityCertificateValidator
- type UnicitySeal
- func (x *UnicitySeal) AddToHasher(hasher hash.Hash)
- func (x *UnicitySeal) Bytes() []byte
- func (x *UnicitySeal) IsValid(verifiers map[string]crypto.Verifier) error
- func (x *UnicitySeal) Sign(id string, signer crypto.Signer) error
- func (x *UnicitySeal) Verify(verifiers map[string]crypto.Verifier) error
- type UnicityTreeCertificate
- type UnicityTreeData
- type UnitDataAndProof
- type UnitID
- type UnitStateProof
- type UnitTreeCert
Constants ¶
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)
const SystemIdentifierLength = 4
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 ( ErrUnicitySealIsNil = errors.New("unicity seal is nil") ErrSignerIsNil = errors.New("signer is nil") ErrUnicitySealHashIsNil = errors.New("hash is nil") ErrInvalidBlockNumber = errors.New("invalid block number") ErrUnicitySealSignatureIsNil = errors.New("no signatures") ErrRootValidatorInfoMissing = errors.New("root node info is missing") ErrUnknownSigner = errors.New("unknown signer") )
var (
ErrBlockIsNil = errors.New("block is nil")
)
var ErrUnicityCertificateIsNil = errors.New("unicity certificate is nil")
var ErrUnicityTreeCertificateIsNil = errors.New("unicity tree certificate is nil")
Functions ¶
func AssertEqualIR ¶ added in v0.4.0
func AssertEqualIR(a, b *InputRecord) error
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 EqualIR ¶ added in v0.4.0
func EqualIR(a, b *InputRecord) bool
func NewTimestamp ¶
func NewTimestamp() uint64
NewTimestamp - returns timestamp in seconds from epoch
func NewTxProof ¶
func VerifyTxProof ¶
func VerifyUnitStateProof ¶
func VerifyUnitStateProof(u *UnitStateProof, algorithm crypto.Hash, unitData *StateUnitData, ucv UnicityCertificateValidator) error
Types ¶
type Block ¶
type Block struct { Header *Header Transactions []*TransactionRecord UnicityCertificate *UnicityCertificate // contains filtered or unexported fields }
func (*Block) GetBlockFees ¶ added in v0.4.0
func (*Block) GetProposerID ¶
func (*Block) GetRoundNumber ¶
func (*Block) Hash ¶
Hash returns the hash of the block. Hash of a block is computed as hash of block header fields and tree hash of transactions.
func (*Block) InputRecord ¶ added in v0.4.0
func (b *Block) InputRecord() (*InputRecord, error)
type Bytes ¶ added in v0.4.0
type Bytes []byte
func (Bytes) MarshalText ¶ added in v0.4.0
func (*Bytes) UnmarshalText ¶ added in v0.4.0
type ClientMetadata ¶
type GenericChainItem ¶
type Header ¶
type InputRecord ¶
type InputRecord struct { PreviousHash []byte `json:"previous_hash,omitempty"` // previously certified state hash Hash []byte `json:"hash,omitempty"` // state hash to be certified BlockHash []byte `json:"block_hash,omitempty"` // hash of the block SummaryValue []byte `json:"summary_value,omitempty"` // summary value to certified RoundNumber uint64 `json:"round_number,omitempty"` // transaction system's round number SumOfEarnedFees uint64 `json:"sum_of_earned_fees,omitempty"` // sum of the actual fees over all transaction records in the block // contains filtered or unexported fields }
func (*InputRecord) AddToHasher ¶
func (x *InputRecord) AddToHasher(hasher hash.Hash)
func (*InputRecord) Bytes ¶
func (x *InputRecord) Bytes() []byte
func (*InputRecord) IsValid ¶
func (x *InputRecord) IsValid() error
func (*InputRecord) NewRepeatIR ¶
func (x *InputRecord) NewRepeatIR() *InputRecord
NewRepeatIR - creates new repeat IR from current IR
func (*InputRecord) String ¶ added in v0.4.0
func (x *InputRecord) String() string
type Payload ¶
type Payload struct { SystemID SystemID Type string UnitID UnitID Attributes RawCBOR ClientMetadata *ClientMetadata // contains filtered or unexported fields }
func (*Payload) BytesWithAttributeSigBytes ¶
func (p *Payload) BytesWithAttributeSigBytes(attrs SigBytesProvider) ([]byte, error)
BytesWithAttributeSigBytes TODO: AB-1016 remove this hack
func (*Payload) SetAttributes ¶
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 Payload.UnmarshalAttributes can be used to decode the attributes.
func (*Payload) UnmarshalAttributes ¶
type PredicateBytes ¶ added in v0.4.0
type PredicateBytes = Bytes
type ProofGenerator ¶
type RawCBOR ¶
type RawCBOR []byte
func (RawCBOR) MarshalCBOR ¶
MarshalCBOR returns r or CBOR nil if r is nil.
func (*RawCBOR) UnmarshalCBOR ¶
UnmarshalCBOR creates a copy of data and saves to *r.
type ServerMetadata ¶
type ServerMetadata struct { ActualFee uint64 TargetUnits []UnitID SuccessIndicator TxStatus ProcessingDetails RawCBOR // contains filtered or unexported fields }
func (*ServerMetadata) GetActualFee ¶
func (sm *ServerMetadata) GetActualFee() uint64
func (*ServerMetadata) UnmarshalDetails ¶
func (sm *ServerMetadata) UnmarshalDetails(v any) error
type SigBytesProvider ¶
type SignatureMap ¶
func (*SignatureMap) AddToHasher ¶
func (s *SignatureMap) AddToHasher(hasher hash.Hash)
func (*SignatureMap) MarshalCBOR ¶
func (s *SignatureMap) MarshalCBOR() ([]byte, error)
func (*SignatureMap) UnmarshalCBOR ¶
func (s *SignatureMap) UnmarshalCBOR(b []byte) error
type StateTreeCert ¶
type StateTreeCert struct { LeftSummaryHash Bytes `json:"leftSummaryHash"` LeftSummaryValue uint64 `json:"leftSummaryValue,string"` RightSummaryHash 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 Bytes `json:"logsHash"` // (z) Value uint64 `json:"value,string"` // (V) SiblingSummaryHash Bytes `json:"siblingSummaryHash"` SiblingSummaryValue uint64 `json:"siblingSummaryValue,string"` // contains filtered or unexported fields }
type StateUnitData ¶
type StateUnitData struct { Data cbor.RawMessage Bearer Bytes }
func (*StateUnitData) UnmarshalData ¶
func (sd *StateUnitData) UnmarshalData(v any) error
type TransactionOrder ¶
type TransactionOrder struct { Payload *Payload OwnerProof []byte FeeProof []byte // contains filtered or unexported fields }
func (*TransactionOrder) GetClientFeeCreditRecordID ¶
func (t *TransactionOrder) GetClientFeeCreditRecordID() []byte
func (*TransactionOrder) GetClientMaxTxFee ¶
func (t *TransactionOrder) GetClientMaxTxFee() uint64
func (*TransactionOrder) PayloadBytes ¶
func (t *TransactionOrder) PayloadBytes() ([]byte, error)
func (*TransactionOrder) PayloadType ¶
func (t *TransactionOrder) PayloadType() string
func (*TransactionOrder) SetOwnerProof ¶
func (t *TransactionOrder) SetOwnerProof(proofer ProofGenerator) error
SetOwnerProof assigns the bytes returned by the function provided as argument to the OwnerProof field unless the function (or reading data to be signed by that function) returned error.
func (*TransactionOrder) SystemID ¶
func (t *TransactionOrder) SystemID() SystemID
func (*TransactionOrder) Timeout ¶
func (t *TransactionOrder) Timeout() uint64
func (*TransactionOrder) UnitID ¶
func (t *TransactionOrder) UnitID() UnitID
func (*TransactionOrder) UnmarshalAttributes ¶
func (t *TransactionOrder) UnmarshalAttributes(v any) error
type TransactionRecord ¶
type TransactionRecord struct { TransactionOrder *TransactionOrder 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) UnmarshalProcessingDetails ¶
func (t *TransactionRecord) UnmarshalProcessingDetails(v any) error
type TxProof ¶
type TxProof struct { BlockHeaderHash []byte Chain []*GenericChainItem UnicityCertificate *UnicityCertificate // contains filtered or unexported fields }
TxProof is a transaction execution proof.
func (*TxProof) GetUnicityTreeSystemDescriptionHash ¶
type Uint64 ¶ added in v0.4.0
type Uint64 uint64
func (Uint64) MarshalText ¶ added in v0.4.0
func (*Uint64) UnmarshalText ¶ added in v0.4.0
type UnicityCertificate ¶
type UnicityCertificate struct { InputRecord *InputRecord `json:"input_record,omitempty"` UnicityTreeCertificate *UnicityTreeCertificate `json:"unicity_tree_certificate,omitempty"` UnicitySeal *UnicitySeal `json:"unicity_seal,omitempty"` // contains filtered or unexported fields }
func (*UnicityCertificate) GetFeeSum ¶ added in v0.4.0
func (x *UnicityCertificate) GetFeeSum() uint64
func (*UnicityCertificate) GetPreviousStateHash ¶ added in v0.4.0
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 ¶ added in v0.4.0
func (x *UnicityCertificate) GetSummaryValue() []byte
func (*UnicityCertificate) IsRepeat ¶
func (x *UnicityCertificate) IsRepeat(prevUC *UnicityCertificate) bool
type UnicityCertificateValidator ¶
type UnicityCertificateValidator interface {
Validate(uc *UnicityCertificate) error
}
type UnicitySeal ¶
type UnicitySeal struct { RootChainRoundNumber uint64 `json:"root_chain_round_number,omitempty"` Timestamp uint64 `json:"timestamp,omitempty"` PreviousHash []byte `json:"previous_hash,omitempty"` Hash []byte `json:"hash,omitempty"` Signatures SignatureMap `json:"signatures,omitempty"` // contains filtered or unexported fields }
func (*UnicitySeal) AddToHasher ¶
func (x *UnicitySeal) AddToHasher(hasher hash.Hash)
AddToHasher - add all UC data including signature bytes for hash calculation
func (*UnicitySeal) Bytes ¶
func (x *UnicitySeal) Bytes() []byte
Bytes - serialize everything except signatures (used for sign and verify)
type UnicityTreeCertificate ¶
type UnicityTreeCertificate struct { SystemIdentifier SystemID `json:"system_identifier,omitempty"` SiblingHashes []*imt.PathItem `json:"sibling_hashes,omitempty"` SystemDescriptionHash []byte `json:"system_description_hash,omitempty"` // contains filtered or unexported fields }
func (*UnicityTreeCertificate) AddToHasher ¶
func (x *UnicityTreeCertificate) AddToHasher(hasher hash.Hash)
func (*UnicityTreeCertificate) EvalAuthPath ¶
func (x *UnicityTreeCertificate) EvalAuthPath(hashAlgorithm gocrypto.Hash) []byte
func (*UnicityTreeCertificate) IsValid ¶
func (x *UnicityTreeCertificate) IsValid(ir *InputRecord, systemIdentifier SystemID, systemDescriptionHash []byte, hashAlgorithm gocrypto.Hash) error
type UnicityTreeData ¶
type UnicityTreeData struct { SystemIdentifier SystemID InputRecord *InputRecord SystemDescriptionRecordHash []byte }
func (*UnicityTreeData) AddToHasher ¶
func (t *UnicityTreeData) AddToHasher(hasher hash.Hash)
func (*UnicityTreeData) Key ¶
func (t *UnicityTreeData) Key() []byte
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
func (UnitID) MarshalText ¶ added in v0.4.0
func (*UnitID) UnmarshalText ¶ added in v0.4.0
type UnitStateProof ¶
type UnitStateProof struct { UnitID UnitID `json:"unitId"` UnitValue uint64 `json:"unitValue,string"` UnitLedgerHash Bytes `json:"unitLedgerHash"` UnitTreeCert *UnitTreeCert `json:"unitTreeCert"` StateTreeCert *StateTreeCert `json:"stateTreeCert"` UnicityCertificate *UnicityCertificate `json:"unicityCert"` // contains filtered or unexported fields }
func (*UnitStateProof) CalculateSateTreeOutput ¶
func (u *UnitStateProof) CalculateSateTreeOutput(algorithm crypto.Hash) ([]byte, uint64)