mirror of
https://github.com/arnaucube/arkeddsa.git
synced 2026-01-12 00:01:28 +01:00
move the poseidon_config function outside from tests
move the poseidon_config function outside from tests, since when externally using this lib usually the user will also use the poseidon_config helper to generate the poseidon config to be used in the signature
This commit is contained in:
@@ -51,18 +51,17 @@ where
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use crate::ed_on_bn254_twist::{
|
|
||||||
constraints::EdwardsVar as GVar, BaseField as Fq, EdwardsConfig, EdwardsProjective as G,
|
|
||||||
ScalarField as Fr,
|
|
||||||
};
|
|
||||||
use ark_ff::PrimeField;
|
use ark_ff::PrimeField;
|
||||||
use ark_r1cs_std::{alloc::AllocVar, eq::EqGadget, fields::nonnative::NonNativeFieldVar};
|
use ark_r1cs_std::{alloc::AllocVar, eq::EqGadget, fields::nonnative::NonNativeFieldVar};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::r1cs::ConstraintSystem;
|
||||||
use rand_core::OsRng;
|
use rand_core::OsRng;
|
||||||
|
|
||||||
use crate::test::poseidon_config;
|
use super::*;
|
||||||
use crate::SigningKey;
|
use crate::ed_on_bn254_twist::{
|
||||||
|
constraints::EdwardsVar as GVar, BaseField as Fq, EdwardsConfig, EdwardsProjective as G,
|
||||||
|
ScalarField as Fr,
|
||||||
|
};
|
||||||
|
use crate::{poseidon_config, SigningKey};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn gadget_verify() {
|
fn gadget_verify() {
|
||||||
|
|||||||
31
src/lib.rs
31
src/lib.rs
@@ -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,19 +32,6 @@ impl core::fmt::Display for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ark_std::error::Error for Error {}
|
|
||||||
|
|
||||||
#[cfg(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_ec::twisted_edwards::TECurveConfig;
|
|
||||||
use ark_ff::PrimeField;
|
|
||||||
use digest::Digest;
|
|
||||||
use rand_core::OsRng;
|
|
||||||
|
|
||||||
/// Generates poseidon constants and returns the config
|
/// Generates poseidon constants and returns the config
|
||||||
pub fn poseidon_config<F: PrimeField>(
|
pub fn poseidon_config<F: PrimeField>(
|
||||||
rate: usize,
|
rate: usize,
|
||||||
@@ -59,6 +49,17 @@ mod test {
|
|||||||
PoseidonConfig::new(full_rounds, partial_rounds, 5, mds, ark, rate, 1)
|
PoseidonConfig::new(full_rounds, partial_rounds, 5, mds, ark, rate, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use ark_crypto_primitives::sponge::Absorb;
|
||||||
|
use ark_ec::twisted_edwards::TECurveConfig;
|
||||||
|
use ark_ff::PrimeField;
|
||||||
|
use digest::Digest;
|
||||||
|
use rand_core::OsRng;
|
||||||
|
|
||||||
|
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
|
||||||
TE::BaseField: Absorb + PrimeField,
|
TE::BaseField: Absorb + PrimeField,
|
||||||
|
|||||||
Reference in New Issue
Block a user