Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree(ics23): add bounding path calculation proptests #115

Merged
merged 1 commit into from
May 27, 2024

Conversation

erwanor
Copy link
Member

@erwanor erwanor commented May 18, 2024

This PR adds a proptest setup that exercises the bounding path logic used to generate ics23 non-existence proofs.

Context
In #100, we fixed a bug located deep in the logic determining the adjacency of two subtrees in the jmt. As part of review, it was pointed out that writing property tests that exercise the different "types" of nonexistence setups/adjacency would have high ROI. As a result, we filed #104 and outlined a testing strategy in this comment.

Proptest strategy

/// Assert that the Ics23 bonding path calculations are correct.
/// To achieve this, the uses a strategy that consists in:
/// 1. generating a sorted vector of key preimages
/// 2. instantiating a JMT over a `TransparentHasher`
///
/// The last point allow us to easily test that for a given key
/// that is *in* the JMT, we can generate two non-existent keys
/// that are "neighbor" to `k`: (k-1, k+1).
///
/// To recap, we generate a vector of sorted key <k_1, ... k_n>;
/// then, we iterate over each existing key `k_i` and compute a
///     tuple of neighbors (`k_i - 1`, `k_i + 1`) which are *not*
///     in the tree.
/// Equipped with those nonexisting neighbors, we check for exclusion
/// in the tree, and specifically assert that the generated proof contains:
/// 1. the initial key we requested (i.e. `k_i + 1` or `k_i - 1`)
/// 2. the correct left neighbor (i.e. `k_{i-1}`, or `k_{i+1}`, or none`)
/// 2. the correct right neighbor (i.e. `k_{i-1}`, or `k_{i+1}`, or none`)
/// across configurations e.g. bounding path for a leftmost or rightmost subtree.
/// More context available in #104.

@erwanor erwanor self-assigned this May 18, 2024
Copy link

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magnificent!

@erwanor erwanor merged commit fe03c66 into main May 27, 2024
10 checks passed
@TalDerei
Copy link

TalDerei commented May 27, 2024

@erwanor I'm curious, how does a proof of non-existence work in the JMT? Is it the same non-membership proof like other sparse merkle tree constructions where you build a merkle proof that the leaf at specific index is empty?

referencing https://hackmd.io/@aztec-network/ryJ8wxfKK#Sparse-Merkle-Trees-and-Non-Membership-Proofs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants