Skip to content

Instantly share code, notes, and snippets.

@Turupawn
Created April 16, 2025 18:24
Show Gist options
  • Save Turupawn/9b6f58a170a0a4c288287a04f6ca4443 to your computer and use it in GitHub Desktop.
Save Turupawn/9b6f58a170a0a4c288287a04f6ca4443 to your computer and use it in GitHub Desktop.
Merkle Inclusion Proofs in Noir
use std::hash::pedersen_hash;
fn main(root : pub Field,
index : Field,
hash_path : [Field; 2],
secret: Field, priv_key: Field,
public_param1: pub Field,
public_param2: pub Field) -> pub Field
{
let note_commitment = pedersen_hash([priv_key, secret]);
let nullifier = pedersen_hash([root, priv_key, public_param1]);
let computed_root =
std::merkle::compute_merkle_root(note_commitment, index, hash_path);
assert(root == computed_root);
nullifier
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment