11#![ no_main]
22
33use arbitrary:: Arbitrary ;
4- use commonware_cryptography:: { sha256:: Digest , Hasher , Sha256 } ;
4+ use commonware_cryptography:: { sha256:: Digest , Sha256 } ;
55use commonware_parallel:: Sequential ;
66use commonware_runtime:: { buffer:: paged:: CacheRef , deterministic, Runner , Supervisor as _} ;
77use commonware_storage:: {
88 journal:: contiguous:: fixed:: Config as FConfig ,
99 merkle:: { full:: Config as MerkleConfig , mmb, mmr, Graftable , Location } ,
10- qmdb:: current:: { ordered:: fixed:: Db as CurrentDb , FixedConfig as Config } ,
10+ qmdb:: {
11+ self ,
12+ current:: { ordered:: fixed:: Db as CurrentDb , FixedConfig as Config } ,
13+ } ,
1114 translator:: TwoCap ,
1215} ;
1316use commonware_utils:: { sequence:: FixedBytes , NZUsize , NZU16 , NZU64 } ;
@@ -113,7 +116,7 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
113116 let suffix = suffix. to_string ( ) ;
114117 let operations = data. operations . clone ( ) ;
115118 runner. start ( |context| async move {
116- let mut hasher = Sha256 :: new ( ) ;
119+ let hasher = qmdb :: hasher :: < Sha256 > ( ) ;
117120 let page_cache = CacheRef :: from_pooler (
118121 & context,
119122 PAGE_SIZE ,
@@ -251,13 +254,13 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
251254 let oldest_loc = db. sync_boundary ( ) ;
252255 if start_loc >= oldest_loc {
253256 let ( proof, ops, chunks) = db
254- . range_proof ( & mut hasher, start_loc, * max_ops)
257+ . range_proof ( & hasher, start_loc, * max_ops)
255258 . await
256259 . expect ( "Range proof should not fail" ) ;
257260
258261 assert ! (
259262 Db :: <F >:: verify_range_proof(
260- & mut hasher,
263+ & hasher,
261264 & proof,
262265 start_loc,
263266 & ops,
@@ -292,15 +295,15 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
292295 let root = db. root ( ) ;
293296
294297 if let Ok ( ( range_proof, ops, chunks) ) = db
295- . range_proof ( & mut hasher, start_loc, * max_ops)
298+ . range_proof ( & hasher, start_loc, * max_ops)
296299 . await {
297300 // Try to verify the proof when providing bad proof digests.
298301 let bad_digests = bad_digests. iter ( ) . map ( |d| Digest :: from ( * d) ) . collect ( ) ;
299302 if range_proof. proof . digests != bad_digests {
300303 let mut bad_proof = range_proof. clone ( ) ;
301304 bad_proof. proof . digests = bad_digests;
302305 assert ! ( !Db :: <F >:: verify_range_proof(
303- & mut hasher,
306+ & hasher,
304307 & bad_proof,
305308 start_loc,
306309 & ops,
@@ -312,7 +315,7 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
312315 // Try to verify the proof when providing bad input chunks.
313316 if & chunks != bad_chunks {
314317 assert ! ( !Db :: <F >:: verify_range_proof(
315- & mut hasher,
318+ & hasher,
316319 & range_proof,
317320 start_loc,
318321 & ops,
@@ -323,11 +326,11 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
323326
324327 let bad_prefix_peaks =
325328 bad_prefix_peaks. iter ( ) . map ( |d| Digest :: from ( * d) ) . collect ( ) ;
326- if range_proof. unfolded_prefix_peaks != bad_prefix_peaks {
329+ if range_proof. prefix_witnesses != bad_prefix_peaks {
327330 let mut bad_proof = range_proof. clone ( ) ;
328- bad_proof. unfolded_prefix_peaks = bad_prefix_peaks;
331+ bad_proof. prefix_witnesses = bad_prefix_peaks;
329332 assert ! ( !Db :: <F >:: verify_range_proof(
330- & mut hasher,
333+ & hasher,
331334 & bad_proof,
332335 start_loc,
333336 & ops,
@@ -338,11 +341,11 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
338341
339342 let bad_suffix_peaks =
340343 bad_suffix_peaks. iter ( ) . map ( |d| Digest :: from ( * d) ) . collect ( ) ;
341- if range_proof. unfolded_suffix_peaks != bad_suffix_peaks {
344+ if range_proof. suffix_witnesses != bad_suffix_peaks {
342345 let mut bad_proof = range_proof. clone ( ) ;
343- bad_proof. unfolded_suffix_peaks = bad_suffix_peaks;
346+ bad_proof. suffix_witnesses = bad_suffix_peaks;
344347 assert ! ( !Db :: <F >:: verify_range_proof(
345- & mut hasher,
348+ & hasher,
346349 & bad_proof,
347350 start_loc,
348351 & ops,
@@ -363,11 +366,11 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
363366 committed_op_count = db. bounds ( ) . await . end ;
364367 let current_root = db. root ( ) ;
365368
366- match db. key_value_proof ( & mut hasher, k. clone ( ) ) . await {
369+ match db. key_value_proof ( & hasher, k. clone ( ) ) . await {
367370 Ok ( proof) => {
368371 let value = db. get ( & k) . await . expect ( "get should not fail" ) . expect ( "key should exist" ) ;
369372 let verification_result = Db :: < F > :: verify_key_value_proof (
370- & mut hasher,
373+ & hasher,
371374 k,
372375 value,
373376 & proof,
@@ -394,10 +397,10 @@ fn fuzz_family<F: Graftable>(data: &FuzzInput, suffix: &str) {
394397 committed_op_count = db. bounds ( ) . await . end ;
395398 let current_root = db. root ( ) ;
396399
397- match db. exclusion_proof ( & mut hasher, & k) . await {
400+ match db. exclusion_proof ( & hasher, & k) . await {
398401 Ok ( proof) => {
399402 let verification_result = Db :: < F > :: verify_exclusion_proof (
400- & mut hasher,
403+ & hasher,
401404 & k,
402405 & proof,
403406 & current_root,
0 commit comments