@ -1,3 +1,8 @@
use ark_ff ::PrimeField ;
use digest ::Digest ;
impl ark_std ::error ::Error for Error { }
use ark_crypto_primitives ::sponge ::poseidon ::{ find_poseidon_ark_and_mds , PoseidonConfig } ;
pub mod ed_on_bn254_twist ;
pub mod ed_on_bn254_twist ;
pub mod eddsa ;
pub mod eddsa ;
pub mod signature ;
pub mod signature ;
@ -5,8 +10,6 @@ pub mod signature;
#[ cfg(feature = " r1cs " ) ]
#[ cfg(feature = " r1cs " ) ]
pub mod constraints ;
pub mod constraints ;
use ark_ff ::PrimeField ;
use digest ::Digest ;
pub use eddsa ::* ;
pub use eddsa ::* ;
pub ( crate ) fn from_digest < F : PrimeField , D : Digest > ( digest : D ) -> F {
pub ( crate ) fn from_digest < F : PrimeField , D : Digest > ( digest : D ) -> F {
@ -29,35 +32,33 @@ impl core::fmt::Display for Error {
}
}
}
}
impl ark_std ::error ::Error for Error { }
/// Generates poseidon constants and returns the config
pub fn poseidon_config < F : PrimeField > (
rate : usize ,
full_rounds : usize ,
partial_rounds : usize ,
) -> PoseidonConfig < F > {
let prime_bits = F ::MODULUS_BIT_SIZE as u64 ;
let ( ark , mds ) = find_poseidon_ark_and_mds (
prime_bits ,
rate ,
full_rounds as u64 ,
partial_rounds as u64 ,
0 ,
) ;
PoseidonConfig ::new ( full_rounds , partial_rounds , 5 , mds , ark , rate , 1 )
}
#[ cfg(test) ]
#[ cfg(test) ]
mod test {
mod test {
use crate ::SigningKey ;
use ark_crypto_primitives ::sponge ::poseidon ::{ find_poseidon_ark_and_mds , PoseidonConfig } ;
use ark_crypto_primitives ::sponge ::Absorb ;
use ark_crypto_primitives ::sponge ::Absorb ;
use ark_ec ::twisted_edwards ::TECurveConfig ;
use ark_ec ::twisted_edwards ::TECurveConfig ;
use ark_ff ::PrimeField ;
use ark_ff ::PrimeField ;
use digest ::Digest ;
use digest ::Digest ;
use rand_core ::OsRng ;
use rand_core ::OsRng ;
/// Generates poseidon constants and returns the config
pub fn poseidon_config < F : PrimeField > (
rate : usize ,
full_rounds : usize ,
partial_rounds : usize ,
) -> PoseidonConfig < F > {
let prime_bits = F ::MODULUS_BIT_SIZE as u64 ;
let ( ark , mds ) = find_poseidon_ark_and_mds (
prime_bits ,
rate ,
full_rounds as u64 ,
partial_rounds as u64 ,
0 ,
) ;
PoseidonConfig ::new ( full_rounds , partial_rounds , 5 , mds , ark , rate , 1 )
}
use super ::poseidon_config ;
use crate ::SigningKey ;
fn run_test < TE : TECurveConfig + Clone , D : Digest > ( )
fn run_test < TE : TECurveConfig + Clone , D : Digest > ( )
where
where