-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
use create::context::PrivateContext; | ||
use crate::{ | ||
|
||
context::PrivateContext, | ||
|
||
fn prove_note_commitment_inclusion( | ||
pub fn prove_note_commitment_inclusion( | ||
note_commitment: Fr, | ||
block_number: Field, // The block at which we'll prove that the note exists | ||
block_number: u32, // The block at which we'll prove that the note exists | ||
context: PrivateContext | ||
) { | ||
|
||
// 1) Get block header from oracle and ensure that the block is included in the archive. | ||
let block_header = context.get_block_header(block_number); | ||
|
||
// 4) Get the membership witness of the note in the note hash tree | ||
let note_hash_tree_id = 2; // TODO(#3443) | ||
let witness: MembershipWitness<NOTE_HASH_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT + 1> = | ||
get_membership_witness(block_number, note_hash_tree_id, note_commitment); | ||
|
||
// 5) Prove that the commitment is in the note hash tree | ||
assert( | ||
block_header.note_hash_tree_root == compute_merkle_root(note_commitment, witness.index, witness.path), | ||
"Proving note inclusion failed" | ||
); | ||
|
||
// --> Now we have traversed the trees all the way up to blocks tree root. | ||
} | ||
|
||
pub fn prove_note_inclusion<Note, N>( | ||
note_interface: NoteInterface<Note, N>, | ||
note_with_header: Note, | ||
block_number: u32, // The block at which we'll prove that the note exists | ||
context: PrivateContext | ||
) { | ||
let note_commitment = note_utils::compute_unique_siloed_note_hash(ValueNoteMethods, note_with_header) | ||
|
||
prove_note_commitment_inclusion(note_commitment, block_number, context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters