game

package
v0.0.0-...-39e0754 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BothWin = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DiskBackedMerkleTreeStorage

type DiskBackedMerkleTreeStorage interface {
	KVMerkleTreeStorage
	Commit()
	Close()
	GetDegree() int
	StoreDegree(d int)
}

type GetMountainRange

type GetMountainRange struct{}

type Hash

type Hash [32]byte

type InMemoryMerkleTreeStorage

type InMemoryMerkleTreeStorage struct {
	// contains filtered or unexported fields
}

a read-only merkle tree stored in the memory

func NewInMemoryMerkleTreeStorage

func NewInMemoryMerkleTreeStorage() *InMemoryMerkleTreeStorage

type KVMerkleTree

type KVMerkleTree struct {
	KVMerkleTreeStorage
	// contains filtered or unexported fields
}

func (*KVMerkleTree) GetChildren

func (m *KVMerkleTree) GetChildren(node Hash) []Hash

func (*KVMerkleTree) GetData

func (m *KVMerkleTree) GetData(node Hash) []byte

func (*KVMerkleTree) GetPrevSibling

func (m *KVMerkleTree) GetPrevSibling(node Hash) Hash

func (*KVMerkleTree) GetProof

func (m *KVMerkleTree) GetProof(node Hash) []Hash

func (*KVMerkleTree) GetRoots

func (m *KVMerkleTree) GetRoots() []Hash

func (*KVMerkleTree) GetSubtreeSize

func (m *KVMerkleTree) GetSubtreeSize(node Hash) int

func (*KVMerkleTree) IsLeaf

func (m *KVMerkleTree) IsLeaf(node Hash) bool

type KVMerkleTreeStorage

type KVMerkleTreeStorage interface {
	// contains filtered or unexported methods
}

type MerkleHasher

type MerkleHasher interface {
	HashData(data []byte) Hash
	ComputeParent(children []Hash) Hash
	CheckProof(leafData []byte, proof []Hash, roots ...Hash) bool
}

type MerkleTree

type MerkleTree interface {
	GetSubtreeSize(node Hash) int
	GetRoots() []Hash
	GetChildren(node Hash) []Hash
	GetProof(node Hash) []Hash
	IsLeaf(node Hash) bool
	GetData(node Hash) []byte
	GetPrevSibling(node Hash) Hash // returns 0 if nonexistent
}

type MerkleTreeDataGenerator

type MerkleTreeDataGenerator func(int) []byte

type Message

type Message interface{}

type MountainRange

type MountainRange struct {
	Roots []Hash
	Sizes []int
}

type NestedLedger

type NestedLedger struct{}

type NextChildren

type NextChildren struct {
	Hashes []Hash
}

type OpenNext

type OpenNext struct {
	Index int
}

type PogrebMerkleTreeStorage

type PogrebMerkleTreeStorage struct {
	// contains filtered or unexported fields
}

func NewPogrebMerkleTreeStorage

func NewPogrebMerkleTreeStorage(path string) *PogrebMerkleTreeStorage

func (*PogrebMerkleTreeStorage) Close

func (s *PogrebMerkleTreeStorage) Close()

func (*PogrebMerkleTreeStorage) Commit

func (s *PogrebMerkleTreeStorage) Commit()

func (*PogrebMerkleTreeStorage) GetDegree

func (s *PogrebMerkleTreeStorage) GetDegree() int

func (*PogrebMerkleTreeStorage) StoreDegree

func (s *PogrebMerkleTreeStorage) StoreDegree(d int)

type SHA256Hasher

type SHA256Hasher struct {
	// contains filtered or unexported fields
}

func NewSHA256Hasher

func NewSHA256Hasher(dim int) *SHA256Hasher

func (*SHA256Hasher) CheckProof

func (m *SHA256Hasher) CheckProof(leafData []byte, proof []Hash, roots ...Hash) bool

func (*SHA256Hasher) ComputeParent

func (h *SHA256Hasher) ComputeParent(children []Hash) Hash

func (*SHA256Hasher) HashData

func (h *SHA256Hasher) HashData(data []byte) Hash

type Session

type Session struct {
	Tree MerkleTree
	I    <-chan Message
	O    chan<- Message
	// contains filtered or unexported fields
}

func (*Session) Run

func (s *Session) Run()

type StartRoot

type StartRoot struct {
	Index int
}

type StateTransition

type StateTransition struct {
	From      []byte // from contains the prev state
	FromProof []Hash
	To        []byte // to contains the current state, and the tx that causes the transition
}

type Terminate

type Terminate struct{}

type Verifier

type Verifier struct {
	To   []chan<- Message
	From []<-chan Message

	Dim int
	MerkleHasher
}

Verifier implements the light client.

func (*Verifier) Match

func (v *Verifier) Match(cidx, pidx int, pmr MountainRange) int

Match runs a match between a challenger and a prover. It takes the indices of the two parties, and the mountain range reported by the prover, which should have a shorter ledger than the challenger. It returns the index of the winner.

func (*Verifier) Run

func (v *Verifier) Run() (MountainRange, int)

Jump to

Keyboard shortcuts

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