Commit graph

27 commits

Author SHA1 Message Date
bfd64810b4 smt: add from_raw_parts() to trait interface 2024-11-13 14:47:06 -07:00
6a0721b57d implement test_multithreaded_subtree 2024-11-13 14:47:06 -07:00
5de20ade48 convert test_singlethreaded_subtree to use SubtreeLeavesIter 2024-11-13 14:47:05 -07:00
3274990951 smt: make with_entries() a trait method 2024-11-13 14:43:39 -07:00
a14e67bf2a SubtreeLeaf::from_smt_leaf() was only used in tests 2024-11-13 14:43:39 -07:00
aa3197fcc1 cleanup test_singlethreaded_subtrees a bit 2024-11-13 14:43:38 -07:00
1c5fc8a830 add SubtreeLeavesIter 2024-11-13 14:41:30 -07:00
60f4dd2161 factor out subtree-append logic 2024-11-13 14:41:29 -07:00
2b04a93a15 rename PrecomputedSubtrees -> PairComputations 2024-11-13 14:37:19 -07:00
49d88600c0 make PrecomputedSubtrees more generic 2024-11-13 14:34:07 -07:00
74ab46ca69 working test_singlethreaded_subtrees() 2024-11-13 14:32:22 -07:00
47e1650a40 refactor sorted_pairs_to_leaves() to also group subtrees 2024-11-13 14:27:09 -07:00
6db08f4714 add test_two_subtrees() test 2024-11-13 14:01:00 -07:00
1bc790586a refactor test_build_subtree_from_leaves() 2024-11-13 13:59:50 -07:00
98e5e0a5b2 WIP(smt): impl simple subtree8 hashing and benchmarks for it
bench(smt-subtree): add a benchmark for single-leaf subtrees

make build_subtree also return the next leaf row

convert (col, hash) tuples to a dedicated struct
2024-11-13 13:59:50 -07:00
520fecaf65 add sorted_pairs_to_leaves() and test for it 2024-11-13 13:59:41 -07:00
8283ec5c30 smt: add pairs_to_leaf() to trait 2024-11-13 13:35:57 -07:00
Andrey Khmuro
940cc04670
feat: add Smt::is_empty (#337) 2024-10-17 14:27:50 -07:00
Qyriad
ae807a47ae
feat: implement transactional Smt insertion (#327)
* 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
2024-09-11 16:49:57 -07:00
Paul-Henry Kajfasz
ad0f472708
Updated Makefile and Readme 2024-08-16 15:07:27 -07:00
Paul Schoenfelder
999a64fca6 chore: handle deprecations in winterfell 0.8.3 release 2024-03-17 16:18:23 -04:00
Augusto Hack
dbab0e9aa9
fix: clippy warnings (#280) 2024-02-21 20:55:02 -08:00
Philippe Laferrière
a9475b2a2d reexport (#273) 2024-02-14 11:52:40 -08:00
Philippe Laferrière
e55b3ed2ce Introduce SmtProof (#270)
* add conversion for `SmtLeaf`

* introduce `SmtProof` scaffolding

* implement `verify_membership()`

* SmtLeaf: knows its index

* `SmtLeaf::index`

* `SmtLeaf::get_value()` returns an Option

* fix `verify_membership()`

* impl `SmtProof::get`

* impl `into_parts()`

* `SmtProof::compute_root`

* use `SmtProof` in `Smt::open`

* `SmtLeaf` constructors

* Vec

* impl `Error` for `SmtLeafError`

* fix std Error

* move Word/Digest conversions to LeafIndex

* `SmtProof::new()` returns an error

* `SparseMerkleTree::path_and_leaf_to_opening`

* `SmtLeaf`: serializable/deserializable

* `SmtProof`: serializable/deserializable

* add tests for SmtLeaf serialization

* move `SmtLeaf` to submodule

* use constructors internally

* fix docs

* Add `Vec`

* add `Vec` to tests

* no_std use statements

* fmt

* `Errors`: make heading

* use `SMT_DEPTH`

* SmtLeaf single case: check leaf index

* Multiple case: check consistency with leaf index

* use `pub(super)` instead of `pub(crate)`

* use `pub(super)`

* `SmtLeaf`: add `num_entries()` accessor

* Fix `SmtLeaf` serialization

* improve leaf serialization tests
2024-02-14 11:52:40 -08:00
Philippe Laferrière
3d71a9b59b Smt: remove inner nodes when removing value (#269) 2024-02-14 11:52:40 -08:00
Philippe Laferrière
5596db7868 Implement Smt struct (replacement to TieredSmt) (#254) 2024-02-14 11:52:40 -08:00
Philippe Laferrière
8ea37904e3 Introduce SparseMerkleTree trait (#245) 2024-02-14 11:52:40 -08:00