From cc398a3cf25c7aa05e3641a9c702062672e7fd21 Mon Sep 17 00:00:00 2001 From: Philippe Laferriere Date: Tue, 28 Nov 2023 16:24:46 -0500 Subject: [PATCH] MmrPeaks::hash_peaks() returns Digest --- src/merkle/mmr/peaks.rs | 4 ++-- src/merkle/mmr/tests.rs | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/merkle/mmr/peaks.rs b/src/merkle/mmr/peaks.rs index a965ac7a..e0ec3f24 100644 --- a/src/merkle/mmr/peaks.rs +++ b/src/merkle/mmr/peaks.rs @@ -64,8 +64,8 @@ impl MmrPeaks { /// The procedure will: /// - Flatten and pad the peaks to a vector of Felts. /// - Hash the vector of Felts. - pub fn hash_peaks(&self) -> Word { - Rpo256::hash_elements(&self.flatten_and_pad_peaks()).into() + pub fn hash_peaks(&self) -> RpoDigest { + Rpo256::hash_elements(&self.flatten_and_pad_peaks()) } pub fn verify(&self, value: RpoDigest, opening: MmrProof) -> bool { diff --git a/src/merkle/mmr/tests.rs b/src/merkle/mmr/tests.rs index 0cb7ac96..a92f4c64 100644 --- a/src/merkle/mmr/tests.rs +++ b/src/merkle/mmr/tests.rs @@ -613,10 +613,7 @@ fn test_mmr_hash_peaks() { // minimum length is 16 let mut expected_peaks = [first_peak, second_peak, third_peak].to_vec(); expected_peaks.resize(16, RpoDigest::default()); - assert_eq!( - peaks.hash_peaks(), - *Rpo256::hash_elements(&digests_to_elements(&expected_peaks)) - ); + assert_eq!(peaks.hash_peaks(), Rpo256::hash_elements(&digests_to_elements(&expected_peaks))); } #[test] @@ -634,7 +631,7 @@ fn test_mmr_peaks_hash_less_than_16() { expected_peaks.resize(16, RpoDigest::default()); assert_eq!( accumulator.hash_peaks(), - *Rpo256::hash_elements(&digests_to_elements(&expected_peaks)) + Rpo256::hash_elements(&digests_to_elements(&expected_peaks)) ); } } @@ -651,7 +648,7 @@ fn test_mmr_peaks_hash_odd() { expected_peaks.resize(18, RpoDigest::default()); assert_eq!( accumulator.hash_peaks(), - *Rpo256::hash_elements(&digests_to_elements(&expected_peaks)) + Rpo256::hash_elements(&digests_to_elements(&expected_peaks)) ); }