types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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")
)
View Source
var (
	ErrBlockIsNil = errors.New("block is nil")
)
View Source
var ErrUnicityCertificateIsNil = errors.New("unicity certificate is nil")
View Source
var ErrUnicityTreeCertificateIsNil = errors.New("unicity tree certificate is nil")

Functions

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 NewTxProof

func NewTxProof(block *Block, txIndex int, algorithm crypto.Hash) (*TxProof, *TransactionRecord, error)

func VerifyTxProof

func VerifyTxProof(proof *TxProof, txRecord *TransactionRecord, trustBase map[string]abcrypto.Verifier, hashAlgorithm crypto.Hash) error

Types

type Block

type Block struct {
	Header             *Header
	Transactions       []*TransactionRecord
	UnicityCertificate *UnicityCertificate
	// contains filtered or unexported fields
}

func (*Block) GetProposerID

func (b *Block) GetProposerID() string

func (*Block) GetRoundNumber

func (b *Block) GetRoundNumber() uint64

func (*Block) Hash

func (b *Block) Hash(algorithm crypto.Hash) ([]byte, error)

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) HeaderHash

func (b *Block) HeaderHash(algorithm crypto.Hash) []byte

func (*Block) IsValid

func (b *Block) IsValid(v func(uc *UnicityCertificate) error) error

func (*Block) SystemID

func (b *Block) SystemID() SystemID

type ClientMetadata

type ClientMetadata struct {
	Timeout           uint64
	MaxTransactionFee uint64
	FeeCreditRecordID []byte
	// contains filtered or unexported fields
}

type GenericChainItem

type GenericChainItem struct {
	Hash []byte
	Left bool
	// contains filtered or unexported fields
}
type Header struct {
	SystemID          SystemID
	ShardID           []byte
	ProposerID        string
	PreviousBlockHash []byte
	// contains filtered or unexported fields
}

func (*Header) Hash

func (h *Header) Hash(algorithm crypto.Hash) []byte

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

type Payload

type Payload struct {
	SystemID       SystemID
	Type           string
	UnitID         UnitID
	Attributes     RawCBOR
	ClientMetadata *ClientMetadata
	// contains filtered or unexported fields
}

func (*Payload) Bytes

func (p *Payload) Bytes() ([]byte, error)

func (*Payload) BytesWithAttributeSigBytes

func (p *Payload) BytesWithAttributeSigBytes(attrs SigBytesProvider) ([]byte, error)

BytesWithAttributeSigBytes TODO: AB-1016 remove this hack

func (*Payload) UnmarshalAttributes

func (p *Payload) UnmarshalAttributes(v any) error

type RawCBOR

type RawCBOR []byte

func (RawCBOR) MarshalCBOR

func (r RawCBOR) MarshalCBOR() ([]byte, error)

MarshalCBOR returns r or CBOR nil if r is nil.

func (*RawCBOR) UnmarshalCBOR

func (r *RawCBOR) UnmarshalCBOR(data []byte) error

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 SigBytesProvider interface {
	SigBytes() ([]byte, error)
}

type SystemID

type SystemID []byte

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) Hash

func (t *TransactionOrder) Hash(algorithm crypto.Hash) []byte

func (*TransactionOrder) PayloadBytes

func (t *TransactionOrder) PayloadBytes() ([]byte, error)

func (*TransactionOrder) PayloadType

func (t *TransactionOrder) PayloadType() string

func (*TransactionOrder) SystemID

func (t *TransactionOrder) SystemID() []byte

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) Hash

func (t *TransactionRecord) Hash(algorithm crypto.Hash) []byte

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

func (p *TxProof) GetUnicityTreeSystemDescriptionHash() []byte

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
)

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) AddToHasher

func (x *UnicityCertificate) AddToHasher(hasher hash.Hash)

func (*UnicityCertificate) Bytes

func (x *UnicityCertificate) Bytes() []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) IsRepeat

func (x *UnicityCertificate) IsRepeat(prevUC *UnicityCertificate) bool

func (*UnicityCertificate) IsValid

func (x *UnicityCertificate) IsValid(verifiers map[string]crypto.Verifier, algorithm gocrypto.Hash, systemIdentifier, systemDescriptionHash []byte) 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           map[string][]byte `json:"signatures,omitempty"`
	// contains filtered or unexported fields
}

func (*UnicitySeal) AddToHasher

func (x *UnicitySeal) AddToHasher(hasher hash.Hash)

func (*UnicitySeal) Bytes

func (x *UnicitySeal) Bytes() []byte

func (*UnicitySeal) IsValid

func (x *UnicitySeal) IsValid(verifiers map[string]crypto.Verifier) error

func (*UnicitySeal) Sign

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

func (*UnicitySeal) Verify

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

type UnicityTreeCertificate

type UnicityTreeCertificate struct {
	SystemIdentifier      SystemID `json:"system_identifier,omitempty"`
	SiblingHashes         [][]byte `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) Bytes

func (x *UnicityTreeCertificate) Bytes() []byte

func (*UnicityTreeCertificate) GetAuthPath

func (x *UnicityTreeCertificate) GetAuthPath(leafHash []byte, hashAlgorithm gocrypto.Hash) ([]byte, error)

func (*UnicityTreeCertificate) IsValid

func (x *UnicityTreeCertificate) IsValid(systemIdentifier, systemDescriptionHash []byte) error

type UnitID

type UnitID []byte

func NewUnitID

func NewUnitID(unitIDLength int, shardPart []byte, unitPart []byte, typePart []byte) UnitID

NewUnitID creates a new UnitID consisting of a shardPart, unitPart and typePart.

func (UnitID) Compare

func (uid UnitID) Compare(key UnitID) int

func (UnitID) Eq

func (uid UnitID) Eq(id UnitID) bool

func (UnitID) HasType

func (uid UnitID) HasType(typePart []byte) bool

func (UnitID) String

func (uid UnitID) String() string

Jump to

Keyboard shortcuts

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