mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-11 08:21:33 +01:00
Upgrade to work with latest ark-ff (#95)
Co-authored-by: Sun <huachuang20@gmail.com>
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::{Fq, Fr};
|
||||
use ark_ec::{
|
||||
models::{ModelParameters, MontgomeryModelParameters, TEModelParameters},
|
||||
twisted_edwards_extended::{GroupAffine, GroupProjective},
|
||||
};
|
||||
use ark_ff::field_new;
|
||||
use ark_ff::MontFp;
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -18,7 +19,6 @@ pub type EdwardsProjective = GroupProjective<EdwardsParameters>;
|
||||
/// Baby-JubJub's curve equation: x² + y² = 1 + (168696/168700)x²y²
|
||||
///
|
||||
/// q = 21888242871839275222246405745257275088548364400416034343698204186575808495617
|
||||
///
|
||||
#[derive(Clone, Default, PartialEq, Eq)]
|
||||
pub struct EdwardsParameters;
|
||||
|
||||
@@ -31,14 +31,15 @@ impl ModelParameters for EdwardsParameters {
|
||||
|
||||
/// COFACTOR^(-1) mod r =
|
||||
/// 2394026564107420727433200628387514462817212225638746351800188703329891451411
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "2394026564107420727433200628387514462817212225638746351800188703329891451411");
|
||||
const COFACTOR_INV: Fr = MontFp!(
|
||||
Fr,
|
||||
"2394026564107420727433200628387514462817212225638746351800188703329891451411"
|
||||
);
|
||||
}
|
||||
|
||||
impl TEModelParameters for EdwardsParameters {
|
||||
/// COEFF_A = 1
|
||||
#[rustfmt::skip]
|
||||
const COEFF_A: Fq = field_new!(Fq, "1");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "1");
|
||||
|
||||
#[inline(always)]
|
||||
fn mul_by_a(elem: &Self::BaseField) -> Self::BaseField {
|
||||
@@ -47,8 +48,10 @@ impl TEModelParameters for EdwardsParameters {
|
||||
|
||||
/// COEFF_D = 168696/168700 mod q
|
||||
/// = 9706598848417545097372247223557719406784115219466060233080913168975159366771
|
||||
#[rustfmt::skip]
|
||||
const COEFF_D: Fq = field_new!(Fq, "9706598848417545097372247223557719406784115219466060233080913168975159366771");
|
||||
const COEFF_D: Fq = MontFp!(
|
||||
Fq,
|
||||
"9706598848417545097372247223557719406784115219466060233080913168975159366771"
|
||||
);
|
||||
|
||||
/// AFFINE_GENERATOR_COEFFS = (GENERATOR_X, GENERATOR_Y)
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = (GENERATOR_X, GENERATOR_Y);
|
||||
@@ -58,16 +61,19 @@ impl TEModelParameters for EdwardsParameters {
|
||||
|
||||
impl MontgomeryModelParameters for EdwardsParameters {
|
||||
/// COEFF_A = 168698
|
||||
#[rustfmt::skip]
|
||||
const COEFF_A: Fq = field_new!(Fq, "168698");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "168698");
|
||||
/// COEFF_B = 168700
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, "168700");
|
||||
const COEFF_B: Fq = MontFp!(Fq, "168700");
|
||||
|
||||
type TEModelParameters = EdwardsParameters;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
const GENERATOR_X: Fq = field_new!(Fq, "19698561148652590122159747500897617769866003486955115824547446575314762165298");
|
||||
#[rustfmt::skip]
|
||||
const GENERATOR_Y: Fq = field_new!(Fq, "19298250018296453272277890825869354524455968081175474282777126169995084727839");
|
||||
const GENERATOR_X: Fq = MontFp!(
|
||||
Fq,
|
||||
"19698561148652590122159747500897617769866003486955115824547446575314762165298"
|
||||
);
|
||||
|
||||
const GENERATOR_Y: Fq = MontFp!(
|
||||
Fq,
|
||||
"19298250018296453272277890825869354524455968081175474282777126169995084727839"
|
||||
);
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use ark_algebra_test_templates::{curves::*, groups::*};
|
||||
use ark_ec::{AffineCurve, ProjectiveCurve};
|
||||
use ark_ff::{bytes::FromBytes, Zero};
|
||||
use ark_std::rand::Rng;
|
||||
use ark_std::str::FromStr;
|
||||
use ark_std::test_rng;
|
||||
use ark_std::{rand::Rng, str::FromStr, test_rng};
|
||||
|
||||
use crate::*;
|
||||
|
||||
use ark_algebra_test_templates::{curves::*, groups::*};
|
||||
|
||||
#[test]
|
||||
fn test_projective_curve() {
|
||||
curve_tests::<EdwardsProjective>();
|
||||
|
||||
Reference in New Issue
Block a user