#manager #verify #merkle #pallet #proof

no-std pallet-merkle

Merkle tree membership pallet with zero-knowledge membership proof verification

1 stable release

3.0.0 Mar 12, 2021

Used in pallet-mixer


1.5K SLoC

Merkle Pallet

The Merkle pallet provides functionality for making and managing the Merkle trees.


The Merkle pallet provides functions for:

  • Creating Merkle trees.
  • Adding the manager and setting whether the manager is required.
  • Adding leaf data to the Merkle tree.
  • Adding nullifiers to the storage.
  • Managing start/stop flags.
  • Caching Merkle tree states.
  • Verifying regular and zero-knowledge membership proofs


  • Membership proof in zero-knowledge: Proving that leaf is inside the tree without revealing which leaf you are proving over.

  • Proof of creation in zero-knowledge: Each leaf is made with an arithmetic circuit which includes hashing several values. Proving to know all these values are called proof of creation.

  • Nullifier: Nullifier is a part of this leaf circuit and is revealed when proving membership in zero-knowledge. The nullifier's role is to prevent double-spending.


The Merkle pallet provides implementations for the following traits:

  • Group Functions for creating and managing the group.


Dispatchable functions

  • create_group - Create Merkle tree and their respective manager account.
  • set_manager_required - Set whether manager is required to add members and nullifiers.
  • set_manager - Set manager account id. Can only be called by the root or the current manager.
  • set_stopped - Sets stopped storage flag. This flag by itself doesn't do anything. It's up to higher-level pallets to make appropriate use of it. Can only be called by the root or the manager;
  • add_members Adds an array of leaves to the tree. Can only be called by the manager if the manager is required.
  • verify - Verifies the membership proof.


The following examples show how to use the Merkle pallet in your custom pallet.

use pallet_merkle::traits::Group;
pub trait Config: frame_system::Config + pallet_merkle::Config {
	type Group: Group<Self::AccountId, Self::BlockNumber, Self::GroupId>;


~278K SLoC