Documentation ¶
Index ¶
- func Hash(text string) string
- func HashStringToBytes(hash string) []byte
- func MHash(h1 string, h2 string) string
- func ToHex(buf []byte) string
- func VerifyMerklePath(hash string, path *MTPath, root string) bool
- type GetRequest
- type GetResponse
- type Hashable
- type MTPath
- type MerkleTree
- func (mt *MerkleTree) ComputeTree(hashes []Hashable)
- func (mt *MerkleTree) GetLeafIndex(hash Hashable) int
- func (mt *MerkleTree) GetPath(hash Hashable) *MTPath
- func (mt *MerkleTree) GetPathByIndex(idx int) *MTPath
- func (mt *MerkleTree) GetRoot() string
- func (mt *MerkleTree) GetTree() []string
- func (mt *MerkleTree) SetTree(leavesCount int, tree []string) error
- func (mt *MerkleTree) VerifyPath(hash Hashable, path *MTPath) bool
- type MerkleTreeI
- type PostRequest
- type PostResponse
- type SecureSerializableValue
- type SecureSerializableValueI
- type Serializable
- type StringHashable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashStringToBytes ¶
HashStringToBytes - convert a hex hash string to bytes
Types ¶
type GetRequest ¶
type GetRequest struct {
*PostRequest
}
func NewHTTPGetRequest ¶
func NewHTTPGetRequest(url string) (*GetRequest, error)
func (*GetRequest) Get ¶
func (r *GetRequest) Get() (*GetResponse, error)
type GetResponse ¶
type GetResponse struct {
*PostResponse
}
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
MerkleTree - A data structure that implements MerkleTreeI interface
func (*MerkleTree) ComputeTree ¶
func (mt *MerkleTree) ComputeTree(hashes []Hashable)
ComputeTree - given the leaf nodes, compute the merkle tree
func (*MerkleTree) GetLeafIndex ¶
func (mt *MerkleTree) GetLeafIndex(hash Hashable) int
GetLeafIndex - Get the index of the leaf node in the tree
func (*MerkleTree) GetPath ¶
func (mt *MerkleTree) GetPath(hash Hashable) *MTPath
GetPath - get the path that can be used to verify the merkle tree
func (*MerkleTree) GetPathByIndex ¶
func (mt *MerkleTree) GetPathByIndex(idx int) *MTPath
GetPathByIndex - get the path of a leaf node at index i
func (*MerkleTree) GetRoot ¶
func (mt *MerkleTree) GetRoot() string
GetRoot - get the root of the merkle tree
func (*MerkleTree) GetTree ¶
func (mt *MerkleTree) GetTree() []string
GetTree - get the entire merkle tree
func (*MerkleTree) SetTree ¶
func (mt *MerkleTree) SetTree(leavesCount int, tree []string) error
SetTree - set the entire merkle tree
func (*MerkleTree) VerifyPath ¶
func (mt *MerkleTree) VerifyPath(hash Hashable, path *MTPath) bool
VerifyPath - given a leaf node and the path, verify that the node is part of the tree
type MerkleTreeI ¶
type MerkleTreeI interface { //API to create a tree from leaf nodes ComputeTree(hashes []Hashable) GetRoot() string GetTree() []string //API to load an existing tree SetTree(leavesCount int, tree []string) error // API for verification when the leaf node is known GetPath(hash Hashable) *MTPath // Server needs to provide this VerifyPath(hash Hashable, path *MTPath) bool //This is only required by a client but useful for testing /* API for random verification when the leaf node is uknown (verification of the data to hash used as leaf node is outside this API) */ GetPathByIndex(idx int) *MTPath }
MerkleTreeI - a merkle tree interface required for constructing and providing verification
type PostRequest ¶
type PostRequest struct {
// contains filtered or unexported fields
}
func NewHTTPPostRequest ¶
func NewHTTPPostRequest(url string, data interface{}) (*PostRequest, error)
func (*PostRequest) Post ¶
func (r *PostRequest) Post() (*PostResponse, error)
type PostResponse ¶
type SecureSerializableValue ¶
type SecureSerializableValue struct {
Buffer []byte
}
SecureSerializableValue - a proxy persisted value that just tracks the encoded bytes of a persisted value
func (*SecureSerializableValue) Decode ¶
func (spv *SecureSerializableValue) Decode(buf []byte) error
Decode - implement interface
func (*SecureSerializableValue) Encode ¶
func (spv *SecureSerializableValue) Encode() []byte
Encode - implement interface
func (*SecureSerializableValue) GetHash ¶
func (spv *SecureSerializableValue) GetHash() string
GetHash - implement interface
func (*SecureSerializableValue) GetHashBytes ¶
func (spv *SecureSerializableValue) GetHashBytes() []byte
GetHashBytes - implement interface
type SecureSerializableValueI ¶
type SecureSerializableValueI interface { Serializable Hashable }
SecureSerializableValueI an interface that makes a serializable value secure with hashing
type Serializable ¶
Serializable interface
type StringHashable ¶
type StringHashable struct {
Hash string
}
func NewStringHashable ¶
func NewStringHashable(hash string) *StringHashable
func (*StringHashable) GetHash ¶
func (sh *StringHashable) GetHash() string
func (*StringHashable) GetHashBytes ¶
func (sh *StringHashable) GetHashBytes() []byte