Skip to content

Rename verify_membership args #22

@jialinli98

Description

@jialinli98
pub fn check_membership<let N: u32, H>(
    leaf: Field,
    index: Field,
    sibling_path: [Field; N],
    root: Field,
) -> bool
where
    H: Hasher + Default,
{
    let calculated_root = compute_root_from_sibling_path::<N, H>(leaf, index, sibling_path);
    calculated_root == root
}

pub fn assert_check_membership<let TREE_HEIGHT: u32, H>(
    leaf: Field,
    index: Field,
    sibling_path: [Field; TREE_HEIGHT],
    root: Field,
)
where
    H: Hasher + Default,
{
    assert(
        check_membership::<TREE_HEIGHT, H>(leaf, index, sibling_path, root),
        "membership check failed",
    );
}

This function can be used to verify membership of internal nodes in addition to leaves. Maybe rename leaf to internal node, TREE_HEIGHT to SIBLING_PATH_LENGTH

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions