Documentation
¶
Index ¶
- Variables
- func BinaryIDListEqual(b1 []*BinaryID, b2 []*BinaryID) bool
- func ComputeLabel(node *BinaryID, cOpts *ComputeOpts) []byte
- func DebugOutput()
- func DebugSupress()
- func Index(b *BinaryID, dag_n int) (index int)
- func PrintDAG(b *BinaryID, dag_n int, store StorageIO, pre string)
- func StringList(bList []*BinaryID) string
- func TreeSize(b *BinaryID, dag_n int) (size int)
- type BinaryID
- func CalcNIPChallenge(rootHash []byte, cOpts *ComputeOpts) (b_list []*BinaryID)
- func CheckAndAdd(BinIDs []*BinaryID, BinID *BinaryID) ([]*BinaryID, bool)
- func GammaToBinaryIDs(gamma []byte, dag_n int) ([]*BinaryID, error)
- func GetParents(node *BinaryID, dag_n int) ([]*BinaryID, error)
- func NewBinaryID(val uint, length int) (*BinaryID, error)
- func NewBinaryIDBytes(v []byte) *BinaryID
- func NewBinaryIDCopy(b *BinaryID) (b2 *BinaryID)
- func NewBinaryIDInt(val uint) *BinaryID
- func Siblings(node *BinaryID, left bool) ([]*BinaryID, error)
- func (b *BinaryID) AddBit(n int) error
- func (b *BinaryID) Encode() (v []byte)
- func (b *BinaryID) Equal(b2 *BinaryID) bool
- func (b *BinaryID) FlipBit(n int)
- func (b *BinaryID) GetBit(n int) (int, error)
- func (b *BinaryID) GreaterThan(b2 *BinaryID) bool
- func (b *BinaryID) String() string
- func (b *BinaryID) TruncateLastBit()
- type ComputeOpts
- type FileIO
- type HashFunc
- type Hasher
- type Prover
- func (p *Prover) CalcChallengeProof(gamma []byte) error
- func (p *Prover) CalcCommitProof(commitment []byte) error
- func (p *Prover) CalcNIPCommitProof() error
- func (p *Prover) ChallengeProof() (b [][]byte, err error)
- func (p *Prover) ChangeDAGSize(size int)
- func (p *Prover) ChangeHashFunc(hfunc HashFunc)
- func (p *Prover) ChangeT(t uint)
- func (p *Prover) Clean()
- func (p *Prover) CommitProof() (b []byte, err error)
- func (p *Prover) ShowDAG()
- type SetDAGSizer
- type StorageIO
Constants ¶
This section is empty.
Variables ¶
var (
HashSize = *flag.Int("Hash_Size_Bytes", 32, "Set the hash size") // TODO: Set Dynamically based on hash library
)
Functions ¶
func BinaryIDListEqual ¶
func ComputeLabel ¶
func ComputeLabel(node *BinaryID, cOpts *ComputeOpts) []byte
ComputeLabel of a node id
func DebugOutput ¶
func DebugOutput()
func DebugSupress ¶
func DebugSupress()
func StringList ¶
Pretty printing function for a list of BinaryID's. Primarily for Debugging
Types ¶
type BinaryID ¶
BinaryID is a binary representation of the ID of a node. The length is needed because we need to identify between 0 and 00 for example. Note: added json Marshalling. Currently, encoding is base64 (for []byte). This is default for []byte in Go, but can change as needed.
func CalcNIPChallenge ¶
func CalcNIPChallenge(rootHash []byte, cOpts *ComputeOpts) (b_list []*BinaryID)
func CheckAndAdd ¶
CheckAndAdd checks if the BinID is already in the list then adds it if it wasn't already there. Also returns true if the BinID was added to the list.
func GetParents ¶
GetParents get parents of a node
func NewBinaryIDBytes ¶
func NewBinaryIDCopy ¶
func NewBinaryIDInt ¶
func Siblings ¶
Siblings returns the list of siblings along the path to the root
Takes in an instance of class BinaryString and returns a list of the siblings of the nodes of the path to to root of a binary tree. Also returns the node itself, so there are N+1 items in the list for a tree with length N.
func (*BinaryID) GetBit ¶
Returns if n'th bit is 0 or 1. Error if n > Length n'th bit from the left. So for 1011 the 1'st bit is the first 1 on the left
func (*BinaryID) GreaterThan ¶
func (*BinaryID) TruncateLastBit ¶
func (b *BinaryID) TruncateLastBit()
type ComputeOpts ¶
type FileIO ¶
type FileIO struct {
// contains filtered or unexported fields
}
func (*FileIO) SetDAGSize ¶
type Prover ¶
type Prover struct {
// contains filtered or unexported fields
}
This type will provide the inteface to the Prover. It implements the io.ReadWriter interface, which will allow it to sit behind an RPC Server or be linked directly to a verifier. CurrentState is used to
func (*Prover) CalcChallengeProof ¶
CalcChallengeProof
func (*Prover) CalcCommitProof ¶
CalcCommitProof calculates the proof of seqeuntial work
func (*Prover) CalcNIPCommitProof ¶
CalcNIPCommitProof proof created by computing openH for the challenge TODO: modify so that each Hx(phi, i) is used to calc challenge (first n bits)
func (*Prover) ChallengeProof ¶
SendChallengeProof
func (*Prover) ChangeDAGSize ¶
Can only call this before the DAG has started to be calculated. Need to add a flag and check for this. TODO: might be cleaner to have n as a field in the Prover struct. Also would need to have it as a field in BinaryID as well in that case.
func (*Prover) ChangeHashFunc ¶
func (*Prover) CommitProof ¶
CommitProof returns phi (root Hash)
type SetDAGSizer ¶
type SetDAGSizer interface {
SetDAGSize(size int)
}
Some storageIO implementations need to know about the DAG Size (n) Calls to change DAG size will check if the storageIO can change DAG size then will forward call this interface function.