Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo changes in 0960300 #154

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions crypto-primitives/src/merkle_tree/constraints.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
crh::{CRHSchemeGadget, TwoToOneCRHSchemeGadget},
merkle_tree::{Config, Path},
merkle_tree::{Config, IdentityDigestConverter, Path},
};
use ark_ff::PrimeField;
use ark_r1cs_std::prelude::*;
Expand All @@ -9,15 +9,11 @@ use ark_relations::r1cs::{Namespace, SynthesisError};
use ark_std::vec::Vec;
use ark_std::{borrow::Borrow, fmt::Debug};

#[cfg(test)]
use crate::merkle_tree::IdentityDigestConverter;

pub trait DigestVarConverter<From, To: ?Sized> {
type TargetType: Borrow<To>;
fn convert(from: From) -> Result<Self::TargetType, SynthesisError>;
}

#[cfg(test)]
impl<T> DigestVarConverter<T, T> for IdentityDigestConverter<T> {
type TargetType = T;

Expand Down
11 changes: 6 additions & 5 deletions crypto-primitives/src/merkle_tree/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![allow(clippy::needless_range_loop)]

use core::hash::BuildHasherDefault;

/// Defines a trait to chain two types of CRHs.
use crate::{
crh::{CRHScheme, TwoToOneCRHScheme},
Expand All @@ -11,7 +9,12 @@ use crate::{
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
#[cfg(not(feature = "std"))]
use ark_std::vec::Vec;
use ark_std::{borrow::Borrow, collections::BTreeSet, fmt::Debug, hash::Hash};
use ark_std::{
borrow::Borrow,
collections::BTreeSet,
fmt::Debug,
hash::{BuildHasherDefault, Hash},
};
use hashbrown::HashMap;
#[cfg(feature = "parallel")]
use rayon::prelude::*;
Expand Down Expand Up @@ -48,12 +51,10 @@ pub trait DigestConverter<From, To: ?Sized> {
}

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

#[cfg(test)]
impl<T> DigestConverter<T, T> for IdentityDigestConverter<T> {
type TargetType = T;
fn convert(item: T) -> Result<T, Error> {
Expand Down
Loading