> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Module membership

Module: `noir_aztec::protocol::merkle_tree::membership`

## Structs

- [MembershipWitness](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/struct.MembershipWitness.md)

## Functions

- [check_membership](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.check_membership.md): Check whether a leaf exists in the tree with the given `root`. `membership_witness` is a hint to prove that the `leaf` exists in the tree with the given `root`.

- [check_membership_with_hasher](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.check_membership_with_hasher.md): Check whether a leaf exists in the tree with the given `root`. Same as `check_membership` but uses a custom hasher. `membership_witness` is a hint to prove that the `leaf` exists in the tree with the given `root`.

- [check_non_membership](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.check_non_membership.md): Check a key's non-existence in the indexed tree with the given `tree_root`. `low_leaf_preimage` is the preimage for the low leaf of the key. The key should be larger than the low leaf's key, and smaller than the low leaf's next key. `low_leaf_membership_witness` is a hint to prove that the low leaf exists in the tree with the given `tree_root`.

- [check_non_membership_with_hasher](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.check_non_membership_with_hasher.md): Same as `check_non_membership` but uses a custom hasher. Use this variant for indexed trees whose internal nodes use a tree-specific separator (e.g. `nullifier_merkle_hash`).

- [conditionally_check_membership](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.conditionally_check_membership.md): Check either membership or non-membership depending on the value of `exists`:

  - If `exists` == true, `key` is in the tree. `leaf_preimage` is for the key itself.
  - If `exists` == false, `key` is not in the tree. `leaf_preimage` is for the low leaf of the key. `membership_witness` is the hint to prove that the `leaf_preimage` exists in the tree with the given `tree_root`.

- [conditionally_check_membership_with_hasher](/aztec-nr-api/v6.0.0/noir_aztec/protocol/merkle_tree/membership/fn.conditionally_check_membership_with_hasher.md): Same as `conditionally_check_membership` but uses a custom hasher. Use this variant for indexed trees whose internal nodes use a tree-specific separator (e.g. `public_data_merkle_hash`).
