Skip to content

Commit 2af7c95

Browse files
committed
chore(VerifyMmrSuccessorProof): Sign off
1 parent eb53c84 commit 2af7c95

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

tasm-lib/src/mmr/verify_mmr_successor.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ impl BasicSnippet for VerifyMmrSuccessor {
182182
/* nominal case */
183183
dup 2 dup 2
184184
dup 7 dup 7
185+
// _ [old_num_leafs: u64] *old_peaks [new_num_leafs: u64] *new_peaks [new_num_leafs: u64] [old_num_leafs: u64]
186+
185187
call {leaf_index_to_mti_and_pki} hint num_unchanged_peaks = stack[0]
186188
hint merkle_tree_idx: u64 = stack[1..3]
187189
// _ [old_num_leafs: u64] *old_peaks [new_num_leafs: u64] *new_peaks [mt_index: u64] num_unchanged_peaks
@@ -199,6 +201,8 @@ impl BasicSnippet for VerifyMmrSuccessor {
199201
addi -1
200202
push {Digest::LEN}
201203
mul
204+
// _ [mt_index: u64] [old_num_leafs: u64] [new_num_leafs: u64] *new_peaks num_unchanged_peaks *old_peaks[0] (old_num_peaks-1)*DIGEST_LENGTH
205+
202206
dup 1
203207
add hint last_old_peak: Pointer = stack[0]
204208
place 1
@@ -381,6 +385,7 @@ impl BasicSnippet for VerifyMmrSuccessor {
381385
fn sign_offs(&self) -> HashMap<Reviewer, SignOffFingerprint> {
382386
let mut sign_offs = HashMap::new();
383387
sign_offs.insert(Reviewer("ferdinand"), 0xeb1e81bd042d7a0c.into());
388+
sign_offs.insert(Reviewer("alan"), 0xeb1e81bd042d7a0c.into());
384389
sign_offs
385390
}
386391
}
@@ -434,16 +439,19 @@ mod tests {
434439
let dummy_proof = MmrSuccessorProof::new_from_batch_append(&old_mmr, &new_dummy_leafs);
435440
let auth_path_len = dummy_proof.paths.len();
436441

437-
let mut paths = vec![];
442+
// grab first path element from nd tokens
443+
let mut path = vec![];
438444
if auth_path_len > 0 {
439445
let first_element = (0..Digest::LEN).rev().map(|i| nd_tokens[i]).collect_vec();
440-
paths.push(Digest::new(first_element.try_into().unwrap()));
446+
path.push(Digest::new(first_element.try_into().unwrap()));
441447
}
448+
449+
// grab remaining path elements from nd digests
442450
if auth_path_len > 1 {
443-
paths.extend((0..auth_path_len - 1).map(|i| nd_digests[i]));
451+
path.extend((0..auth_path_len - 1).map(|i| nd_digests[i]));
444452
}
445453

446-
assert!(MmrSuccessorProof { paths }.verify(&old_mmr, &new_mmr));
454+
assert!(MmrSuccessorProof { paths: path }.verify(&old_mmr, &new_mmr));
447455
}
448456

449457
fn pseudorandom_initial_state(

0 commit comments

Comments
 (0)