Browse Source

BN254 and Grumpkin Poseidon configurations (#106)

* Add BN254 and Grumpkin Poseidon configurations

* Remove unncecessary comment

* Fix BN254 Poseidon config test

* Correction

* Update folding-schemes/src/transcript/poseidon/grumpkin.rs

Co-authored-by: Pierre <pdaixmoreux@gmail.com>

---------

Co-authored-by: Pierre <pdaixmoreux@gmail.com>
update-nifs-interface
Ahmad Afuni 5 months ago
committed by GitHub
parent
commit
852134a898
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
23 changed files with 1197 additions and 76 deletions
  1. +3
    -3
      examples/external_inputs.rs
  2. +2
    -2
      examples/utils.rs
  3. +1
    -0
      folding-schemes/Cargo.toml
  4. +3
    -3
      folding-schemes/src/commitment/ipa.rs
  5. +2
    -2
      folding-schemes/src/commitment/kzg.rs
  6. +2
    -2
      folding-schemes/src/commitment/mod.rs
  7. +2
    -2
      folding-schemes/src/commitment/pedersen.rs
  8. +2
    -2
      folding-schemes/src/folding/circuits/sum_check.rs
  9. +5
    -5
      folding-schemes/src/folding/hypernova/nimfs.rs
  10. +3
    -3
      folding-schemes/src/folding/nova/circuits.rs
  11. +3
    -3
      folding-schemes/src/folding/nova/cyclefold.rs
  12. +2
    -2
      folding-schemes/src/folding/nova/decider_eth.rs
  13. +3
    -3
      folding-schemes/src/folding/nova/decider_eth_circuit.rs
  14. +2
    -2
      folding-schemes/src/folding/nova/mod.rs
  15. +2
    -2
      folding-schemes/src/folding/nova/nifs.rs
  16. +3
    -3
      folding-schemes/src/folding/protogalaxy/folding.rs
  17. +45
    -31
      folding-schemes/src/transcript/poseidon.rs
  18. +574
    -0
      folding-schemes/src/transcript/poseidon/bn254.rs
  19. +519
    -0
      folding-schemes/src/transcript/poseidon/grumpkin.rs
  20. +2
    -2
      folding-schemes/src/utils/espresso/sum_check/mod.rs
  21. +13
    -0
      folding-schemes/src/utils/vec.rs
  22. +2
    -2
      solidity-verifiers/src/verifiers/kzg.rs
  23. +2
    -2
      solidity-verifiers/src/verifiers/nova_cyclefold.rs

+ 3
- 3
examples/external_inputs.rs

@ -25,7 +25,7 @@ use folding_schemes::folding::nova::Nova;
use folding_schemes::frontend::FCircuit;
use folding_schemes::{Error, FoldingScheme};
mod utils;
use folding_schemes::transcript::poseidon::poseidon_test_config;
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
use utils::init_nova_ivc_params;
/// This is the circuit that we want to fold, it implements the FCircuit trait. The parameter z_i
@ -131,7 +131,7 @@ pub mod tests {
// test to check that the ExternalInputsCircuits computes the same values inside and outside the circuit
#[test]
fn test_f_circuit() {
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let cs = ConstraintSystem::<Fr>::new_ref();
@ -169,7 +169,7 @@ fn main() {
];
assert_eq!(external_inputs.len(), num_steps);
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let F_circuit = ExternalInputsCircuits::<Fr>::new(poseidon_config).unwrap();
println!("Prepare Nova ProverParams & VerifierParams");

+ 2
- 2
examples/utils.rs

@ -21,7 +21,7 @@ use folding_schemes::{
decider_eth_circuit::DeciderEthCircuit, get_r1cs, Nova, ProverParams, VerifierParams,
},
frontend::FCircuit,
transcript::poseidon::poseidon_test_config,
transcript::poseidon::poseidon_canonical_config,
FoldingScheme,
};
@ -37,7 +37,7 @@ pub(crate) fn init_nova_ivc_params>(
KZGVerifierKey<Bn254>,
) {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// get the CM & CF_CM len
let (r1cs, cf_r1cs) = get_r1cs::<G1, GVar, G2, GVar2, FC>(&poseidon_config, F_circuit).unwrap();

+ 1
- 0
folding-schemes/Cargo.toml

@ -9,6 +9,7 @@ ark-ff = "^0.4.0"
ark-poly = "^0.4.0"
ark-std = "^0.4.0"
ark-crypto-primitives = { version = "^0.4.0", default-features = false, features = ["r1cs", "sponge", "crh"] }
ark-grumpkin = {version="0.4.0"}
ark-poly-commit = "^0.4.0"
ark-relations = { version = "^0.4.0", default-features = false }
ark-r1cs-std = { version = "0.4.0", default-features = false } # this is patched at the workspace level

+ 3
- 3
folding-schemes/src/commitment/ipa.rs

@ -567,7 +567,7 @@ mod tests {
use std::ops::Mul;
use super::*;
use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript};
use crate::transcript::poseidon::{poseidon_canonical_config, PoseidonTranscript};
#[test]
fn test_ipa() {
@ -583,7 +583,7 @@ mod tests {
// setup params
let (params, _) = IPA::<Projective, hiding>::setup(&mut rng, d).unwrap();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// init Prover's transcript
let mut transcript_p = PoseidonTranscript::<Projective>::new(&poseidon_config);
// init Verifier's transcript
@ -627,7 +627,7 @@ mod tests {
// setup params
let (params, _) = IPA::<Projective, hiding>::setup(&mut rng, d).unwrap();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// init Prover's transcript
let mut transcript_p = PoseidonTranscript::<Projective>::new(&poseidon_config);
// init Verifier's transcript

+ 2
- 2
folding-schemes/src/commitment/kzg.rs

@ -244,12 +244,12 @@ mod tests {
use ark_std::{test_rng, UniformRand};
use super::*;
use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript};
use crate::transcript::poseidon::{poseidon_canonical_config, PoseidonTranscript};
#[test]
fn test_kzg_commitment_scheme() {
let mut rng = &mut test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let transcript_p = &mut PoseidonTranscript::<G1>::new(&poseidon_config);
let transcript_v = &mut PoseidonTranscript::<G1>::new(&poseidon_config);

+ 2
- 2
folding-schemes/src/commitment/mod.rs

@ -78,14 +78,14 @@ mod tests {
use super::kzg::{ProverKey, KZG};
use super::pedersen::Pedersen;
use crate::transcript::{
poseidon::{poseidon_test_config, PoseidonTranscript},
poseidon::{poseidon_canonical_config, PoseidonTranscript},
Transcript,
};
#[test]
fn test_homomorphic_property_using_Commitment_trait() {
let mut rng = &mut test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let n: usize = 128;
// set random vector for the test

+ 2
- 2
folding-schemes/src/commitment/pedersen.rs

@ -216,7 +216,7 @@ mod tests {
use ark_std::UniformRand;
use super::*;
use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript};
use crate::transcript::poseidon::{poseidon_canonical_config, PoseidonTranscript};
#[test]
fn test_pedersen() {
@ -229,7 +229,7 @@ mod tests {
let n: usize = 10;
// setup params
let (params, _) = Pedersen::<Projective>::setup(&mut rng, n).unwrap();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// init Prover's transcript
let mut transcript_p = PoseidonTranscript::<Projective>::new(&poseidon_config);

+ 2
- 2
folding-schemes/src/folding/circuits/sum_check.rs

@ -173,7 +173,7 @@ mod tests {
use crate::{
folding::circuits::sum_check::{IOPProofVar, VPAuxInfoVar},
transcript::{
poseidon::{poseidon_test_config, PoseidonTranscript, PoseidonTranscriptVar},
poseidon::{poseidon_canonical_config, PoseidonTranscript, PoseidonTranscriptVar},
Transcript, TranscriptVar,
},
utils::{
@ -207,7 +207,7 @@ mod tests {
{
let mut rng = ark_std::test_rng();
let poseidon_config: PoseidonConfig<C::ScalarField> =
poseidon_test_config::<C::ScalarField>();
poseidon_canonical_config::<C::ScalarField>();
let mut poseidon_transcript_prove = PoseidonTranscript::<C>::new(&poseidon_config);
let poly_mle = DenseMultilinearExtension::rand(num_vars, &mut rng);
let virtual_poly =

+ 5
- 5
folding-schemes/src/folding/hypernova/nimfs.rs

@ -374,7 +374,7 @@ where
pub mod tests {
use super::*;
use crate::ccs::tests::{get_test_ccs, get_test_z};
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
use crate::transcript::poseidon::PoseidonTranscript;
use ark_std::test_rng;
use ark_std::UniformRand;
@ -446,7 +446,7 @@ pub mod tests {
let (new_instance, w2) = ccs.to_cccs(&mut rng, &pedersen_params, &z_2).unwrap();
// Prover's transcript
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let mut transcript_p: PoseidonTranscript<Projective> =
PoseidonTranscript::<Projective>::new(&poseidon_config);
transcript_p.absorb(&Fr::from_le_bytes_mod_order(b"init init"));
@ -500,7 +500,7 @@ pub mod tests {
let (mut running_instance, mut w1) =
ccs.to_lcccs(&mut rng, &pedersen_params, &z_1).unwrap();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let mut transcript_p: PoseidonTranscript<Projective> =
PoseidonTranscript::<Projective>::new(&poseidon_config);
@ -597,7 +597,7 @@ pub mod tests {
}
// Prover's transcript
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let mut transcript_p: PoseidonTranscript<Projective> =
PoseidonTranscript::<Projective>::new(&poseidon_config);
transcript_p.absorb(&Fr::from_le_bytes_mod_order(b"init init"));
@ -647,7 +647,7 @@ pub mod tests {
let (pedersen_params, _) =
Pedersen::<Projective>::setup(&mut rng, ccs.n - ccs.l - 1).unwrap();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// Prover's transcript
let mut transcript_p: PoseidonTranscript<Projective> =
PoseidonTranscript::<Projective>::new(&poseidon_config);

+ 3
- 3
folding-schemes/src/folding/nova/circuits.rs

@ -559,7 +559,7 @@ pub mod tests {
use crate::commitment::pedersen::Pedersen;
use crate::folding::nova::nifs::tests::prepare_simple_fold_inputs;
use crate::folding::nova::nifs::NIFS;
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
#[test]
fn test_committed_instance_var() {
@ -615,7 +615,7 @@ pub mod tests {
#[test]
fn test_committed_instance_hash() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let i = Fr::from(3_u32);
let z_0 = vec![Fr::from(3_u32)];
@ -654,7 +654,7 @@ pub mod tests {
#[test]
fn test_challenge_gadget() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let u_i = CommittedInstance::<Projective> {
cmE: Projective::rand(&mut rng),

+ 3
- 3
folding-schemes/src/folding/nova/cyclefold.rs

@ -377,7 +377,7 @@ pub mod tests {
use crate::folding::nova::get_cm_coordinates;
use crate::folding::nova::nifs::tests::prepare_simple_fold_inputs;
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
#[test]
fn test_committed_instance_cyclefold_var() {
@ -488,7 +488,7 @@ pub mod tests {
#[test]
fn test_cyclefold_challenge_gadget() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fq>();
let poseidon_config = poseidon_canonical_config::<Fq>();
let u_i = CommittedInstance::<Projective> {
cmE: Projective::zero(), // zero on purpose, so we test also the zero point case
@ -550,7 +550,7 @@ pub mod tests {
#[test]
fn test_cyclefold_hash_gadget() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fq>();
let poseidon_config = poseidon_canonical_config::<Fq>();
let U_i = CommittedInstance::<Projective> {
cmE: Projective::rand(&mut rng),

+ 2
- 2
folding-schemes/src/folding/nova/decider_eth.rs

@ -292,7 +292,7 @@ pub mod tests {
use crate::commitment::pedersen::Pedersen;
use crate::folding::nova::{get_cs_params_len, ProverParams};
use crate::frontend::tests::CubicFCircuit;
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
#[test]
fn test_decider() {
@ -319,7 +319,7 @@ pub mod tests {
>;
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let F_circuit = CubicFCircuit::<Fr>::new(()).unwrap();
let z_0 = vec![Fr::from(3_u32)];

+ 3
- 3
folding-schemes/src/folding/nova/decider_eth_circuit.rs

@ -614,7 +614,7 @@ pub mod tests {
use crate::commitment::pedersen::Pedersen;
use crate::folding::nova::{get_cs_params_len, ProverParams, VerifierParams};
use crate::frontend::tests::{CubicFCircuit, CustomFCircuit, WrapperCircuit};
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
use crate::FoldingScheme;
use crate::ccs::r1cs::tests::{get_test_r1cs, get_test_z};
@ -768,7 +768,7 @@ pub mod tests {
#[test]
fn test_decider_circuit() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let F_circuit = CubicFCircuit::<Fr>::new(()).unwrap();
let z_0 = vec![Fr::from(3_u32)];
@ -843,7 +843,7 @@ pub mod tests {
#[test]
fn test_kzg_challenge_gadget() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let U_i = CommittedInstance::<Projective> {
cmE: Projective::rand(&mut rng),

+ 2
- 2
folding-schemes/src/folding/nova/mod.rs

@ -815,14 +815,14 @@ pub mod tests {
use crate::commitment::pedersen::Pedersen;
use crate::frontend::tests::CubicFCircuit;
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
/// This test tests the Nova+CycleFold IVC, and by consequence it is also testing the
/// AugmentedFCircuit
#[test]
fn test_ivc() {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let F_circuit = CubicFCircuit::<Fr>::new(()).unwrap();

+ 2
- 2
folding-schemes/src/folding/nova/nifs.rs

@ -209,7 +209,7 @@ pub mod tests {
use crate::commitment::pedersen::{Params as PedersenParams, Pedersen};
use crate::folding::nova::circuits::ChallengeGadget;
use crate::folding::nova::traits::NovaR1CS;
use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript};
use crate::transcript::poseidon::{poseidon_canonical_config, PoseidonTranscript};
#[allow(clippy::type_complexity)]
pub(crate) fn prepare_simple_fold_inputs<C>() -> (
@ -257,7 +257,7 @@ pub mod tests {
NIFS::<C, Pedersen<C>>::compute_cmT(&pedersen_params, &r1cs, &w1, &ci1, &w2, &ci2)
.unwrap();
let poseidon_config = poseidon_test_config::<C::ScalarField>();
let poseidon_config = poseidon_canonical_config::<C::ScalarField>();
let r_bits = ChallengeGadget::<C>::get_challenge_native(
&poseidon_config,

+ 3
- 3
folding-schemes/src/folding/protogalaxy/folding.rs

@ -385,7 +385,7 @@ mod tests {
use crate::ccs::r1cs::tests::{get_test_r1cs, get_test_z};
use crate::commitment::{pedersen::Pedersen, CommitmentScheme};
use crate::transcript::poseidon::{poseidon_test_config, PoseidonTranscript};
use crate::transcript::poseidon::{poseidon_canonical_config, PoseidonTranscript};
pub(crate) fn check_instance<C: CurveGroup>(
r1cs: &R1CS<C::ScalarField>,
@ -512,7 +512,7 @@ mod tests {
let r1cs = get_test_r1cs::<Fr>();
// init Prover & Verifier's transcript
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let mut transcript_p = PoseidonTranscript::<Projective>::new(&poseidon_config);
let mut transcript_v = PoseidonTranscript::<Projective>::new(&poseidon_config);
@ -552,7 +552,7 @@ mod tests {
let r1cs = get_test_r1cs::<Fr>();
// init Prover & Verifier's transcript
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let mut transcript_p = PoseidonTranscript::<Projective>::new(&poseidon_config);
let mut transcript_v = PoseidonTranscript::<Projective>::new(&poseidon_config);

+ 45
- 31
folding-schemes/src/transcript/poseidon.rs

@ -1,3 +1,7 @@
mod bn254;
mod grumpkin;
use ark_bn254::Fr as Bn254_Fr;
use ark_crypto_primitives::sponge::{
constraints::CryptographicSpongeVar,
poseidon::{constraints::PoseidonSpongeVar, PoseidonConfig, PoseidonSponge},
@ -5,6 +9,7 @@ use ark_crypto_primitives::sponge::{
};
use ark_ec::{AffineRepr, CurveGroup, Group};
use ark_ff::{BigInteger, Field, PrimeField};
use ark_grumpkin::Fr as Grumpkin_Fr;
use ark_r1cs_std::{boolean::Boolean, fields::fp::FpVar};
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
use ark_std::Zero;
@ -115,46 +120,55 @@ impl TranscriptVar for PoseidonTranscriptVar {
}
}
/// WARNING the method poseidon_test_config is for tests only
pub fn poseidon_test_config<F: PrimeField>() -> PoseidonConfig<F> {
let full_rounds = 8;
let partial_rounds = 31;
let alpha = 5;
let rate = 2;
let (ark, mds) = ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds::<F>(
F::MODULUS_BIT_SIZE as u64,
rate,
full_rounds,
partial_rounds,
0,
);
PoseidonConfig::new(
full_rounds as usize,
partial_rounds as usize,
alpha,
mds,
ark,
rate,
1,
)
/// This Poseidon configuration generator agrees with Circom's Poseidon(4) in the case of BN254's scalar field and
/// makes use of the constants generated by the reference implementation script in the case of Grumpkin's scalar field.
pub fn poseidon_canonical_config<F: PrimeField>() -> PoseidonConfig<F> {
let field_modulus_bytes = F::MODULUS.to_bytes_be();
if field_modulus_bytes == Bn254_Fr::MODULUS.to_bytes_be() {
bn254::poseidon_config::<F>()
} else if field_modulus_bytes == Grumpkin_Fr::MODULUS.to_bytes_be() {
grumpkin::poseidon_config::<F>()
} else {
let full_rounds = 8;
let partial_rounds = 31;
let alpha = 5;
let rate = 2;
let (ark, mds) = ark_crypto_primitives::sponge::poseidon::find_poseidon_ark_and_mds::<F>(
F::MODULUS_BIT_SIZE as u64,
rate,
full_rounds,
partial_rounds,
0,
);
PoseidonConfig::new(
full_rounds as usize,
partial_rounds as usize,
alpha,
mds,
ark,
rate,
1,
)
}
}
#[cfg(test)]
pub mod tests {
use super::*;
use ark_pallas::{constraints::GVar, Fq, Fr, Projective};
use ark_bn254::{constraints::GVar, Fq, Fr, G1Projective as G1};
use ark_grumpkin::Projective;
use ark_r1cs_std::{alloc::AllocVar, groups::CurveVar, R1CSVar};
use ark_relations::r1cs::ConstraintSystem;
use ark_vesta::Projective as E2Projective;
use std::ops::Mul;
#[test]
fn test_transcript_and_transcriptvar_get_challenge() {
// use 'native' transcript
let config = poseidon_test_config::<Fr>();
let mut tr = PoseidonTranscript::<Projective>::new(&config);
let config = poseidon_canonical_config::<Fr>();
let mut tr = PoseidonTranscript::<G1>::new(&config);
tr.absorb(&Fr::from(42_u32));
let c = tr.get_challenge();
@ -174,8 +188,8 @@ pub mod tests {
let nbits = crate::constants::N_BITS_RO;
// use 'native' transcript
let config = poseidon_test_config::<Fq>();
let mut tr = PoseidonTranscript::<E2Projective>::new(&config);
let config = poseidon_canonical_config::<Fq>();
let mut tr = PoseidonTranscript::<Projective>::new(&config);
tr.absorb(&Fq::from(42_u32));
// get challenge from native transcript
@ -190,7 +204,7 @@ pub mod tests {
// get challenge from circuit transcript
let c_var = tr_var.get_challenge_nbits(nbits).unwrap();
let P = Projective::generator();
let P = G1::generator();
let PVar = GVar::new_witness(cs.clone(), || Ok(P)).unwrap();
// multiply point P by the challenge in different formats, to ensure that we get the same

+ 574
- 0
folding-schemes/src/transcript/poseidon/bn254.rs

@ -0,0 +1,574 @@
use crate::utils::vec::mat_from_str_mat;
use ark_bn254::Fr;
use ark_crypto_primitives::sponge::poseidon::PoseidonConfig;
use ark_ff::{BigInteger, PrimeField};
// Constants chosen to agree with Circom's choice for Poseidon(5),
// which is the recommended width for this field according to §3 of
// https://eprint.iacr.org/2019/458.pdf
pub(crate) fn constants<F: PrimeField>() -> (Vec<Vec<F>>, Vec<Vec<F>>) {
assert_eq!(
F::MODULUS.to_bytes_be(),
Fr::MODULUS.to_bytes_be(),
"The prime field must be isomorphic to BN254's scalar field."
);
let ark_string: Vec<Vec<&'static str>> = vec![
vec![
"6652655389322448471317061533546982911992554640679550674058582942754771150993",
"2411464732857349694082092299330329691469354396507353145272547491824343787723",
"21491443688002139478732659842894153142870918973450440713149176834049574486740",
"20196926676989483530222124573030747187074792043523478381149800153065505592963",
"12986278951352369831003505493892366673723882190521699331613883287145355738793",
],
vec![
"21126146258242782643168619000295062005037298340836817770565977031890883232034",
"15509665795506578582538177431401381655815033647735781734613703976071034655246",
"6989769181472743404364681671283889685042701491627165526899522083327752110839",
"7062179885254277466334896166987547257487047183881628199983668518000910197987",
"13842521112365108087725039904948872289730786568469683976372377853164252494752",
],
vec![
"3830559505943186272618534143266118508463381443414165428900505002474439179836",
"17704863473432653834041116667846189591617394753001613253930974854399793083900",
"875580502229441633079974792778818749112423694973231971690365132230865385439",
"1971134273535892826573832061354985059300866001765691176219451252512658771248",
"4865738840363990164915013008693722144676933915103280504727326977328013515878",
],
vec![
"1148603338028060679975883868174895825055359423662532941509525326937127571764",
"17506086433923270253695698017062834613463718526046463655503742220257039588796",
"21580033018107258179208198773211859664893072138803756118939260252922297665067",
"15411900706973212043830142913959920716501447427702082030760032355626616412240",
"12219699506725448409610279620972339448030565224304464695714944121760832152291",
],
vec![
"4525719544192047521328360848269156485222470829314314216955024799558286708479",
"19667371373588322336224317159113441765198420040800065314868656839300028747331",
"18916925604689704279265158984702141998345424765142129953154245912230835240445",
"12789343981741773931665143789673052782408749041041266509485929045869073416222",
"3094428508959717445577232225505810354980663487713729230015754183012845687401",
],
vec![
"18544590634480965569098056786078005630500574069468005220462377474861119476492",
"20990087440247450018723844204951613913840993427110495085701200965767234569705",
"17552251989761134508416634118845221324472178264364440017634233349418103869223",
"21000797802575507763447855752602183842956182733750968489641741136166640639409",
"19292751508591545849778577901067988044973302547209758604667395356943370737868",
],
vec![
"18314088316445539319869442180584299715533304874169767778761887632882728399870",
"15003745150856597539000559910957155642193629735521291045949652201905498569732",
"7839443900003691950104175747634267110464104444913379977500178134209666299140",
"13568305490393393394812598233983935295266242465548739772708079888867621061127",
"6453005227995051361096639028742707098785560656441339640433794156400437698140",
],
vec![
"1420171596348195609536167209221442141824294918625468780931400849866478645240",
"8347329128252205996443084339884155586061343024498283583400215109265013719709",
"7893774494551056447960817286805128884970061671041428326788899872964096959040",
"8970476243368194065341537088653900235777512204874037182428362347342487241690",
"239049405935404678508864874854718951364753739466303321590415544572014148257",
],
vec![
"15772878921699764223771017074289335629553777447709755479885293350677783703695",
"5416082112919155131434995906647355834510201879607888732259087164602171650389",
"4384524908062410354304345761652962203632712291085564157560146286207296352050",
"4210984612917608245844011498198864216639269565627982123611519493203177283139",
"18816442907032290878644773027005263628136050677095986565400687355912498966559",
],
vec![
"21443510232279945782338486087712914668515437675585863788610958361560172084515",
"3234314779308300525339049581669531363375743827111579883853941968586490182859",
"11029499234949696730080035941750777601416171837281021031653841244636590396063",
"11145210633226924132308292113124660576759662647204939721872338908644906571564",
"4583160563963432761409369246361117506465307518522062239686649163525543782173",
],
vec![
"9813992026757562966842771727657080117609486122615087352428596024939855084450",
"10084171857039480706430282187972782725948479260179367780776125786119489581409",
"3874212709197875589640151274548083098712939093643165182881681226579903752816",
"21595542491397091124739711708612983479307589335640792812157875295064235960610",
"2068530815441314105493629066002923150651375034543842424822712297257260726954",
],
vec![
"2673459852071215292298131389250564595426361004231758522146794940265552265806",
"8591046256746588406353455230465605224309754008961178558834659065898923355164",
"1020055192431352394776887540248098706183934464205704158014904833376067287118",
"11085709480582865378042656141271006552092494690130782253913953070642865919312",
"5673844083530503489429922596812992664928167369104420134641855283771127716005",
],
vec![
"10492199162275168254265892158402955076490959375050993042712629236807564461542",
"2280843393156259739329331366624245275580688891778782679394848304764573859886",
"6807797027131305026345508953353882265754363485246407959111359919046340709440",
"12692191384043938397944633973317584101723715998700063415107128429315536223446",
"19818676957110967644349139912613239435706480354664804036688552936554140369382",
],
vec![
"18055602608192644695569077694296748842203151828348990995792087204755925787339",
"20934555391215769430553078793246717148484784880715746179415906355043590089450",
"11420705181439111353998210442417752592951340005396931802449360401461783159557",
"19878854521263746227125001670931867821366047088989510542865511663910116386085",
"8568201846715449867087132677683368912214864824182424933182820310911278496552",
],
vec![
"19198701614488576617610339232794062430644024620523684127268879880793305460015",
"15262122764244854433806270478871594904740306012582364033343126589996733802868",
"6412758421155818207287638337822550233376667015263373809976157264137577776202",
"17371585001641430978766734501830788427263945848682170096055857509304472649262",
"20262970042379497707724791203314262108784948621691331141565359315001027736581",
],
vec![
"3859750447119748295302212198327542106766447958113540005985799287718502362717",
"1172269945800307665458943534144481495673510885455899148864236015097947176746",
"8164247467959680477306326470118519335673181279975551434197731340070491876250",
"4513977811114181395323888111232002391599397736872779927267726121435887238972",
"1075250595927474080680862736233039825365918646878264905022213616210377518447",
],
vec![
"18658420120424372681792175914064174056413842231969276203770574969914576681364",
"17769673440848360838244654765103041739044212539359630263894092078288342647801",
"4319086204044362848967484441065231939136453667264715596505827197873119273506",
"11221173270629292820060668122527062274557317856738971635698169204652845111606",
"8635411372759272135249379415383299350267629947167809163276219879514948820576",
],
vec![
"926977621651476360285369760355547766944001783780761167546467658394097283069",
"17702143780592866375901805387463459229828093905183622296234691441436877570082",
"629612289140842594504574984021125242351317893847688437087866691775821981724",
"19990548577495092294245865870717186004301934545721835081514347926537975465539",
"7124830628609719908679298707909792306162298058570958688501370177898647946696",
],
vec![
"14620227791860703231425817538142948793892390269806790476396226159679984968174",
"18495581997440241868332244230687799183899751339442721677540757155760745277888",
"16922065056093401385376103551657968760602009001905886435813054626317776258714",
"9969610601962874779035054685661667941954971427956866645694064022029705170229",
"15281641269114187762159685323068136816556739502211864119670902056596295644116",
],
vec![
"12114994625438879103001132949163961965524612903017200394727056658298824651596",
"4840986177718281128440833017205097196672382395936939379498412745183060615212",
"12847307562796769659308999092658905656250954898192781948610713494470441775991",
"20290096217351155282642224215178246911041509999959311313223857240001143893317",
"16151664509646153154405691138084115125600386733136285504828908979176781265710",
],
vec![
"13848845391482751436287906247470303487958950799995701248612703022979890932133",
"6335716166231441585596963683321661194889815181545222079376536449814718259931",
"1824302750039354704619545544386637317858342555634601563660279997221547953768",
"11327469654081586239268713126961534952233559223228327222485848924908493444712",
"10077703415170135154603829433031861799853903739210136452726077323833067256620",
],
vec![
"16368073884579385814331927334821006319227867093692644942500207970751483237405",
"10621580796499573269115131164341885791299038227955222944695715163010783205295",
"2099241376651019397894434242565225315652133572870234550073686122343103853816",
"17104632243449417396641550271977294699471083572885397875525767745512335891599",
"1935453754847256492223646005402770357836971113012418013930273797463411526183",
],
vec![
"7492761611332930896292052363224494314920390056637668407353957465667515477934",
"16836705924460095689555600825174696605443212968244843485187771119291716736958",
"16995495500678141665340056658079449793587669420913589967848082091551329904176",
"16097379973857697753436437302681608056543122759719328497348770844548177814262",
"17476569537128329379528694049566216604638194592812108658767104922628767500420",
],
vec![
"17997217989870184804787026924935938133194070033518938653831611194683423549591",
"17573343771046232580761295935281170028624495346579002725814597714902588657750",
"2450087639204541254902859018960918562514681200270997307467560465282168310665",
"17288084325555056222618040923753050382954155896826087372317882602328092535440",
"21837047676579063581498107773514419735425738753079336764356909012851439336687",
],
vec![
"370061273472837873736743292149368449614309676635341873070086681342317566380",
"420725183996224279379885018872359102189091670793820517618337092091910692771",
"4966571645678139143731798992823327185758562224229132271884647901363447388530",
"5039558223429273757296118284876763395391635773837549121798873235133698166026",
"14663152729953724779401067486012084029581847325524052152795817923033297673686",
],
vec![
"7201040456590575809960214033959496417566605177095808543357813677845263237276",
"16872945504528960415453618286121813996587432836152082188694652370255998768595",
"4914824783780909279212078186433590922437371437384817332713271291839616026466",
"17503018483514413315464207189113334433424965178631599286655188843769810245465",
"4087750571011463387872022799241315348852213278729592692674275176152296405923",
],
vec![
"4006961923780091252337105595934918049936238157468198971234322013673884171131",
"4481908842184366902145805444001507554481032302978790080019710161108326487967",
"13532316826436461968093937893872910736305115143550039673102602344678825540956",
"11602986656925867325907196773754426955346837006705269228226729102186031417465",
"15306992574062791537454541745213815567999895856471097922112648012979731636068",
],
vec![
"4497571735611504561173050536899411999551839050319538712220770383407135602945",
"2571242673174714867278075260451133687893879636121064640779554188161591611843",
"7070272070524747733177730083966686149849667613589868731851816020060781720851",
"1308310289745495626002351437755820460104812708071634598163946330870933261232",
"9483468192990391193401121929514821570714432121414330663623018046165053411090",
],
vec![
"7317568349845215930675847155716598288688799068821709820024570206796617676748",
"1918505733423704616434273602054555051755671749253598966287072464475922854850",
"15158168161084905689406532256983805923258003804476527617207287404280855731962",
"6855540174355511438343304861678411868002455139032857270673849263857877330771",
"5989863238360846166935911112885654223487221280254816980802479355446167746774",
],
vec![
"20283337058688740322296928691341300752003492063748410749625272920572074851396",
"18957132189629332408653055312790838576277703952267542471751593810468444454136",
"15764518568966520670995753676429154315765754748131847346608706222194564055358",
"7192524197002826721654253762628934164676539329903087107420445743247046038858",
"142950766663597487919643890566358241353679421113406309294925836697585309311",
],
vec![
"15012262168187689680572958978610204856600235635916074406168861726626292993057",
"20795666834671497603181209610179324236645779324677512349797033323222380300794",
"12650341271833683789775531792948185319868795529390391267833516836256688318306",
"5597700232877580665749288204589530549415282468176625525368428476461504532052",
"20949303924691159143653175365242293984396858344688574262804199947001630916385",
],
vec![
"10746523145835332938672833282581864816136388045771578294905302886974358762209",
"4998982766221590779170630035756820066555357949247521575936385387288356143784",
"6936999580131731861735955554005106460473097800566952971315565150681540640020",
"6670695360676548472482680016233507548657051302712214051977034166870814430578",
"12210816592786563975173850937247594401582085430897698766795696447223454826466",
],
vec![
"14933901149105284237676334791785996160108290333321693498322435129559137152007",
"3848529433916624869590379003597911090976938589461403388133685310398004369431",
"12778805225074604003024964969486878839359935515509480774809299341511161183802",
"3288267180428684202786697419666969564766921974531343432588030535602163038467",
"1272672432174256751826350693883913844502039730140570583479554071765667798207",
],
vec![
"21130828804874452930669244946376257892693846272313548250936991077452679117587",
"21254559353072473881932828401787134230282801383134765683324465204971002861493",
"4116075860631781527931204624078712926526805345818156200756399332393348685924",
"17435888597009729827411190999389277840088354756277916760187756022854497211746",
"15837398163415665169712832984380121382150588321621493928953938599666110830812",
],
vec![
"17988638446757562417082379159769772097890681265659458369075768452342579854303",
"8144561030363576879343874888624208577604401139613622673042754207987577727758",
"20020299925602421262203305284307419339160247406220693128040712457114283033661",
"2945951415037890626891130390523013930737768652394758977777336357159436605764",
"1505954324723537402640844232704189835623922400329086438898375859826553573763",
],
vec![
"11851584491756305117491374581845512067704002072833714119284164514457248861803",
"14471204965036278214508938537949717553799007630471016532866101610339050785912",
"7163557293233604902868673807221391042191134560333950452577270522828534690707",
"17291625782465108601367695465389799786592304061550212130987221355832952230827",
"10240907112109243116543462081552827576656826251172050843989873656917271396422",
],
vec![
"20702261919346727858635106264046787321170414155594199951578791234276181642650",
"16678253307828004252292273162411388452019952018258857370242272543091326285541",
"19810917631941180098047817620026253706643400683524412974923209268916769874447",
"3357220165225360610202375608872621445880880830154732998557832689480921421791",
"4392285438534542495332422274902727975330102148971785438164412161504066619105",
],
vec![
"14642025133729666610167675086855441462580619607677226879159952689184960379911",
"18142623439987890999821892559271093087005885278955082040377769578204898750505",
"11769399023330099592616157336702104329646487200891911089287290893650532639221",
"7261353756299584174448625214367175510387913706095214313669922259027644778060",
"10406994568199070863112470594593301582798997458844791396920771226539013327304",
],
vec![
"7475277967562870216712397220016587384793504784585573136176313471517144184018",
"9598064630327104406929367986473441777975480987434868213697837347643980267620",
"21137410002545951849752865514437404724653771608225272412595423069852350320648",
"12345612867231779996383303763804719815752861524077922121654106906093103051400",
"16461750199070055335468534730937701659470268635084522644824623393184528879703",
],
vec![
"7829250842543018165409887731515254191943527926556191989558018633300783421935",
"19801151644322693878208767560968285812646931156576102755771403150148125880648",
"808770634664491371274943928223981161442027957963181999892266696287962813461",
"2298122748772261447929855283951027113218922003687701626762072351622993276571",
"17407798064458858450209051887305178872029674498718760624162479511390762310526",
],
vec![
"18585562277464562541666582720366573863334618817908062612923861658144918595030",
"733976598693219656339731904831283238690050114241501938501377743874139460889",
"11316063986696838098122262534148335669847478050407756877728672233736962269417",
"17614529714381496379478130066245111825610297227468263851608027100133421612826",
"12110694197729365219340374599835523099651939156213930558791147158357810646901",
],
vec![
"4337343008663255658976574468931581484970687989356019720784093082313510905405",
"1379188959674402095268172673987199124815512095460112504778179157481327937561",
"3116148242507754420428768481157196067508084836097458698846114802493377512591",
"13306507137873332434793374848948087993544118494881134631519748904811343155566",
"18496878480807017010077624766326681523549495609998881196570603040242554712562",
],
vec![
"3940126764022508707486095199473913866137718790062498893812401335738707507732",
"10030078765792498033316282784150304209584388923549357286679864120250994473810",
"18519871685760382462428068450331593474924737719734568498029727699878543899254",
"12599428893576891013523136950822667754415283296587096197120138265392279834128",
"16038578953099895530943034305356008247313649524436132877362941968861459073483",
],
vec![
"14319233878082524834510736727226054073026413911339853399113450188859080424272",
"13710161613540579690732775978855380876556751245265568031703536595040993113748",
"14958726446649273856607176275240008023824615720456760403465034344703779274727",
"20935428111942360630758629263346308597806819928838924586682307174931367773605",
"5826394436548487315966647466017047216786257295199620110266250301500717796281",
],
vec![
"31401797997389676486806123612280306684597605608110075525648021056710776011",
"10784171495708237485952707518956314344821522727746927291389338644844400581452",
"11604345371765580191117799693565193618158448665352599382713281103552305960442",
"1378145039624937931836538950217364481423707761527018494355648047365613434790",
"10284294167221806561993937798090888689421933711157676807977401896199778472860",
],
vec![
"8233695574758520342808807499924062869636681352769371531557726871630696672029",
"6570581391072134029876349038190171593169496519436674767949949730275868319732",
"4026501263908027819614805027945064360196399012004574117767831931274788631138",
"21091098569404004244061462065218203986433580687172854429523306262593782053656",
"20711772916118045406356429185975897495222240215931761100801599257137350834799",
],
vec![
"3165519312799351250309462589160165591299333587158531489859211268084164422251",
"16470663723473939739601217501478624726068461799539012562455639586886033078064",
"15672299304945968727435591100602007503785845873606917887638890765525875123857",
"21393538327627889838198844493522533627143658125568123117776524944297103649079",
"7688819203734248199049004650451546300187194458173935784579101984183800649342",
],
vec![
"6609663518412297884695057080546416278366560290439222127471462938252865438638",
"3476303650597281786976907813110835564442121684386467570637538230409080744769",
"20633582549754495054832414039299188930065286005370053173386561254823483851717",
"18067076834611402459142612082327591538480657933568191619109271502102126814407",
"157209609820117793892254328219308970217366919934739036156851508233236414461",
],
vec![
"1848396116513925340973398423998379465460554039715233953825786874352442451413",
"188642786730195655565401615804782553245486295156304142809552609651873793325",
"540089254487190924787439362270708251103955915909358626209177199653451469720",
"12796274768956950589847157187031845061404119522843128177103898080653493269942",
"1785666356337148874573621868025910291826158842346617719666738769156993598966",
],
vec![
"20649919247042517528354490854561347316237285929352042389729444382153378749538",
"9568390566108569727471722677925269460696523515877621230569682954652430518787",
"8590683334740232786825518158771304803451657249486419816607179533515442407283",
"9321198393538172042803957409292145345834077448228642847843261373640165958582",
"3651905214805616378360839954289447530035139753215923648216350128870943481828",
],
vec![
"1324345422558073117779462079218851558068746895262914344818945294328678893083",
"6666363895154434021620869731925915051086919707989020578203743660669796175288",
"9850757893972463103359995012900314323213006625927501272997539940766979170137",
"10214293226445704940138790188111862069675188797488928722469679760666574484266",
"16862124085118494177559484642483513597285992646267864845521573612482278871023",
],
vec![
"9172340118369291059693735314505606817316211450324955429310200429408035954801",
"1968992755714619414656181112336357119271845800144345284299978250769356388249",
"17192498940296212027365280042755701662136570107224000496521552617655679821443",
"10063385968535643122430064779260670089120686456635080613693015398478175344193",
"20101961459945738562625328882763768836449780661345042148985756598106706734632",
],
vec![
"12704305975772252539534386080950631076046431529894091327218544197389260775334",
"3008242816727585639441748210631464697850194693570485141354082562181236010097",
"7797705698071555811456747812384107102104184812467361013142453143842134807658",
"19323240331433203844038522035479659453946066968727795017745942269828428751105",
"1698137797127320576751729191866734754105401103859852376273763815257758421427",
],
vec![
"17656850887825900397821271738817912328294075224643535784810269137125067875996",
"20755447986835730799031196367323817361150623932048563112034040627213597261325",
"6221130271964372280138992636208062417325313096379273438539556580491430711297",
"11042709376363248213366896208587241517252100440844476816212498352999929578287",
"987361321094619571176752720390429919723900732295551211263814448408232028205",
],
vec![
"15077982986114392945859048373768437818569856001604485167476360943078774679228",
"6278894644165961404521866714059972066255652200107181684047812674333675794053",
"2649747800006903047073625320829560088088800522557851927539477888486006072675",
"2636278052351769676017824297717609512488651850924228608531372135635042762078",
"816232991472315395984098922575496846552245086608787214581606973359616326446",
],
vec![
"14372687274434205592004117128588852491871014819273428668840779210928924573820",
"7351401720390274950322621121981079413650308506660552567079785209176949174210",
"10275293929161727274572318228903710245677747557851999483919909420098936352013",
"14869686444606195206734119702227763209172799407142930791211203702643805341518",
"937617196362766626935279232045712623531859540210120280128165029613358941709",
],
vec![
"21331527351771920568751070369057714014285398281585036009305608379072813379081",
"4305436470381074948146072259605215282335211631970525440530773004228212378618",
"5894273721571292784412707230481346442881109207745969297947253583203466014760",
"6512250441044591603946512492071171861967500633638753443182294740883123881284",
"20863871952569294813936866452848141274047362082838805921071316386912981651979",
],
vec![
"18788566662709810970880679984141390717017951403407913908833463086244783373013",
"7784927597396249543149135503684024377171301321636804832597181795981969626201",
"13818519831569592521516488188127966399245767953522268350556654747680372036664",
"10515208647860053151690062640705322684876580250632027862984821874343071549235",
"797604926079325807488629085866693514275115789253871397971708541758696512985",
],
vec![
"8741784289526985522570446847275649913333939699807282742190607491216732972386",
"20966712704043418981047968701828936463778140093909973286855779694780086635828",
"11359697297415630167449040380538108774924967116147664240213257348125754475868",
"8070907838094569287067982462230761680706116783989613960066342967469297961118",
"1868550288036217638713133945402464194193242298015503906068429633793800456561",
],
vec![
"198709459347510170000840600179608479136663571567208109852828485236018304733",
"1601154135701845545733926027872374554514541574822026314034696802419388627041",
"4363994778006302991481199477873248350039564117453810275561422974475581105893",
"773054378219982710451611471050404495804413666789496412742983455527754059148",
"5209426340109575519362014651321132459061755868557415513439993327176584352934",
],
vec![
"16124961412020675839394907565568143713078242978522632778625312854364651991011",
"20812496670075231301471694692369245988519082317145989298573032859079075730004",
"3312489967581906638742585802390894285073229440039144559060030129184388053832",
"2967475373447822846542676378804990140732835322255774209561143670843223463335",
"19744585401442299381952694102570931935735276268739851233412754166721728873141",
],
vec![
"20026293345566344685499234599699178313754630774489046573312844763673073616936",
"2611303659034102517884318354550433047021831422518437228002960700934925644951",
"6230291832603218406134986471162106408091661326026848531605999413028246206577",
"9126162046556730019959291776456914453189657463686708035601186672661595109020",
"18827736146609035067773173111376739253733288103277133456626928961785293662143",
],
vec![
"2328703958261360872869074208611873245571971231035163763965210852182760438390",
"13796410059666172174899788866809560044715551934510722965495280798363043241416",
"1593663256684781552813616365605526150610454082601584196604084376715746899324",
"1565874145189898288764434737762721576951043839540107044892767693968417810945",
"8709849304563896945461696717753976956465219721409993781555147204068634555572",
],
vec![
"2994256803561260177499267243802460581941891553208150783951937342406846377191",
"10452746656507347152042187616753027475507881362159944564077673851918869542550",
"20130580998875572619695450234900655050996104101008767761546912649074040426200",
"18926933358104691474037431437316089682088433006245222723356764715400831411716",
"3783551594057498940671877156409957274854990650480535806320220142873170375307",
],
vec![
"7919031943604095374667473717154511882451510130166237539514111182596247372692",
"14518552587329209714850286012780632801030157943402419401997576700600952906519",
"4770764028263701271241862755569969531641408032906982530346384375773459918490",
"10866502826034731763529371496585294375373238783964914673031891984092997621879",
"4234148117462322266937279401468367908013627589417699250592523530383852950379",
],
vec![
"10747942066055887965185603234524367638106812660210378090215017248140719240336",
"2587411532912868255102795810490361867789634574022411742057853375399270197531",
"17350061113113681344498080520518808976916692173267298878258722510332360424059",
"16490282364669098969805528215926442920328903121380947471680517193373377657129",
"9274691782659584680377375192682066090127280485689527337429804211265749864190",
],
vec![
"7630965482352419767782717986075793694403609453648729580916814032587325374653",
"9483872310024003776681196467845329825094379763716541754956796450187787638623",
"12182966986735661215639970080491757244218854808156498220088212871061979325833",
"1853790963611367149183440339188924598268644281518961106776656221408171642714",
"17425077915972423995335545370701802959607559878032910147159424242864219303096",
],
vec![
"14571075346526399549826264845894977639678567831720652860528738036970272895919",
"5627701855249158721927849603102149698163511782011562166637339712383551336091",
"3620805686755372260289125555061886982808014642356719556961142525373021656729",
"11556995641752009899073583627136467840237831247117281278719511600076965602980",
"18960242154096055221658318882298412299294886669455506299567210308762501113202",
],
];
let mds_string: Vec<Vec<&'static str>> = vec![
vec![
"16789463359527776692258765063233607350971630674230623383979223533600140787105",
"17179611066821656668705197789232102741366879862607190942874777813024566441829",
"18653277315487164762584377009009109585010878033606596417396490909822722930739",
"7373070639853668650581790286343199505413793790160702463077019294817051722180",
"4823864393442908763804841692709014014130031798360007432734996408628916373879",
],
vec![
"19196309854577132760746782449135315310664418272926255500908899397538686486585",
"18123132816088485879885148351452823314623055244145916622592591084094232513914",
"18436594886553181913092702411547018228276047601279727265790147051821171174455",
"15167500404313194506503404655898040457721633218143681920692711693000769735187",
"9437986152015460505719924283993842205604222075968464846270136901243896809793",
],
vec![
"21445376105821232747280055223032050399373725161014449207033808524504027971613",
"49684738714301073369749035791061182456037935161360748355432247732088942674",
"9826409059947591908303145327284336313371973037536805760095514429930589897515",
"8494798325496773219358794086647759478982958403252584257436898618394561204124",
"21251937175072447337747316555423152807036003235223125066270735279039060889959",
],
vec![
"5539100337780919206842837176908516952801756637410959104376645017856664270896",
"6297628909516159190915174165284309160976659474973668336571577778869958189934",
"12792263637464508665199868777503118105486490400267592501708855807938962470650",
"17254685306085558791725544672172906900581495686070720065168939143671412445514",
"3590396502942934679818900672232030233017710909687947858184099000783280809247",
],
vec![
"19055249881366445073616526879263250763682650596233071589085239500077496415637",
"7367697936402141224946246030743627391716576575953707640061577218995381577033",
"1322791522030759131093883057746095061798181102708855007233180025036972924046",
"20456741074925985565499300081580917471340328842103779922028754640077047587707",
"9059147312071680695674575245237100802111605600478121517359780850134328696420",
],
];
(
mat_from_str_mat(ark_string).unwrap(),
mat_from_str_mat(mds_string).unwrap(),
)
}
pub fn poseidon_config<F: PrimeField>() -> PoseidonConfig<F> {
let full_rounds: usize = 8;
let partial_rounds: usize = 60;
let alpha = 5;
let rate = 4;
let (ark, mds) = constants::<F>();
PoseidonConfig::new(full_rounds, partial_rounds, alpha, mds, ark, rate, 1)
}
#[cfg(test)]
pub mod tests {
use super::*;
use ark_crypto_primitives::sponge::{poseidon::PoseidonSponge, CryptographicSponge};
use std::str::FromStr;
// Test with value taken from https://github.com/iden3/circomlibjs/blob/43cc582b100fc3459cf78d903a6f538e5d7f38ee/test/poseidon.js#L32
#[test]
fn check_against_circom_poseidon() {
let pos_conf = poseidon_config::<Fr>();
let mut poseidon_sponge: PoseidonSponge<Fr> = CryptographicSponge::new(&pos_conf);
let v: Vec<Fr> = vec!["1", "2", "3", "4"]
.into_iter()
.map(|x| Fr::from_str(x).unwrap())
.collect();
poseidon_sponge.absorb(&v);
poseidon_sponge.squeeze_field_elements::<Fr>(1);
assert!(
poseidon_sponge.state[0]
== Fr::from_str(
"18821383157269793795438455681495246036402687001665670618754263018637548127333"
)
.unwrap()
);
}
}

+ 519
- 0
folding-schemes/src/transcript/poseidon/grumpkin.rs

@ -0,0 +1,519 @@
use crate::utils::vec::mat_from_str_mat;
use ark_crypto_primitives::sponge::poseidon::PoseidonConfig;
use ark_ff::{BigInteger, PrimeField};
use ark_grumpkin::Fr;
// Poseidon constants for Grumpkin curve as generated by
// https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_params_poseidon.sage
// generated with `sage generate_params_poseidon.sage 1 0 254 5 5 128 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47`
pub(crate) fn constants<F: PrimeField>() -> (Vec<Vec<F>>, Vec<Vec<F>>) {
assert_eq!(
F::MODULUS.to_bytes_be(),
Fr::MODULUS.to_bytes_be(),
"The prime field must be isomorphic to Grumpkin's scalar field."
);
let ark_string: Vec<Vec<&'static str>> = vec![
vec![
"1302239555262414373374689806120238567451910671048356388761256768881091977026",
"20142103518641694351566464807000085009490728625878244431319536321251441942827",
"1848725460637284900919684211664029868073589532499995561090226899069857587691",
"5361307675224911135631066913685411082885932664964555034697699114860673882233",
"4473122481411436076578491888827463154326954640259385462117207234024651916467",
],
vec![
"4533665742580623759631463707292502457303336027513946514723234383907861855246",
"18472882194054405184784552208176156100293313194921931757669044776860165723544",
"13757170890682053314816924771913668733053950646218560510866549037895645369564",
"15806422895261109419898318282501524707572435539997217203708101166323921748108",
"4766645625917486367271392557885239315740765821810232842247605581184299843494",
],
vec![
"20755837067826525663784916442484716524757386712340218661351088127992212106824",
"6931011592102208154123444754548015589930397906195731845090389578241299211369",
"12872548123049027593925484150531538114342387406107964171770931024714006292181",
"19021338859263582291104968524901108269784177222899573306303774240117233382398",
"17624901113592432267211565106957770530605134617091943075252981153737028641716",
],
vec![
"11897559166778002356641650092926138527561825100763949484362978917091516510740",
"16531220301863555769676315206097401335513858226194647800882375473715925042232",
"17424778277809172963111651706245659891848752348049503063931347914108000943672",
"8755320631024432262855370560922521571750691690410643309032862198109856402583",
"13001374422759326741836935513643753155827889666543672420219715996498314514388",
],
vec![
"1216381760598407582699518975893828293652170521927520199708385998164690424621",
"12904452162183097363015957196342633654786993893983128901759408322407067297371",
"12561546531549776115730200560156766849625548211823920139512193600272045292214",
"6930331115111210258738101597156664444782725205072006650173982958818687844256",
"20343201589001547428520895531352840937278491384202851733146323236738523363974",
],
vec![
"21276658617773026322558061138281506464246599637634454717771400932019299351058",
"10097707957242243649644020228037307057787037645761780570978695646445962985259",
"20884899049383530051119245117264409449924070600456004919419167743735821727525",
"13397377812553675887463913728139069073663372700997375397306322061704817036699",
"18616452404841674533221000354835108216941859123618809264334834815478741347616",
],
vec![
"14095582055409818879058497145465115091368953664985761666416195570775862375876",
"989852126716121482840752331182237457108026053334039713051379901905011698070",
"17340662943780963387950947862140795796989106523426385169679957973719353360741",
"21755563706267022930627043190481285340144355046068185172121349807216561640069",
"15325642321391280884601090785518744373251074806018161393832307224918948529190",
],
vec![
"10947071261274459198985325724422809398466752666178363754986952007564051091991",
"19953459756557134691582789660250080388719207918492892241424355079847437897323",
"13017630646666130918684255548141038078663596336503425492693574842865036949889",
"4905735010145524529321574488779565535942265382177114282705789859908899904195",
"10994310769595981723441482938782205505832502558966986540479894047164733348048",
],
vec![
"4558883426533135507911287152839063026974356902037934918621088392204919960394",
"11389411190803682369640964183611054693569262790844534007467939610145999369106",
"18427429659657004292641659748828676044508307931530940913274422128932825189144",
"4747632600112900813091981406884834870751420906815558480423623116525080457937",
"5490841575344500401467379479524085742106499725818479519577052331586947120981",
],
vec![
"2347382691271463868967750760346366670376966725559856646130273282076458003368",
"16502441246700317204003385838804213772286717383737310147868712728226242159711",
"14646651083202779369271496867484659085917125847409070439596464462441721106180",
"13041468713723203915781425513068453721571105549428616212880344099041922281475",
"3565173238238447220537445892325048229194756045427371806218935305698716190995",
],
vec![
"17943632701836793558610248175530473966863264931644843118326991954984458357290",
"8629262964952314380681928360755010594313865847541533524671645031866347944808",
"7572585832263212060188863708270352053805259115073057646408375965480399606343",
"83274726636107851152653695232725466625000275473180660596342055855019190940",
"18419438698221392832302278310087737661219932827207397795877863686561542628223",
],
vec![
"16874449584406008639769137537482670173495631460698323839993762270762442482009",
"8749161354809478532131350694773024129109208098976978805205338319260439258799",
"20095113607838931495450163196664901744414657849787917039337877115367663583621",
"21496402233796304778674847416310373229074196587894223152969939251561124632593",
"7306593543990928826856646724176363830912005405046339703530820920160807073796",
],
vec![
"16574885752032489191936718275612881782825833553621719044993535519938387127400",
"17893846554920802635748353716139419828283296002539047685567560104482290794073",
"8217710934970159387824787503447453277040037054856124483775233206267781444657",
"11736757443656203051940992851618854589883051155619796589606327570587773463597",
"7357108854635356516029972411581451513334735628108242015429096369590782972006",
],
vec![
"8147957389683128377316520163944526066526593720865319955477800843043644615989",
"8578207148496795372472985004149219327836996063338727427201924899856749727241",
"878253637253843051899747206938918363442655844121997039811453253482370007284",
"20781125944276624211500376146292543892734001454479669416166826579753807566548",
"20773295400756975680254195587466646104772947626518629881700760847706165190894",
],
vec![
"8895732064456860615031330861811147768090897020733265327161274654936972538582",
"13954796436586071032237593323904206118434100817076378166833933826515717194615",
"6355545976680142042668472818246836867663718105500649088196115931833309333103",
"4499982511725783916459995397890272599887600061913175041084892456480149140119",
"15967465264568599312952212489705525749991909148648023268083881356822830788370",
],
vec![
"7045959712343242541933282090760122650714071751280111869924239373404367611226",
"2758736619576784375230833756818006811754042435434827244702302161302877039098",
"19397434025124552842587969987983638711272147892938019758837488416168452483405",
"10440333186925843771206432302032975829293919982173553632337605164736343289924",
"20794828600186593697605470276342298530768058055061372707773720672699288893913",
],
vec![
"709447844943698498852757143805467220589543729112138798025120783273302752965",
"17630037546285330880196515002704642932154600033057727390686078225861835742326",
"11964069260068059126618472914968597496192458090458011601036083658775820131292",
"19972222798144604337869256501706490565052674557941336457278259071687666383574",
"20844290750559969884082493778608981257417176059035561389829575829623760080290",
],
vec![
"14878046182581709281495871580054466314356460127105044683621574875682589989779",
"17065124944399078846233335855360993858196260091317227579344094536004687852415",
"1360185877806851401242557944439065061377489353855369475692187665353692978482",
"12049768792718449936655304983585280196700538370638579473561453856246399176898",
"15709845344656905001433765150369354864137327645236573224421289508062355021142",
],
vec![
"12621360382058090679255394201724646640587139016796614995047968862337201466266",
"18274600673536226005784163227137914855155135034599653130567948750716142598090",
"21787884937926839264206539030201705373748985208764895579805499705238531820296",
"5518911123238579609231332432611943975352402278711652122694671920605456058290",
"21761949116188843619537619306753312531716136775725591544674153934240863529357",
],
vec![
"17796869701357527201664204976604962048892070624767673384550605654779596007581",
"2647864604326554986833555225919077882119773589724990209783919042763253098108",
"19617892249447454311609020630034101548030577828642557996979504904433175197191",
"16539302958461539414481327333293722887554229697833863735141593451081482424120",
"4643606366993265766773586170443164470758797322755782618742651473789684357708",
],
vec![
"4071581142654619843147341131359139210505553973938073256620554556892698535665",
"8438506585452949563345440953823822856687668373103117920012160878623100635715",
"5752648847295773759323596722843573010957235282128774345262290688283958122187",
"4895183974327552378943157516835940807537265497873725882428018890508283672707",
"99879445459850652926996475631572406748626601406767594664854914412536794882",
],
vec![
"1923718358753835151721387946715785538388643977826645864293502204191986917822",
"20477927320500904716666257724334897086463565247896774882102460405414651843209",
"4006849405528300180014054829493834535617772179184109802880071219554470452886",
"10107976939430331960441747215493937401372845315504512470617212987469116885943",
"7119571668689414144607710005511178646031929995895119888457483830175098096498",
],
vec![
"9872390410521458646121186788124410025628155737484619433357017546855004223978",
"21606915995435014503540652557971419337975068893666154677779514355357198577484",
"18001171795801887563745450369173596829659495012571495799316565738291413999685",
"20937233136022841286771273476220803640966790989321822224992915812050072125029",
"13853572901603423386283135192760416047463779350471925431886912539052870854516",
],
vec![
"7070600116437505566301516576517233788065772494741576728836386496081684767923",
"11184373642166206206995287089301456597658294766117413157771494639288064885056",
"12841477105033880138152882352270850924315792748224498738103381953046184795144",
"1755167770148415657695387316779398514494819098407216925610122012803274394347",
"17004098977713219442909011456539313463808204294677194009536257955735490204316",
],
vec![
"13918334833224327546297267827647471092666708610949564904320302281568358386219",
"11114170313788260091002151042271544880186588359420682000730043368717205266601",
"18439850522357402898303132218070821687887062629580147710920704074847733864016",
"10530436785876228149266150677701972714943238262920190774882843981609997621353",
"21072114166085741592816517938297707270436788587579436145325231685649812963629",
],
vec![
"2094411010794090876717462570342717890672062958788201315289761804428904533721",
"8915878887328839142983427035164815337561276204353902884382943661261415445046",
"7616342698079827765791968427743036240203047763116805302331458419499028658482",
"8200710106989617402554959919916002247984642580296370147402494036734414480292",
"20744924048241957058281161545923736050414168021353274950816510886479212477941",
],
vec![
"21382304571836070549931341837111711288815078485385836691041098667712848959513",
"5363454082341013317554893533404052402561614424686599343270520107449141324251",
"19271380433074332255461750206392593155229797371298469126288176518859012402488",
"19284858754791044234619190072916658819128950416929669576669828359721253583476",
"4347052022768834992831956681958567468275115041393166850705568538274021535653",
],
vec![
"5347579665803543154579370003793541492663176864561245170012842054646916411756",
"15154015709945488235461044557840341690070793639780701389600826304410652635126",
"14284408872658800251723507539653877329628932861134484971720825469778534181682",
"9711589473384623153441082777119419277451857932364007911882413378746629857300",
"12386040029204472714497332338926304138183035061201374723092754304685826751973",
],
vec![
"2982316836932298422050557525101873891357503977663776438631253526538497978038",
"9441977932804102579353475137962384655847637389761448611532778568891212385341",
"8539525209965113683210134921270851023819533178131265377811744281414999344105",
"15410066578620981498634743331974323624474573834322740404100062731142779729944",
"12392063012290922514331017726588085071539844101072814893654199668124656370438",
],
vec![
"17065187639764462859853096495755804816599495563961724364982614144577063825801",
"2008764007761084581130273411301054447855384981112680350916101365339816942167",
"12033786842942478889587047472531970811285454161836192807274525954252993062530",
"3984393467579617759108600545867686724263281569823213622742775912250034844523",
"18618339702539879228841658632418255862053759038071892766106358111976063460190",
],
vec![
"18156898408367441617119711804274259507528069577887238632062644667202857018593",
"21080042863306662936950095604614158871112079027267728361334324632449882247493",
"16240965012479307524071605734375101960274551356571955298617984622775658350016",
"14221844007451140205992483251522807080442254924228164870716910231527342559914",
"7292289663573284912177572483254539576411910175285178060564787819667108102326",
],
vec![
"8103273422142674255776372834488704655604711673426196023800875386912884557457",
"18054187581485462987355985044629428571768458762730021689491495998294234577693",
"20453295504331160733306660954772311473025215927027991341100710420100047539002",
"3554118714213142358752758480123600824792611607375962381969520157236774923426",
"16830192789363703470207646307443660978790147868390422240433276093601295592554",
],
vec![
"15107140136797957315748929296388826049467241369326022314386608202530282365423",
"21285265735865763357384027044858771755072817264141123441908045614213326425978",
"2777078076018600443384138666065892999827937343665706320976121985854040040062",
"10306526793348313220313360232622366773192621454610895150539556890481223908878",
"3986094169820581741224158158414757002901140745319315875507610903859141202594",
],
vec![
"21395437918063083580979333150773034354616142666169453508234137643490987983673",
"13129544875124812052819482497670660745332583868001421786918912932537916025567",
"21689372610185905991917284292707031919082550146838541051789173093404095075260",
"5305829976126283652922397651017903920529015051010018920756189140868470197981",
"2553681848662163005833529966579252450790058534306544039492996212114422395433",
],
vec![
"17713528016716160377032633031860382085838469031075655507795128756976791355435",
"9491820604894314039555713267327419914973891054344379708675409342186583881613",
"6888439906763505303063673789064050442951420414130075443251542450847862464460",
"14770568168929423572115974934221902453911829356761238549785497088819971653517",
"15835128816772321432767426850947174577707938773126912973158661902028150167517",
],
vec![
"2764734647777982876147187592277418709626222378470508712045781515019904687169",
"14699561850422431548490916788128110229469336625799148789554766764560249484208",
"16202237139602136968728272054154053690700101264849231363184732378737631713776",
"21010382217320933047328167881513834327367306210350848830624615290126734674978",
"21878796003151751780103238716473704388589102790973207193769075594800938087472",
],
vec![
"16438931517546594489433313976198411445658491191751450877756574263898742742630",
"15455021954879694880064386371706730890497994176717928888903890601866739219035",
"277392098767674408206679066669309082190128728677980290645097736422198920211",
"5385642205466209548834686561634430250955636094674076888166796942411558088911",
"17152161762746123707923926605859839391687842796333435151544669011943325907368",
],
vec![
"3539586941998825906572765166881959268581870110160554530811172791559432510434",
"21291265123168208642370952811729162800582110383948835797311786248565114295223",
"2475340677262844094762960246163985089881056535034632621616818968620298251230",
"7798235620200455154874326974510730344303802310964712096010822362290605624218",
"14364505836915122239803412656452014006778204615405446331730923361702473284265",
],
vec![
"3872806894327146131397743191674114521881565862842516477386664477274530674192",
"16164023672176103844702158338588552984086839649602006663630596524214840215227",
"7439761190815555063979460097977546697596706515018808044867072104367234295151",
"21364402501789153204603544261572251710651046144649289908173963362038696965375",
"8541399769584536552281910909458898334230834359986988903753611163373264370868",
],
vec![
"17647063943033783343020879048153964677277647702692500560761944649467500611781",
"15431008881896942001008226179572746419787757159745657256720934853277152574653",
"20852931786641660679003694154889935566769395955557209711272839603920934953150",
"229293965011229721775346264940129463558498351348196659393871004320274382782",
"7102765778493273901641218835005965594441081283488593995494571562113400044023",
],
vec![
"4301428317229312828848967074495057161390882846626923162898001307573720630811",
"6989871140410537543374674628221533758557593095781620131775473860353033620371",
"14067861690966768379045513737638214939361046173691580428921121219527106167265",
"10989355720245531664247415871120996675597011727515839530375673271732849482030",
"10636028492234020984772246771393454781159159764299311356516055847130840656251",
],
vec![
"1509516411118548818479457061390140842030611053766198534277289864733053431984",
"6016527014717414985715406835438830385705629018768225890341272217512754139075",
"18009870630854269740667553351515356750620208866286443996079385817462687994328",
"12941208659965353535945982278425167790646108682089354539893990334776263126582",
"6408630755002382624736766372813746743394479801231860327307412987646876771160",
],
vec![
"6473275960778512513582331085185673196248957133908028732835704730551444739301",
"4671308961157574927916195230344644717882965779035591214536796362854427778381",
"19414951835068462134134049195061882403344971565248849237922973692054730376754",
"14719038943075760086280025662026793548388999166109750623206284980568171488172",
"12271960755926571759397203838320016671890894112192008081391935132421981211443",
],
vec![
"21409190531342114688424168613381967368449891418465485126773696301325070397882",
"107881145622341766195797697180398630966146686121294922902505492300376581701",
"17382945389561659460319815947516238642247658799110915338488621060102080047539",
"6328410082901692275666073849891663711371196642536900744578688459148095541551",
"5499749772383208465048180320867175193567502820575626739181055378423718868039",
],
vec![
"3204525958061714990518441380431615353302696462736414225170035013526539981058",
"9376764803231999304238028037321448743861331501170058694965687575771463991453",
"5237849715714294820293831443727094658731366644369324164620835602118042346870",
"9239495575265257427822371973110544704770778444170109638878775549832354515494",
"7880425335496839386103630104455216237845620064265863480289309995594489485862",
],
vec![
"10207842905317613746951982575056147000309206576502209186044867806033750144086",
"18745940987111747211061984736915990760500362627666000109808520301610434121504",
"13079189067909178317435686398656108053236860538441664302331350911412055820915",
"17067019205640552338021677449560599552840430767893036009592844143843557994424",
"13016918696846808514331427814150121751322377780531194517695510258675820732909",
],
vec![
"21489797151464601775632825035710818267963200552334448174801229855857128663775",
"4934888620039211187671244780535801635284292253603825321579664975935835597948",
"16602483151127971722313642909560175097035441303962316845857049824454750801486",
"18641807385681192758876550180654220921365911502760326609634613337194020209523",
"16925927598302001873588652395266396371351036692514405706361568743594010741532",
],
vec![
"14486092351755954790229242015868583215610453135748933043922672728536022197704",
"20778174490546328244258656158430202863648695790985677923372400582930757310418",
"16631748808740506031147919524411887259543162754298984304792262445311999057100",
"8786033961094907554640397512269007851362576125025617120625202376510922518234",
"17544380304193526481389764226846912653688724640722680092503328991834898226758",
],
vec![
"2040898632628667450504825873427940388725164943108463598147204658638706060670",
"11266666625440259700781586210036861414729690333809733995405037631962446956155",
"13460535253234440686890388506029233180141711540662215480601224102735227984512",
"12636160103920207730958920610195885429915333096038982786347009836030899638483",
"6383739819588725781339075155063162102005724252294667119009147433389509274581",
],
vec![
"3615415542286145222801248937923769406863619912085574834683457411852358326065",
"21484290530292488749479723708756361451822492014684193820961010478972790190053",
"9248035906677166766115225191221800851151572573012446205259169609929901480989",
"8431379073917134790658087470500967107593432305778554481716806377637231835193",
"18827891457467202141300330875540352074826671738513349870408037755815876855513",
],
vec![
"12257405118592396506493659207395476994164449510609233957374912486666332869265",
"21226225959854014471324834236076174784480392729934587257035277409456041350054",
"20286225677735463160252689903334639277764329300633051406303811016606383879277",
"10279964694039468933161973601611338291797534036555810740994417216892754405764",
"19505712206874315617549350996181917781225952142243549491268122179248885644216",
],
vec![
"20038967257440016050053835036217347375509692369869123828333050890335921590418",
"8523701096675837950983704311311321332315273369885750549632214593466999278559",
"3555295004833619124925912036253452620323771244275346931178469823606125124449",
"13784324444186967604165178202741636059533026352459109519158961779055205702963",
"1990731083029044014598831932498759644447254974253506030415271492596479699841",
],
vec![
"17578439096922405381448775550808806383371194977564690298325676455726616889023",
"8482864734928111222662141206829539770993499916626142030432142812087814950739",
"14427490653680209977995871526275577094021456563142468863069496015597239256954",
"2886468118550034063520843296160011102344999339741412744323416088047748803031",
"14572134157746751340989844304520965763735898987561573587755290732664963516241",
],
vec![
"2012188439304315533653966624269826479632693436228005577812006502639655900430",
"15532739752336769387812617799347097353090822643182498581522593843370142001319",
"17529534703270713594321571895249323223685495976329442080636746684463806784661",
"21031534080894610876355523771107722102837183493228844664680261397823519630070",
"19436577385855087170357474710455765498240805774464631546842557209664504220669",
],
vec![
"12949787909663269259076764555571843769659200695381876462828212199650601988661",
"19840887115057106171541062849618907727997426564328068613363838385495062694080",
"11070881582551838082405230404504983313196662759570037918719480824477325348619",
"21121613659252535934567682773727354352249754361426783252117493686550694641841",
"13853384193563682327636191280511053847941124197231804085111291238364825228055",
],
vec![
"16534768562387351990889034654990847617621658362728970493903460833326016536279",
"16737626808770332056817306496249435585235512996421417871213979019489327200794",
"4955268430584609526967650698915505429623726703834197733312701363048061722841",
"9263608332778781442606069584033040773652544643298512410910187831068155040930",
"14054336891450573864216276098381163567665599861126245131928674022194523625593",
],
vec![
"21801176434550838737352604795544877125500872320940890751193577820117534718405",
"9079447684660962172190409320608785803288621417039371710407887510606175315445",
"8133910245538672265863502046036258662943074913843998565031782462595186859432",
"9027563286570496827301683766505646642464515894808680909417176262524667994607",
"17813887182413861707818763379048369988110623133775484154852873751145361117513",
],
vec![
"8273529887305322812400486795371424723512754022502284544817751808933420020056",
"6193911737909565720690901657318625169120108300025594301424772109607790217525",
"373596750078768704743702896865778923677151831044315726342014805308595338731",
"15663337206542612442532133239045611552243679621992911236973616735274383423741",
"17476521689840597137182775014002918999849301054751890629300658136899537687697",
],
vec![
"10121895709985849082387712269452727249466555335022614339144618832725920412034",
"11353776892399275074635875354785293934117783200085751402421982281545221342465",
"15469593317594462447141531241838454642357125438273561690975191399478697119085",
"17865888279934933809429394512960214291450883690852180796520429879983293128990",
"6274350675415573512803325527372997466731705110595230630336129852455603760381",
],
vec![
"9515352341824235667448011992857822921915261676679964918079021159851642025303",
"477707918786271386693553202815432152082461724031549221576128656997166664476",
"11386216724751845172421028486683728466296560704582636027450491190849829017239",
"4868197961579949504657937771026878598470017307487284109130104378522476324759",
"7991796353928888821416988025327754752177012963861843782973600632603733430518",
],
vec![
"11333649983259548605035153795104287405127917441832737799837601790907346338950",
"3253711061374706142428324171829325260316225494115007268262947478002641026402",
"5496514984404605000691982099037699217882902140738102410212416632722084066284",
"6974913403648934971601590531570930173199234097058361874070921020086428415758",
"5883566280233036595341911997921541009923447375421011739277658309528500897712",
],
vec![
"21445567565181758135550457460741698101787978571665239784748669483459739751994",
"243826411958605269263143447048452095693190359309032214693902308098516987479",
"21154333990044972665175047861269029145893456380868567541001936195732856016776",
"3319183817985491659546270466674828377723765699200573232068916648375974981613",
"3073970873570833352097605152458525154296900481368706411115318768432378669842",
],
vec![
"20483576083983106606340357456603738075578078878737741433492057427336395394207",
"18720024904290757089439759576658550350669656533688125048290648882155502317676",
"1642499300715381739293473205810772993318440465411115612594671091056540126965",
"19304118143010791587684818902506948075645331242883697200070316546112584129578",
"17514394941065568574615190205049601810984856925614240654769418757202361926933",
],
vec![
"11556753834792658188438232905095955072130370253803724342392908382453645967403",
"6129219138206469959108774259486604720996391435645088561379200297574544675692",
"18072280082137011908300861638959080543066161505384020771128066003845703716201",
"17698719397344644673462975571660619385706341688261285732100232300374907025408",
"19711276008373408462398739099936823239389914489313560182281159321304186912571",
],
];
let mds_string: Vec<Vec<&'static str>> = vec![
vec![
"11040268765618966485743930331384449252540178255721603113765764162439951530662",
"14619397736929193730245228786408558236521630763386146399322813942010841864899",
"10667900877576512207318813047240865767100252874399171146942316173885571898103",
"12165316291228285262842448955655563528504835782461286041201951512387113326195",
"10396208898093391600689903392326434668878305652248452965403131377623408094066",
],
vec![
"19503909329721711777979879761659766779862832905278244618068517524827486499103",
"4959388492818549747321625860510175535335795548729907524166782031582541039280",
"16115979899849295727011176917576445189620726075595230031659429359211848784926",
"505854154613852852989462660917429865956711080615787601025929677126127137972",
"3809388125781819260420235233525803721174258720871002958819149356974147520791",
],
vec![
"16684302548808282795274602108101884787806448235075553242259501124382211853639",
"15761534168109871534581041602143280815389334970289855273694992235420618466756",
"11194351297025208548187494208359225900929561831849862863133416814929915734783",
"1892277486669848856135789846900228616904357145126282105455443798229090074187",
"2781765068911985355639433624785498046913019524724151023603546614690160030185",
],
vec![
"12037519845045404407540321574767620698649052766728735733715255850418456502517",
"2732503219087414496659560236942305660362604072017478968909949641450059765139",
"6751856993585408160559297753599536526938230756668214257332833164872580357525",
"21154610483210081693552160119046341221136362570739966307225431519652159656367",
"6208150041573103146633376259286490046406285001830507663903329995399090412043",
],
vec![
"18063113951004757412844021744032560391991074710825639164600470602537681012962",
"4309850927493714562265638576973404086579410809307210903617085917528289705963",
"17965146435760138739568881121411723561477417980023835001880054802493337747241",
"4834762967413709351083800837287853102040090485798752777075791579043757218092",
"18099176386979510370196738775718135350042677134310008561670476620955846754392",
],
];
(
mat_from_str_mat(ark_string).unwrap(),
mat_from_str_mat(mds_string).unwrap(),
)
}
pub fn poseidon_config<F: PrimeField>() -> PoseidonConfig<F> {
let full_rounds: usize = 8;
let partial_rounds: usize = 56;
let alpha = 5;
let rate = 4;
let (ark, mds) = constants::<F>();
PoseidonConfig::new(full_rounds, partial_rounds, alpha, mds, ark, rate, 1)
}

+ 2
- 2
folding-schemes/src/utils/espresso/sum_check/mod.rs

@ -211,7 +211,7 @@ pub mod tests {
use ark_poly::MultilinearExtension;
use ark_std::test_rng;
use crate::transcript::poseidon::poseidon_test_config;
use crate::transcript::poseidon::poseidon_canonical_config;
use crate::transcript::poseidon::PoseidonTranscript;
use crate::transcript::Transcript;
use crate::utils::sum_check::SumCheck;
@ -224,7 +224,7 @@ pub mod tests {
let mut rng = test_rng();
let poly_mle = DenseMultilinearExtension::rand(5, &mut rng);
let virtual_poly = VirtualPolynomial::new_from_mle(&Arc::new(poly_mle), Fr::ONE);
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
// sum-check prove
let mut poseidon_transcript_prove: PoseidonTranscript<Projective> =

+ 13
- 0
folding-schemes/src/utils/vec.rs

@ -119,6 +119,19 @@ pub fn mat_vec_mul_sparse(M: &SparseMatrix, z: &[F]) -> Result
Ok(res)
}
pub fn mat_from_str_mat<F: PrimeField>(str_mat: Vec<Vec<&str>>) -> Result<Vec<Vec<F>>, Error> {
str_mat
.into_iter()
.map(|row| {
row.into_iter()
.map(|s| {
F::from_str(s).map_err(|_| Error::Other("Invalid decimal string".to_string()))
})
.collect()
})
.collect()
}
pub fn hadamard<F: PrimeField>(a: &[F], b: &[F]) -> Result<Vec<F>, Error> {
if a.len() != b.len() {
return Err(Error::NotSameLength(

+ 2
- 2
solidity-verifiers/src/verifiers/kzg.rs

@ -90,7 +90,7 @@ mod tests {
use folding_schemes::{
commitment::{kzg::KZG, CommitmentScheme},
transcript::{
poseidon::{poseidon_test_config, PoseidonTranscript},
poseidon::{poseidon_canonical_config, PoseidonTranscript},
Transcript,
},
};
@ -132,7 +132,7 @@ mod tests {
#[test]
fn kzg_verifier_accepts_and_rejects_proofs() {
let mut rng = ark_std::rand::rngs::StdRng::seed_from_u64(test_rng().next_u64());
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let transcript_p = &mut PoseidonTranscript::<G1>::new(&poseidon_config);
let transcript_v = &mut PoseidonTranscript::<G1>::new(&poseidon_config);

+ 2
- 2
solidity-verifiers/src/verifiers/nova_cyclefold.rs

@ -142,7 +142,7 @@ mod tests {
get_cs_params_len, Nova, ProverParams,
},
frontend::FCircuit,
transcript::poseidon::poseidon_test_config,
transcript::poseidon::poseidon_canonical_config,
Decider, Error, FoldingScheme,
};
@ -287,7 +287,7 @@ mod tests {
KZGVerifierKey<Bn254>,
) {
let mut rng = ark_std::test_rng();
let poseidon_config = poseidon_test_config::<Fr>();
let poseidon_config = poseidon_canonical_config::<Fr>();
let f_circuit = FC::new(()).unwrap();
let (cs_len, cf_cs_len) =
get_cs_params_len::<G1, GVar, G2, GVar2, FC>(&poseidon_config, f_circuit).unwrap();

Loading…
Cancel
Save