Commit Graph

55 Commits

Author SHA1 Message Date
str4d a829044d8a
Merge pull request #11 from zcash/release-0.2.0
incrementalmerkletree 0.2.0
2021-12-17 16:35:37 +00:00
Jack Grigg 1ac3ad239f incrementalmerkletree 0.2.0
Closes zcash/incrementalmerkletree#10.
2021-12-17 16:00:32 +00:00
Kris Nuttycombe 5312649292
Merge pull request #7 from nuttycom/use_witness_for_checkpointing
Use witness for checkpointing
2021-12-10 10:32:04 -07:00
Kris Nuttycombe 0a8854f1b0 Apply suggestions from code review & fix clippy complaints. 2021-12-09 16:31:22 -07:00
Kris Nuttycombe e4573b81c1 Ensure that we always drop old checkpoints when adding a checkpoint. 2021-12-06 13:37:48 -07:00
Kris Nuttycombe 67a5d6ff29 Fix documentation of tree methods. 2021-12-06 13:37:48 -07:00
Kris Nuttycombe 6296748cad Use witness functionality for checkpointing.
This restores an earlier approach to creating checkpoints
that is more space-efficient and reuses the `witness`
machinery. This is preparatory work for supporting arbitrary
rewind-to-witnessed-position.
2021-12-02 08:09:12 -07:00
str4d b7bd624612
Merge pull request #6 from nuttycom/serialization_support
Two minor fixes, plus methods required to support parsing and serialization.
2021-08-03 14:18:22 +01:00
str4d a36a98b64d
Documentation typos
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-08-03 14:18:08 +01:00
Kris Nuttycombe 616344aa9b Document newly added BridgeTree methods. 2021-07-30 15:30:11 -06:00
Kris Nuttycombe 75b26c1dea Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-07-30 15:04:55 -06:00
Kris Nuttycombe 4e12c24807 Move `Position` into the base lib module and ensure wraps u64 explicitly. 2021-07-30 11:52:52 -06:00
Kris Nuttycombe 04384b2b66 Add AuthFragment::from_parts and MerkleBridge::from_parts 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 7b3ac3a22f Lighten constraints on BridgeTree methods. 2021-07-22 12:21:36 -06:00
Kris Nuttycombe d6c0088fc6 Add construction of BridgeTree from parts. 2021-07-22 12:21:36 -06:00
Kris Nuttycombe f705a68db8 Add `TryFrom<NonEmptyFrontier<H>> for Frontier<H, DEPTH>` 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 9a8d388ec8 Implement `PartialEq` and `Eq` for Frontier 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 54430890b1 Add Leaf::into_value 2021-07-22 12:21:36 -06:00
Kris Nuttycombe 6d527c7a67 Add accessors to private frontier elements. 2021-07-22 12:21:33 -06:00
Kris Nuttycombe 909f0d6224 Add `From<usize>` impl for Position 2021-07-22 12:20:12 -06:00
Kris Nuttycombe a5bd5b6a2a Add Frontier::from_parts constructor. 2021-07-22 12:19:55 -06:00
Kris Nuttycombe 98c4dc8de2 Fix an off-by-one error in the maximum height of the tree. 2021-07-22 12:19:16 -06:00
Kris Nuttycombe 2f65f19fa6 Fix formatting. 2021-07-22 12:10:42 -06:00
Kris Nuttycombe 5684063539
Merge pull request #5 from nuttycom/rename_ommer
Rename "parent" to "ommer" and add a few public operations required for serialization support.
2021-07-22 12:01:30 -06:00
Kris Nuttycombe 4d44fb56f5
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
Co-authored-by: ying tong <yingtong@z.cash>
2021-07-20 09:45:36 -06:00
Kris Nuttycombe 9dfc9ecdcc Auth fragment concatenation is only associative, not commutative. 2021-07-20 07:40:13 -06:00
Kris Nuttycombe 63d8437d72 Simplify leaf_value match. 2021-07-20 07:25:26 -06:00
Kris Nuttycombe e6dd1c2461 Remove value_at 2021-07-20 07:22:59 -06:00
Kris Nuttycombe d188121cbe Improve bridgetree documentation. 2021-07-08 10:16:55 -06:00
Kris Nuttycombe 5f719bb769 Rename "parent" to "ommer"
The term "parent" as it has previously been used in this module is
confusing, because it referred not to the actual parent of a leaf note,
but to the *sibling* of the leaf's future parent. "Ommer" is a
gender-neutral term for the sibling of a parent, so it is ideal
for use in this context.
2021-07-02 16:43:32 -06:00
str4d 8b59049f17
Merge pull request #4 from nuttycom/frontier_dyn_memory_usage
Add function to estimate dynamic memory usage of frontiers.
2021-06-28 23:29:10 +01:00
Kris Nuttycombe 530c94a40f Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-06-28 16:24:27 -06:00
Kris Nuttycombe 5e70b5cfd6 Add function to estimate dynamic memory usage of frontiers.
Also clean up Clippy complaints.
2021-06-28 16:07:09 -06:00
Sean Bowe 09029e9a96
Expose new() only in tests. 2021-06-24 14:16:13 -06:00
Sean Bowe 709dbd07c4
Added stuff for publishing to crates.io 2021-06-24 14:14:30 -06:00
ebfull 5abf28ccf3
Merge pull request #3 from nuttycom/fix_str_combine
Revert change to string combine function for tests.
2021-06-24 14:13:32 -06:00
Kris Nuttycombe e499a27f04 Revert change to string combine function for tests. 2021-06-24 14:12:52 -06:00
ebfull 6b42e590ae
Merge pull request #1 from nuttycom/merkle_bridge
Add an efficient implementation of the incremental merkle tree.
2021-06-24 14:00:34 -06:00
Kris Nuttycombe cf68d49d3f Trivial fixup. 2021-06-23 15:39:24 -06:00
Kris Nuttycombe 3decd0bf48 Use const generic parameter for tree depth. 2021-06-23 14:14:57 -06:00
Kris Nuttycombe aed785e896 Rename "Level" -> "Altitude"
The FlyClient spec uses "Altitude" for this concept in
Merkle mountain ranges, so I'm renaming for consistency.
2021-06-19 11:24:33 -06:00
Kris Nuttycombe d319262985 Add conversion from Position to usize 2021-06-19 08:07:59 -06:00
Kris Nuttycombe 205b075aa8 Expose position of possibly-empty frontier. 2021-06-18 22:06:16 -06:00
Kris Nuttycombe 06e0a5772e Add `Frontier` trait as a subset of `Tree` operations.
For some applications, it is not necessary to include the
full range of witnessing and checkpointing operations. The
Frontier trait captures the minimal operations required:
appending leaves to the tree and constructing the root
of the tree by hashing against empty nodes.
2021-06-18 14:21:03 -06:00
Kris Nuttycombe b89a359121 Remove duplicative case from witness computation. 2021-06-18 09:24:09 -06:00
Kris Nuttycombe c1fcd83329 Implement efficient incremental merkle tree. 2021-06-17 19:32:50 -06:00
Kris Nuttycombe 1267c8ec07 Rename "efficient" module to "bridgetree". 2021-06-17 19:31:26 -06:00
Kris Nuttycombe 37d1f920e4 Refactor hashing api & contracts of witness & checkpoint methods.
In this commit:

* TreeHasher is replaced by the Hashable trait. Hashable is
  modified to use level information in the construction of
  the hash, and a convenience method is provided for obtaining
  the empty node at a given level.

* The pop_checkpoint method is removed from the `Tree` interface.
  Instead, a maximum number of checkpoints is established at tree
  construction time and then the oldest checkpoints are automatically
  dropped when adding new checkpoints once that number is reached.

* The `witness` method implementation in the sample tree
  is modified to ignore duplicate calls.

* Property testing functiona are modified to abstract over
  the type of hashable data.
2021-06-17 19:24:18 -06:00
Kris Nuttycombe 68c8d88bd3 Move sample tree & efficient tree to independent modules. 2021-06-17 19:17:47 -06:00
Sean Bowe 48507454f3
combined tree 2021-01-05 15:11:17 -07:00