Skip to content

Commit 206c5d1

Browse files
committed
Modify verify_proof
1 parent b52286e commit 206c5d1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/data_structures/mmr/mmr.cairo

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl MMRImpl of MMRTrait {
9191
// @return Result with true if the proof is valid, false otherwise
9292
fn verify_proof(
9393
self: @MMR, index: MmrSize, hash: MmrElement, peaks: Peaks, proof: Proof
94-
) -> Result<bool, felt252> {
94+
) -> Result<(), felt252> {
9595
let leaf_count = mmr_size_to_leaf_count(*self.last_pos);
9696
if leaf_count_to_peaks_count(leaf_count) != peaks.len().into() {
9797
return Result::Err('Invalid peaks count');
@@ -103,11 +103,14 @@ impl MMRImpl of MMRTrait {
103103
let (peak_index, peak_height) = get_peak_info(*self.last_pos, index);
104104

105105
if proof.len() != peak_height {
106-
return Result::Ok(false);
106+
return Result::Err('Invalid peaks');
107107
}
108108

109109
let peak = proof.compute_peak(index, hash);
110110

111-
Result::Ok(*peaks.at(peak_index) == peak)
111+
if *peaks.at(peak_index) != peak {
112+
return Result::Err('Invalid proof');
113+
}
114+
Result::Ok(())
112115
}
113116
}

0 commit comments

Comments
 (0)