core

package
v0.0.0-...-ab61f1e Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUID  string = "state"
	CEUID string = "codeexec"
)
View Source
const (
	OPCODE    string = "OPCODE"
	KEYVALUE  string = "KEYVALUE"
	PRECOMMIT string = "PRECOMMIT"
	CONST     string = "CONST"
)

Variables

This section is empty.

Functions

func PrepareKVDicts

func PrepareKVDicts(r *ExecutionRequest, proofs map[string]*StateProof) (map[string]KVDict, error)

Types

type Contract

type Contract struct {
	Workflows map[string]*Workflow `json:"workflows"`
	DFUs      []string             `json:"dfus"`
}

type ContractHeader

type ContractHeader struct {
	CID       byzcoin.InstanceID
	CodeHash  []byte
	Lock      bool
	CurrState string
}

type ContractRaw

type ContractRaw struct {
	CID      byzcoin.InstanceID
	Contract *Contract
	FSM      *FSM
}

type DFU

type DFU struct {
	NumNodes  int           `json:"num_nodes"`
	Threshold int           `json:"threshold"`
	Opcodes   []string      `json:"opcodes"`
	Keys      []kyber.Point `json:",omitempty"`
}

type DFUIdentity

type DFUIdentity struct {
	Threshold int
	Keys      []kyber.Point
}

type DFURegistry

type DFURegistry struct {
	Units map[string]*DFU `json:"registry"`
}

type DataDependency

type DataDependency struct {
	Src     string      `json:"src"`
	SrcName string      `json:"src_name,omitempty"`
	Idx     int         `json:"idx,omitempty"`
	Value   interface{} `json:"value,omitempty"`
	// This is a terrible hack but the only quick way I could think of to
	//make it work with protobuf.
	//DataDependency is serialized as part of sending the contract
	//data to the state unit. However,
	//protobuf does not like the interface{} type. Therefore,
	//after reading in the JSON files,
	//we check the type of Value; assign its value to one of the following
	//variables; and set Value to nil.
	StringValue string
	UintValue   uint64
}

type ExecutionPlan

type ExecutionPlan struct {
	CID       []byte
	StateRoot []byte
	CodeHash  []byte
	WfName    string
	TxnName   string
	Txn       *Transaction
	DFUData   map[string]*DFUIdentity
	Sig       bdnproto.BdnSignature
}

func (*ExecutionPlan) Hash

func (p *ExecutionPlan) Hash() []byte

func (*ExecutionPlan) String

func (p *ExecutionPlan) String() string

type ExecutionRequest

type ExecutionRequest struct {
	Index      int
	EP         *ExecutionPlan
	OpReceipts map[string]*OpcodeReceipt
}

func (*ExecutionRequest) Verify

func (r *ExecutionRequest) Verify(data *VerificationData) error

type FSM

type FSM struct {
	InitialState string                 `json:"initial_state"`
	States       []string               `json:"states"`
	Transitions  map[string]*Transition `json:"transitions"`
}

type KV

type KV struct {
	Key   string
	Value []byte
}

type KVDict

type KVDict struct {
	Data map[string][]byte
}

type Opcode

type Opcode struct {
	Name         string                     `json:"name"`
	DFUID        string                     `json:"dfu_id"`
	Dependencies map[string]*DataDependency `json:"inputs,omitempty"`
}

type OpcodeReceipt

type OpcodeReceipt struct {
	EPID  []byte // Hash of the execution plan
	OpIdx int
	//OpName string
	// Name of the output variable
	Name string
	// hash = H(output)
	HashBytes []byte
	Sig       bdnproto.BdnSignature
}

func (*OpcodeReceipt) Hash

func (r *OpcodeReceipt) Hash() []byte

type StateProof

type StateProof struct {
	Proof   *byzcoin.Proof
	Genesis *skipchain.SkipBlock
}

func (StateProof) VerifyFromBlock

func (p StateProof) VerifyFromBlock(publics []kyber.Point) error

VerifyFromBlock takes a skipchain id and the first block of the proof. It verifies that the proof is valid for this skipchain. It verifies the proof, that the merkle-root is stored in the skipblock of the proof and the fact that the skipblock is indeed part of the skipchain. It also uses the provided block to insure the first roster is correct. If all verifications are correct, the error will be nil. It does not verify wether a certain key/value pair exists in the proof. func (p StateProof) VerifyFromBlock(verifiedBlock *skipchain.SkipBlock, publics []kyber.Point) error {

type Storage

type Storage struct {
	Store []KV
}

Storage holds the contract state. Store[0] stores the raw contract data, and Store[1] stores the contract header. (i.e. Store[0].Key == "raw", Store[1].Key == "header"). The stored value is a protobuf-encoded core.ContractRaw and core.ContractHeader struct.

type Transaction

type Transaction struct {
	Opcodes []*Opcode `json:"opcodes"`
}

type Transition

type Transition struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type VerificationData

type VerificationData struct {
	UID        string
	OpcodeName string
	CodeHash   []byte
	// key: input variable, value: H(output) from parent opcode.
	InputHashes map[string][]byte
	StateProofs map[string]*StateProof
	Precommits  *KVDict
}

type Workflow

type Workflow struct {
	Txns map[string]*Transaction `json:"txns"`
}

Jump to

Keyboard shortcuts

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