ark-crypto-primitives 0.6.0

A library of useful cryptographic primitives
Documentation
use crate::crh::poseidon::{TwoToOneCRH as PoseidonTwoToOneCRH, CRH as PoseidonCRH};
use crate::crh::{CRHScheme, TwoToOneCRHScheme};
use crate::merkle_tree::{Config, IdentityDigestConverter};
use crate::sponge::Absorb;
use ark_ff::PrimeField;
use ark_std::marker::PhantomData;

// Common config for a Merkle Tree using Poseidon (as seen in STIR, WHIR, WARP etc.)

#[derive(Clone)]
pub struct PoseidonMerkleConfig<F: PrimeField> {
    _field: PhantomData<F>,
}

impl<F: PrimeField + Absorb> Config for PoseidonMerkleConfig<F> {
    type Leaf = [F];
    type LeafDigest = <Self::LeafHash as CRHScheme>::Output;
    type LeafInnerDigestConverter = IdentityDigestConverter<Self::LeafDigest>;
    type InnerDigest = <Self::TwoToOneHash as TwoToOneCRHScheme>::Output;
    type LeafHash = PoseidonCRH<F>;
    type TwoToOneHash = PoseidonTwoToOneCRH<F>;
}