* `witnessed_positions` returns the set of positions that have been
witnessed in the tree.
* `garbage_collect` makes the garbage collection operation of
`bridgetree::BridgeTree` publicly accessible. It is always safe to
implement this method as a no-op.
This modifies the `Tree::authentication_path` and `Tree::remove_witness`
methods to only operate in terms of the tree position, rather than both
the position and the hash that is expected to be the leaf at that
position.
Positions in the tree are always unique, and the tree already contains
the leaf information corresponding to each position, so the existing API
previously required the storage of redundant information. This change
streamlines the API without loss of power.
This also adds additional consistency checks to the property tests.
In practice, when performing a rewind we don't want to have to
do the additional bookkeeping keeping the leaf position and
value around just to be able to remove the witnesses. After
this change, `rewind` will always succeed unless there are
no checkpoints.
While these additional bounds are often used with hashable
types, they are not necessary for the construction of `Frontier`
values, and so should not be required everywhere.
This adds a garbage collection method to BridgeTree that
can be used to eliminate checkpoints and removed witnesses
that are no longer reachable for possible rewinds. It also
prunes unnecessary auth fragments from the tree.
Removal of witnesses is now recorded on a per-checkpoint
level, so that rewinding the tree state now restores any
witnesses that were removed since the checkpoint.
A number of internal consistency checks previously enforced
by the property tests have been removed as they did not
correctly implement this semantic, and reimplementing these
consistency checks would be equivalent to reimplementing the
sample tree, so these checks are now performed simply by
comparison against the reference implentation.
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.
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.