Imperative wrapper of MerkleTree
This module contains an imperative wrapper of the functional API provided by MerkleTree
.
This makes common usage pattern around these trees more convenient.
This module defines two types:
The Store
. This is meant to be your canister's single hash tree. It is separated
from the class providing functions so that it can be put in stable memory:
The Ops
class. This wraps such a Store
and offers all the operations you expect.
So this is the suggested idiom:
stable let cert_store : CertTree.Store = CertTree.newStore();
let ct = CertTree.Ops(cert_store);
Dyadic intervals
This module is mostly internal to MerkleTree
. It is a separate module mainly to expose
its code for the test suite without polluting the MerkleTree
interface.
A merkle tree
This library provides a simple merkle tree data structure for Motoko. It provides a key-value store, where both keys and values are of type Blob.
var t = MerkleTree.empty();
t := MerkleTree.put(t, "Alice", "\00\01");
t := MerkleTree.put(t, "Bob", "\00\02");
let w = MerkleTree.reveals(t, ["Alice" : Blob, "Malfoy": Blob].vals());
will produce
#fork (#labeled ("\3B…\43", #leaf("\00\01")), #pruned ("\EB…\87"))
#fork(#labeled("\41\6C\69\63\65", #leaf("\00\01")), #labeled("\42\6F\62", #pruned("\E6…\E2")))
The witness format is compatible with the HashTree used by the Internet Computer, so client-side, the same verification logic can be used.
Revealing multiple keys at once is supported, and so is proving absence of a key.
The tree branches on the bits of the keys (i.e. a patricia tree). This means that the merkle tree and thus the root hash is unique for a given tree. This in particular means that insertions are efficient, and that the tree can be reconstructed from the data, independently of the insertion order.
A functional API is provided (instead of an object-oriented one), so that the actual tree can easily be stored in stable memory.
Internet Computer Request Data
This library provides functionality for the data structures encountered when interacting with the Internet Computer, in particular its HTTP API, certificates and canister signatures.
This contains the generic functionality: A data type R
for such values,
CBOR encoding (encodeCBOR
) and the “[Representation-independent hash[” (hash
).
Internet Computer Canister Signatures
This modules allows canister to produce signatures according to the “Canister Signature scheme”.