Minor change removing a duplicated check of `h_digest==pubkey_com`at
`src/dsa/rpo_falcon512/signature.rs#L100`, which is already done at
`src/dsa/rpo_falcon512/signature.rs#L95`.
* merkle: add parent() helper function on NodeIndex
* smt: add pairs_to_leaf() to trait
* smt: add sorted_pairs_to_leaves() and test for it
* smt: implement single subtree-8 hashing, w/ benchmarks & tests
This will be composed into depth-8-subtree-based computation of entire
sparse Merkle trees.
* merkle: add a benchmark for constructing 256-balanced trees
This is intended for comparison with the benchmarks from the previous
commit. This benchmark represents the theoretical perfect-efficiency
performance we could possibly (but impractically) get for computing
depth-8 sparse Merkle subtrees.
* smt: test that SparseMerkleTree::build_subtree() is composable
* smt: test that subtree logic can correctly construct an entire tree
This commit ensures that `SparseMerkleTree::build_subtree()` can
correctly compose into building an entire sparse Merkle tree, without
yet getting into potential complications concurrency introduces.
* smt: implement test for basic parallelized subtree computation w/ rayon
Building on the previous commit, this commit implements a test proving
that `SparseMerkleTree::build_subtree()` can be composed into itself not
just concurrently, but in parallel, without issue.
* smt: add from_raw_parts() to trait interface
This commit adds a new required method to the SparseMerkleTree trait,
to allow generic construction from pre-computed parts.
This will be used to add a generic version of `with_entries()` in a
later commit.
* smt: add parallel constructors to Smt and SimpleSmt
What the previous few commits have been leading up to: SparseMerkleTree
now has a function to construct the tree from existing data in parallel.
This is significantly faster than the singlethreaded equivalent.
Benchmarks incoming!
---------
Co-authored-by: krushimir <krushimir@reilabs.co>
Co-authored-by: krushimir <kresimir.grofelnik@reilabs.io>
* feat(smt): impl constructing leaves that don't yet exist
This commit implements 'prospective leaf construction' -- computing
sparse Merkle tree leaves for a key-value insertion without actually
performing that insertion.
For SimpleSmt, this is trivial, since the leaf type is simply the value
being inserted.
For the full Smt, the new leaf payload depends on the existing payload
in that leaf. Since almost all leaves are very small, we can just clone
the leaf and modify a copy.
This will allow us to perform more general prospective changes on Merkle
trees.
* feat(smt): export get_value() in the trait
* feat(smt): implement generic prospective insertions
This commit adds two methods to SparseMerkleTree: compute_mutations()
and apply_mutations(), which respectively create and consume a new
MutationSet type. This type represents as set of changes to a
SparseMerkleTree that haven't happened yet, and can be queried on to
ensure a set of insertions result in the correct tree root before
finalizing and committing the mutation.
This is a direct step towards issue 222, and will directly enable
removing Merkle tree clones in miden-node InnerState::apply_block().
As part of this change, SparseMerkleTree now requires its Key to be Ord
and its Leaf to be Clone (both bounds which were already met by existing
implementations). The Ord bound could instead be changed to Eq + Hash,
if MutationSet were changed to use a HashMap instead of a BTreeMap.
* chore(smt): refactor empty node construction to helper function