diff options
Diffstat (limited to 'crypto.h')
-rw-r--r-- | crypto.h | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -17,6 +17,29 @@ struct iomt_node { hash_t val; /* all zero indicates placeholder */ }; +struct iomt { + int mt_leafcount, mt_logleaves; /* mt_logleaves must equal 2^mt_leafcount */ + + /* Each level of the IOMT is stored sequentially from left to + * right, top to bottom, as follows: + * + * [0]: root + * [1]: root left child + * [2]: root right child + * [3]: left child of [1] + * [4]: right child of [1] + * [5]: left child of [2] + * [6]: right child of [2], + * + * and so on. + */ + hash_t *mt_nodes; /* this has 2 * mt_leafcount - 1 elements. Note + * that the bottom level consists of hashes of + * the leaf nodes. */ + + struct iomt_node *mt_leaves; +}; + /* guaranteed to be zero */ static const struct hash_t hash_null = { { 0 } }; @@ -52,6 +75,19 @@ int *merkle_complement_ordersonly(int leafidx, int logleaves); * given leaf node. Will be ordered from nearest relative to root. */ int *merkle_dependents(int leafidx, int logleaves); +hash_t *lookup_nodes(const hash_t *nodes, const int *indices, int n); +void restore_nodes(hash_t *nodes, const int *indices, const hash_t *values, int n); + +/* IOMT: */ +struct iomt *iomt_new(int logleaves); + +/* This function is prefixed merkle_ because it does not know about + * any IOMT-specific properties (though it is still passed an iomt + * struct) */ +void merkle_update(struct iomt *tree, uint64_t leafidx, hash_t newval, hash_t **old_dep); + +void iomt_fill(struct iomt *tree); + int bintree_parent(int idx); int bintree_sibling(int idx); |