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 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) 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 ¶
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
}
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
Click to show internal directories.
Click to hide internal directories.