message: [snarky-rs] refactor Constants to take advantage of KimchiCurve
diff: +//! Constants used for poseidon.
  +
  use ark_ec::AffineCurve;
  -use ark_ff::{Field, PrimeField};
  -use commitment_dlog::{commitment::CommitmentCurve, srs::endos};
  -use mina_curves::pasta::{Fp, Fq, Pallas as PallasAffine, Vesta as VestaAffine};
  +use ark_ff::Field;
  +use commitment_dlog::commitment::CommitmentCurve;
  use oracle::poseidon::ArithmeticSpongeParams;
  +use crate::curve::KimchiCurve;
  +
  #[derive(Clone)]
  pub struct Constants<F: Field> {
  pub poseidon: ArithmeticSpongeParams<F>,
  @@ -11,33 +14,20 @@ pub struct Constants<F: Field> {
  pub base: (F, F),
  }
  -pub trait KimchiParams: PrimeField {
  - fn constants() -> Constants<Self>;
  -}
  -
  -impl KimchiParams for Fp {
  - fn constants() -> Constants<Fp> {
  - let (endo_q, _endo_r) = endos::<PallasAffine>();
  - let base = PallasAffine::prime_subgroup_generator()
  +impl<F> Constants<F>
  +where
  + F: Field,
  +{
  + pub fn new<Curve: KimchiCurve<ScalarField = F>>() -> Self {
  + let poseidon = Curve::sponge_params().clone();
  + let (endo_q, _endo_r) = Curve::OtherCurve::endos();
  + let base = Curve::OtherCurve::prime_subgroup_generator()
  .to_coordinates()
  .unwrap();
  - Constants {
  - poseidon: oracle::pasta::fp_kimchi::params(),
  - endo: endo_q,
  - base,
  - }
  - }
  -}
  -impl KimchiParams for Fq {
  - fn constants() -> Constants<Fq> {
  - let (endo_q, _endo_r) = endos::<VestaAffine>();
  - let base = VestaAffine::prime_subgroup_generator()
  - .to_coordinates()
  - .unwrap();
  - Constants {
  - poseidon: oracle::pasta::fq_kimchi::params(),
  - endo: endo_q,
  + Self {
  + poseidon,
  + endo: *endo_q,
  base,
  }
  }
  