mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-11 16:31:36 +01:00
Upgrade to work with latest ark-ff (#95)
Co-authored-by: Sun <huachuang20@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ use ark_ec::{
|
||||
models::{ModelParameters, MontgomeryModelParameters, TEModelParameters},
|
||||
twisted_edwards_extended::{GroupAffine, GroupProjective},
|
||||
};
|
||||
use ark_ff::field_new;
|
||||
use ark_ff::MontFp;
|
||||
|
||||
use crate::{fq::Fq, fr::Fr};
|
||||
|
||||
@@ -24,8 +24,10 @@ impl ModelParameters for EdwardsParameters {
|
||||
|
||||
/// COFACTOR_INV (mod r) =
|
||||
/// 29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158
|
||||
#[rustfmt::skip]
|
||||
const COFACTOR_INV: Fr = field_new!(Fr, "29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158");
|
||||
const COFACTOR_INV: Fr = MontFp!(
|
||||
Fr,
|
||||
"29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158"
|
||||
);
|
||||
}
|
||||
|
||||
// Many parameters need to be written down in the Montgomery residue form,
|
||||
@@ -38,15 +40,13 @@ impl TEModelParameters for EdwardsParameters {
|
||||
/// Needs to be in the Montgomery residue form in Fq
|
||||
/// I.e., -1 * R for Fq
|
||||
/// = 252557637842979910814547544293825421990201153003031094870216460866964386803867699028196261
|
||||
#[rustfmt::skip]
|
||||
const COEFF_A: Fq = field_new!(Fq, "-1");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "-1");
|
||||
|
||||
/// COEFF_D = 4212
|
||||
/// Needs to be in the Montgomery residue form in Fq
|
||||
/// I.e., 4212 * R for Fq
|
||||
/// = 389461279836940033614665658623660232171971995346409183754923941118154161474636585314923000
|
||||
#[rustfmt::skip]
|
||||
const COEFF_D: Fq = field_new!(Fq, "4212");
|
||||
const COEFF_D: Fq = MontFp!(Fq, "4212");
|
||||
|
||||
/// Generated randomly
|
||||
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = (GENERATOR_X, GENERATOR_Y);
|
||||
@@ -62,21 +62,24 @@ impl TEModelParameters for EdwardsParameters {
|
||||
|
||||
impl MontgomeryModelParameters for EdwardsParameters {
|
||||
/// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204
|
||||
#[rustfmt::skip]
|
||||
const COEFF_A: Fq = field_new!(Fq, "203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
|
||||
const COEFF_A: Fq = MontFp!(Fq, "203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
|
||||
|
||||
/// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931
|
||||
#[rustfmt::skip]
|
||||
const COEFF_B: Fq = field_new!(Fq, "272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
|
||||
const COEFF_B: Fq = MontFp!(Fq, "272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
|
||||
|
||||
type TEModelParameters = EdwardsParameters;
|
||||
}
|
||||
|
||||
/// GENERATOR_X =
|
||||
/// 282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227
|
||||
#[rustfmt::skip]
|
||||
const GENERATOR_X: Fq = field_new!(Fq, "282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227");
|
||||
const GENERATOR_X: Fq = MontFp!(
|
||||
Fq,
|
||||
"282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227"
|
||||
);
|
||||
|
||||
/// GENERATOR_Y =
|
||||
/// 452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703
|
||||
#[rustfmt::skip]
|
||||
const GENERATOR_Y: Fq = field_new!(Fq, "452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703");
|
||||
const GENERATOR_Y: Fq = MontFp!(
|
||||
Fq,
|
||||
"452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703"
|
||||
);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use ark_algebra_test_templates::{curves::*, groups::*};
|
||||
use ark_ec::{AffineCurve, ProjectiveCurve};
|
||||
use ark_std::rand::Rng;
|
||||
use ark_std::test_rng;
|
||||
use ark_std::{rand::Rng, 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