post

package
v0.0.0-...-a9f2047 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	K  = 256 // this needs to match the output size of Hx() - when sha256() is used
	W  = K   // merkle tree label length in bits
	WB = 32  // W length in bytes
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Identifier

type Identifier string // A Variable-length binary string. e.g. "0011010" Only 0s and 1s are allowed chars.

type Label

type Label []byte // label is WB bytes long binary data

type Labels

type Labels []Label // an ordered list of Labels

type MemoryStore

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

a simple in-ram post data store implementing StoreReader

func (*MemoryStore) Close

func (ms *MemoryStore) Close() error

func (*MemoryStore) FileName

func (ms *MemoryStore) FileName() string

func (*MemoryStore) Read

func (ms *MemoryStore) Read(idx uint64) (bitarray.BitArray, error)

func (*MemoryStore) ReadBytes

func (ms *MemoryStore) ReadBytes(idx uint64) ([]byte, error)

read from index idx and return as []byte

func (*MemoryStore) ReadUint64

func (ms *MemoryStore) ReadUint64(idx uint64) (uint64, error)

type MerkleProof

type MerkleProof []Node

type MerkleProofs

type MerkleProofs []MerkleProof

type MerkleTreeReader

type MerkleTreeReader interface {
	ReadProof(id Identifier) (MerkleProof, error) // Returns the path from a node identified by id to the root node
	ReadProofs(indices []*big.Int) (MerkleProofs, error)
	Close() error
}

func NewMerkleTreeReader

func NewMerkleTreeReader(psr StoreReader, fileName string, l uint, n uint, h hashing.HashFunc) (MerkleTreeReader, error)

n - merkle tree size = 2^n

type MerkleTreeWriter

type MerkleTreeWriter interface {
	Write() ([]byte, error)
}

func NewMerkleTreeWriter

func NewMerkleTreeWriter(psr StoreReader, fileName string, l uint, n uint,
	h hashing.HashFunc) (MerkleTreeWriter, error)

n - store length. T = 2^n

type Node

type Node struct {
	Id    Identifier
	Label Label
}

type StoreReader

type StoreReader interface {
	Read(idx uint64) (bitarray.BitArray, error)
	ReadUint64(idx uint64) (uint64, error)
	ReadBytes(idx uint64) ([]byte, error)
	Close() error
	FileName() string
}

StoreReader is a random access reader capable of reading data from any valid bit offset

func NewMemoryStoreReader

func NewMemoryStoreReader(data []uint64) StoreReader

func NewStoreReader

func NewStoreReader(filePath string, n uint) (StoreReader, error)

type StoreWriter

type StoreWriter interface {
	Write(r uint64, n byte) error
	WriteBool(b bool) error
	Close() error
	FileName() string
}

StoreWriter is a serial writer that appends data to the file

func NewStoreWriter

func NewStoreWriter(filePath string, n uint) (StoreWriter, error)

type Table

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

func NewTable

func NewTable(id []byte, n uint64, l uint, h hashing.HashFunc, filePath string) (*Table, error)

Create a new prover with commitment X and param n:= 9 <= n <= 63 l:= 1 <= l <= 63

func (*Table) Generate

func (t *Table) Generate(returnData bool) ([]uint64, error)

func (*Table) Store

func (t *Table) Store(merkleFilePath string) ([]byte, error)

Implements the Store phase of rpost (page 9) Stores the data and the merkle tree

type TreeStoreReader

type TreeStoreReader interface {
	Read(id Identifier) (Label, error)
	Size() uint64
	Close() error
}

A simple (k,v) reader - fully supports random access

func NewTreeStoreReader

func NewTreeStoreReader(fileName string, n uint) (TreeStoreReader, error)

type TreeStoreWriter

type TreeStoreWriter interface {
	Write(id Identifier, l Label)
	IsLabelInStore(id Identifier) (bool, error)
	Reset() error
	Delete() error
	Size() uint64
	Finalize()    // finalize writing w/o closing the file
	Close() error // finalize and close
}

A simple store writer Labels must be written in depth-first order. Random access is not supported

func NewTreeStoreWriter

func NewTreeStoreWriter(fileName string, n uint) (TreeStoreWriter, error)

n - binary tree height

Jump to

Keyboard shortcuts

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