Commit graph

917 commits

Author SHA1 Message Date
4a2bad749a MerkleTree: use new NodeIndex::proof_indices() to resolve TODO 2025-04-23 19:39:53 +02:00
72553db538 SimpleSmt: do not assume that Merkle paths Deref to Vec in tests
This is in preparation for the next commit, where we change
`SimpleSmt::open()` to return a `SparseMerklePath`, which cannot
dereference to a Vec.
2025-04-23 19:39:53 +02:00
632345a2f2 smt: refactor MerklePath logic
Computation of the correct node indices to get is moved to
`NodeIndex::proof_indices()`, and getting a node's index based on its
parent is generalized into `SparseMerkleTree::get_hash()`.
2025-04-23 19:39:53 +02:00
4fe6ca3f57 smt: add SparseMerklePath, a compact representation of MerklePath 2025-04-23 19:39:53 +02:00
3971b166c8 MerklePath: add clarity getters for API parity with future SparseMerklePath
This adds `MerklePath::at_depth()` and `MerklePath::at_idx()`, both for
clarity and for API parity with `SparseMerklePath` in the next commit.
2025-04-23 19:39:53 +02:00
20bac15aba MerklePath: document indexing order of nodes
I've left the iteration order of `MerklePath::inner_nodes()`
unspecified, but other methods of iteration and indexing are now
specified to be in order of deepest to shallowest.
2025-04-23 19:39:53 +02:00
1f922adb96 add // TESTS header 2025-04-23 19:31:32 +02:00
Grzegorz Świrski
06e468a008 use Cow instead of the additional IntoIter struct 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
e719e5e92a loop over depths in tests 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
5321fff6e0 clarify empty_nodes_mask documentation 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
ab2e7bef8e clarify that SparseMerklePath can store up to SMT_MAX_DEPTH nodes total 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
371f7f5f86 remove unsafe FromIterator<(NonZero<u8>, Option<RpoDigest>)> 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
21f572b407 make from_iter_with_depth private, make sure iterators in tests have the same length 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
1c5eae29c0 keep at_depth and at_idx consistent wrt ownership 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
5f62212b3d move comment 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
82c140e996 return a deserialization error if too many empty nodes detected 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
4e97f0a192 move try_from doc to function level for better ide support 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
d32e8c9fcb clearer assertions in sparse_path tests 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
6ca4f887ce swap test_borrowing_iterator and test_owning_iterator names 2025-04-23 19:31:24 +02:00
Grzegorz Świrski
29d24a697c expect instead of unwrap
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
2025-04-23 19:31:24 +02:00
Grzegorz Świrski
61782a5478 strengthen the wording in docs
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
2025-04-23 19:31:24 +02:00
96df4fef87 smt: change SimpleSmt::open() to return a sparse path 2025-04-23 19:31:24 +02:00
76e5d4d97d SimpleSmt: do not assume that Merkle paths Deref to Vec in tests
This is in preparation for the next commit, where we change
`SimpleSmt::open()` to return a `SparseMerklePath`, which cannot
dereference to a Vec.
2025-04-23 19:31:24 +02:00
fd759c23d4 smt: add SparseMerklePath, a compact representation of MerklePath 2025-04-23 19:31:24 +02:00
5d20459202 squash Cow commits into each other 2025-04-23 19:25:45 +02:00
Grzegorz Świrski
a39cd06537 use Cow instead of the additional IntoIter struct 2025-04-23 19:25:17 +02:00
8cedb9dafb fetch Greg's changes 2025-04-23 19:24:31 +02:00
Grzegorz Świrski
20156d1ac9 Cow without std 2025-04-17 22:11:46 +02:00
Grzegorz Świrski
866a6bd78a use Cow instead of the additional IntoIter struct 2025-04-16 17:47:33 +02:00
Grzegorz Świrski
9daaef8061 loop over depths in tests 2025-04-16 11:58:18 +02:00
Grzegorz Świrski
a03167ca8f clarify empty_nodes_mask documentation 2025-04-16 11:45:09 +02:00
Grzegorz Świrski
e5766b8194 clarify that SparseMerklePath can store up to SMT_MAX_DEPTH nodes total 2025-04-16 11:33:16 +02:00
Grzegorz Świrski
6c59d059eb remove unsafe FromIterator<(NonZero<u8>, Option<RpoDigest>)> 2025-04-16 11:31:04 +02:00
Grzegorz Świrski
c6edb4d42d make from_iter_with_depth private, make sure iterators in tests have the same length 2025-04-16 11:02:52 +02:00
Grzegorz Świrski
b9eaca42ac keep at_depth and at_idx consistent wrt ownership 2025-04-16 10:26:46 +02:00
Grzegorz Świrski
78f1edb918 move comment 2025-04-16 10:07:56 +02:00
Grzegorz Świrski
05fc26423d return a deserialization error if too many empty nodes detected 2025-04-16 10:05:39 +02:00
Grzegorz Świrski
d1e76062a3 move try_from doc to function level for better ide support 2025-04-16 09:50:20 +02:00
Grzegorz Świrski
d985fce4fa clearer assertions in sparse_path tests 2025-04-16 09:47:06 +02:00
Grzegorz Świrski
d2c4a02f0c swap test_borrowing_iterator and test_owning_iterator names 2025-04-16 09:40:23 +02:00
Grzegorz Świrski
71b741e0ce
expect instead of unwrap
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
2025-04-16 09:34:52 +02:00
Grzegorz Świrski
c168c72f5a
strengthen the wording in docs
Co-authored-by: Philipp Gackstatter <PhilippGackstatter@users.noreply.github.com>
2025-04-16 09:32:16 +02:00
d15031b1c7 move serialization above the iterators 2025-04-07 16:29:55 +02:00
5ab7980fbc smt: change SimpleSmt::open() to return a sparse path 2025-04-07 16:29:43 +02:00
5685f6d4b6 SimpleSmt: do not assume that Merkle paths Deref to Vec in tests
This is in preparation for the next commit, where we change
`SimpleSmt::open()` to return a `SparseMerklePath`, which cannot
dereference to a Vec.
2025-04-07 16:29:43 +02:00
80bd9af671 smt: add SparseMerklePath, a compact representation of MerklePath 2025-04-07 16:29:43 +02:00
44ee5270eb SPARSE MERKLE PATH CONTAINERS -> SPARSE VALUE PATH 2025-04-07 16:29:14 +02:00
fadbc74bb4 smt: change SimpleSmt::open() to return a sparse path 2025-04-07 16:29:04 +02:00
0c436503e9 SimpleSmt: do not assume that Merkle paths Deref to Vec in tests
This is in preparation for the next commit, where we change
`SimpleSmt::open()` to return a `SparseMerklePath`, which cannot
dereference to a Vec.
2025-04-07 16:29:04 +02:00
9ae2934de9 smt: add SparseMerklePath, a compact representation of MerklePath 2025-04-07 16:29:04 +02:00