Documentation
¶
Index ¶
- func HashFunc() hash.Hash
- func Verify(root []byte, hash []byte, merkleSig *MerkleSig) bool
- type KeyIterator
- func (prkg *KeyIterator) Deserialize(data []byte) error
- func (prkg *KeyIterator) GobDecode(data []byte) error
- func (prkg KeyIterator) GobEncode() ([]byte, error)
- func (prkg *KeyIterator) Next() (*lmots.PrivateKey, error)
- func (prkg *KeyIterator) Offset() uint32
- func (prkg *KeyIterator) Serialize() ([]byte, error)
- type MerkleAgent
- func (agent *MerkleAgent) GobDecode(data []byte) error
- func (agent *MerkleAgent) GobEncode() ([]byte, error)
- func (agent *MerkleAgent) LeafIdx() uint32
- func (agent *MerkleAgent) Rebuild(data []byte, secret []byte) error
- func (agent *MerkleAgent) Serialize() ([]byte, error)
- func (agent *MerkleAgent) SerializeSecretKey() []byte
- func (agent *MerkleAgent) Traverse()
- type MerkleSig
- type Node
- type TreeHashStack
- func (ths *TreeHashStack) Deserialize(data []byte) error
- func (ths *TreeHashStack) GobDecode(data []byte) error
- func (ths TreeHashStack) GobEncode() ([]byte, error)
- func (th *TreeHashStack) Init(startingLeaf, h uint32) error
- func (th *TreeHashStack) IsCompleted() bool
- func (th *TreeHashStack) LowestTailHeight() uint32
- func (ths *TreeHashStack) Serialize() ([]byte, error)
- func (th *TreeHashStack) SetLeaf(leaf uint32)
- func (th *TreeHashStack) Top() *Node
- func (th *TreeHashStack) Update(I []byte, numOp uint32, nodeHouse [][]byte)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Verify ¶
Verify verifies a Merkle signature
Example ¶
const H = 4 seed := make([]byte, lmots.N) rand.Reader.Read(seed) merkleAgent, err := NewMerkleAgent(H, seed) if nil != err { panic(err) } msg := make([]byte, lmots.N) rand.Reader.Read(msg) // what if no more leaf to use in the Merkle agent _, sig, err := Sign(merkleAgent, msg) if nil != err { panic(err) } fmt.Println(Verify(merkleAgent.Root, msg, sig))
Output: true
Types ¶
type KeyIterator ¶
type KeyIterator struct { // options specifying stuff like nonce for // randomizing hash function *lmots.LMOpts // contains filtered or unexported fields }
KeyIterator is a prkg to produce a key chain for user based on a seed
func NewKeyIterator ¶
func NewKeyIterator(compactSeed []byte) *KeyIterator
NewKeyIterator makes a prkg
func (*KeyIterator) Deserialize ¶
func (prkg *KeyIterator) Deserialize(data []byte) error
Deserialize unmarshals the prkg from gob bytes
func (*KeyIterator) GobDecode ¶
func (prkg *KeyIterator) GobDecode(data []byte) error
GobDecode customizes the Gob decoding scheme for KeyIterator
func (KeyIterator) GobEncode ¶
func (prkg KeyIterator) GobEncode() ([]byte, error)
GobEncode customizes the Gob encoding scheme for KeyIterator
func (*KeyIterator) Next ¶
func (prkg *KeyIterator) Next() (*lmots.PrivateKey, error)
Next estimates and returns the next sk-pk pair
func (*KeyIterator) Offset ¶
func (prkg *KeyIterator) Offset() uint32
Offset returns 0-based index of the **next** key returned by this prkg
func (*KeyIterator) Serialize ¶
func (prkg *KeyIterator) Serialize() ([]byte, error)
Serialize marshals a prkg into gob bytes
type MerkleAgent ¶
MerkleAgent implements a agent working according to the Merkle signature scheme
func NewMerkleAgent ¶
func NewMerkleAgent(H uint32, seed []byte) (*MerkleAgent, error)
NewMerkleAgent makes a fresh Merkle signing routine by running the generate key and setup procedure
func (*MerkleAgent) GobDecode ¶
func (agent *MerkleAgent) GobDecode(data []byte) error
GobDecode customizes the Gob decoding for MerkleAgent
func (*MerkleAgent) GobEncode ¶
func (agent *MerkleAgent) GobEncode() ([]byte, error)
GobEncode customizes the Gob encoding for MerkleAgent
func (*MerkleAgent) LeafIdx ¶
func (agent *MerkleAgent) LeafIdx() uint32
LeafIdx returns the index of next leaf to use
func (*MerkleAgent) Rebuild ¶
func (agent *MerkleAgent) Rebuild(data []byte, secret []byte) error
Rebuild restores the merkle agent from serialized bytes and secret bytes
func (*MerkleAgent) Serialize ¶
func (agent *MerkleAgent) Serialize() ([]byte, error)
Serialize encodes all the information about the merkle tree that can be stored as plaintext
func (*MerkleAgent) SerializeSecretKey ¶
func (agent *MerkleAgent) SerializeSecretKey() []byte
SerializeSecretKey encodes all the secret data which shall be encrypted
func (*MerkleAgent) Traverse ¶
func (agent *MerkleAgent) Traverse()
Traverse updates both auth path and retained stack for next use
type MerkleSig ¶
MerkleSig is the container for the signature generated according to LMS
func Sign ¶
func Sign(agent *MerkleAgent, hash []byte) (*lmots.PrivateKey, *MerkleSig, error)
Sign produces a Merkle signature
func (*MerkleSig) Deserialize ¶
Deserialize unmarshals the MerkleSig from gob bytes
type TreeHashStack ¶
type TreeHashStack struct {
// contains filtered or unexported fields
}
TreeHashStack is a stack tracing the running state of the tree hash algo
func NewTreeHashStack ¶
func NewTreeHashStack(startingLeaf, h uint32) *TreeHashStack
NewTreeHashStack makes a new tree hash instance
func (*TreeHashStack) Deserialize ¶
func (ths *TreeHashStack) Deserialize(data []byte) error
Deserialize unmarshals the TreeHashStack from the Gob bytes
func (*TreeHashStack) GobDecode ¶
func (ths *TreeHashStack) GobDecode(data []byte) error
GobDecode customizes the Gob decoding scheme for TreeHashStack
func (TreeHashStack) GobEncode ¶
func (ths TreeHashStack) GobEncode() ([]byte, error)
GobEncode customizes the Gob encoding scheme for TreeHashStack
func (*TreeHashStack) Init ¶
func (th *TreeHashStack) Init(startingLeaf, h uint32) error
Init initializes the tree hash instance to target specific height and the range of leaves
func (*TreeHashStack) IsCompleted ¶
func (th *TreeHashStack) IsCompleted() bool
IsCompleted checks if the tree hash instance has completed
func (*TreeHashStack) LowestTailHeight ¶
func (th *TreeHashStack) LowestTailHeight() uint32
LowestTailHeight returns the lowest height of tail nodes in this tree hash instance
func (*TreeHashStack) Serialize ¶
func (ths *TreeHashStack) Serialize() ([]byte, error)
Serialize marshals the TreeHashStack as Gob bytes
func (*TreeHashStack) SetLeaf ¶
func (th *TreeHashStack) SetLeaf(leaf uint32)
SetLeaf updates the leaf index
func (*TreeHashStack) Top ¶
func (th *TreeHashStack) Top() *Node
Top returns the node in the top of the stack