Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
WizardOfMenlo committed Oct 22, 2024
1 parent c506917 commit c674966
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/crypto/merkle_tree/blake3.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{borrow::Borrow, marker::PhantomData};

use super::HashCounter;
use super::{HashCounter, IdentityDigestConverter};
use ark_crypto_primitives::{
crh::{CRHScheme, TwoToOneCRHScheme},
merkle_tree::{Config, IdentityDigestConverter},
merkle_tree::Config,
sponge::Absorb,
};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/merkle_tree/keccak.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{borrow::Borrow, marker::PhantomData};

use super::HashCounter;
use super::{HashCounter, IdentityDigestConverter};
use ark_crypto_primitives::{
crh::{CRHScheme, TwoToOneCRHScheme},
merkle_tree::{Config, IdentityDigestConverter},
merkle_tree::Config,
sponge::Absorb,
};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
Expand Down
14 changes: 13 additions & 1 deletion src/crypto/merkle_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod mock;

use std::{borrow::Borrow, marker::PhantomData, sync::atomic::AtomicUsize};

use ark_crypto_primitives::crh::CRHScheme;
use ark_crypto_primitives::{crh::CRHScheme, merkle_tree::DigestConverter, Error};
use ark_serialize::CanonicalSerialize;
use lazy_static::lazy_static;
use rand::RngCore;
Expand Down Expand Up @@ -59,3 +59,15 @@ impl<F: CanonicalSerialize + Send> CRHScheme for LeafIdentityHasher<F> {
Ok(buf)
}
}

/// A trivial converter where digest of previous layer's hash is the same as next layer's input.
pub struct IdentityDigestConverter<T> {
_prev_layer_digest: T,
}

impl<T> DigestConverter<T, T> for IdentityDigestConverter<T> {
type TargetType = T;
fn convert(item: T) -> Result<T, Error> {
Ok(item)
}
}

0 comments on commit c674966

Please sign in to comment.