Browse Source

Fixes

fq2_neg_nonresidue
Pratyush Mishra 4 years ago
parent
commit
4e45f92ca9
4 changed files with 13 additions and 70 deletions
  1. +2
    -2
      bw6_761/src/curves/tests.rs
  2. +2
    -2
      cp6_782/src/curves/tests.rs
  3. +1
    -1
      ed_on_cp6_782/src/curves/mod.rs
  4. +8
    -65
      ed_on_mnt4_298/src/curves/mod.rs

+ 2
- 2
bw6_761/src/curves/tests.rs

@ -57,8 +57,8 @@ fn test_bilinearity() {
let b: G2Projective = rng.gen();
let s: Fr = rng.gen();
let sa = a.mul(s);
let sb = b.mul(s);
let sa = a.mul(s.into_repr());
let sb = b.mul(s.into_repr());
let ans1 = BW6_761::pairing(sa, b);
let ans2 = BW6_761::pairing(a, sb);

+ 2
- 2
cp6_782/src/curves/tests.rs

@ -57,8 +57,8 @@ fn test_bilinearity() {
let b: G2Projective = rng.gen();
let s: Fr = rng.gen();
let sa = a.mul(s);
let sb = b.mul(s);
let sa = a.mul(s.into_repr());
let sb = b.mul(s.into_repr());
let ans1 = CP6_782::pairing(sa, b);
let ans2 = CP6_782::pairing(a, sb);

+ 1
- 1
ed_on_cp6_782/src/curves/mod.rs

@ -2,7 +2,7 @@ use ark_ec::{
models::{ModelParameters, MontgomeryModelParameters, TEModelParameters},
twisted_edwards_extended::{GroupAffine, GroupProjective},
};
use ark_ff::{biginteger::BigInteger384 as BigInteger, field_new};
use ark_ff::{field_new};
use crate::{fq::Fq, fr::Fr};

+ 8
- 65
ed_on_mnt4_298/src/curves/mod.rs

@ -2,7 +2,7 @@ use ark_ec::{
models::{ModelParameters, MontgomeryModelParameters, TEModelParameters},
twisted_edwards_extended::{GroupAffine, GroupProjective},
};
use ark_ff::{biginteger::BigInteger320, field_new};
use ark_ff::{field_new};
use crate::{fq::Fq, fr::Fr};
@ -31,43 +31,22 @@ impl TEModelParameters for EdwardsParameters {
/// I.e., -1 * R for Fq
/// = 252557637842979910814547544293825421990201153003031094870216460866964386803867699028196261
#[rustfmt::skip]
const COEFF_A: Fq = field_new!(Fq, BigInteger320([
17882590928154426277u64,
6901912683734848330u64,
364575608937879866u64,
8740893163049517815u64,
2181130330288u64,
]));
const COEFF_A: Fq = field_new!(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, BigInteger320([
8040159930071495160u64,
16503302848883893212u64,
4541498709509651666u64,
11429056610118256373u64,
3363453258354u64,
]));
const COEFF_D: Fq = field_new!(Fq, "4212");
/// COFACTOR = 4
const COFACTOR: &'static [u64] = &[4];
/// COFACTOR_INV (mod r) =
/// 29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158
/// Needs to be in the Montgomery residue form in Fr
/// I.e., 29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158 * R for Fr
/// = 55841162081570353734700426339805757388253838807422867796343130916044015196330318480543044
#[rustfmt::skip]
const COFACTOR_INV: Fr = field_new!(Fr, BigInteger320([
6539529304383425860u64,
7567022062893857598u64,
17399624368177871129u64,
14575354999847441509u64,
482253688048u64,
]));
const COFACTOR_INV: Fr = field_new!(Fr, "29745142885578832859584328103315528221570304936126890280067991221921526670592508030983158");
/// Generated randomly
const AFFINE_GENERATOR_COEFFS: (Self::BaseField, Self::BaseField) = (GENERATOR_X, GENERATOR_Y);
@ -83,57 +62,21 @@ impl TEModelParameters for EdwardsParameters {
impl MontgomeryModelParameters for EdwardsParameters {
/// COEFF_A = 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204
/// Needs to be in the Montgomery residue form in Fq
/// I.e., 203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204 * R for Fq
/// = 184958108588233737086787169006685138672129232027042887479256778022373554352621152610883766
#[rustfmt::skip]
const COEFF_A: Fq = field_new!(Fq, BigInteger320([
13866101745789245622u64,
14126297534943667090u64,
11307578615387704385u64,
8263080598809044705u64,
1597329401399u64,
]));
const COEFF_A: Fq = field_new!(Fq, "203563247015667910991582090642011229452721346107806307863040223071914240315202967004285204");
/// COEFF_B = 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931
/// Needs to be in the Montgomery residue form in Fq
// I.e., 272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931 * R for Fq
// = 320157167097726084542307919580965705308273073979019302261176143711555219255114245445508756
#[rustfmt::skip]
const COEFF_B: Fq = field_new!(Fq, BigInteger320([
3452336036810055316u64,
18124271906235581187u64,
7868316676197606962u64,
9218705727289990924u64,
2764931259177u64,
]));
const COEFF_B: Fq = field_new!(Fq, "272359039153593414761767159011037222092403532445017207690227512667250406992205523555677931");
type TEModelParameters = EdwardsParameters;
}
/// GENERATOR_X =
/// 282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227
/// Needs to be in the Montgomery residue form in Fq
/// I.e., 282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227 * R for Fq
/// = 6917556742108450905978293995070573074174231920036503115659104908111915200040057661385715
#[rustfmt::skip]
const GENERATOR_X: Fq = field_new!(Fq, BigInteger320([
797921980254612467u64,
14323677897559322103u64,
16879595040064082265u64,
5138786402348661261u64,
59741186014u64,
]));
const GENERATOR_X: Fq = field_new!(Fq, "282406820114868156776872298252698015906762052916420164316497572033519876761239463633892227");
/// GENERATOR_Y =
/// 452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703
/// Needs to be in the Montgomery residue form in Fq
/// I.e., 452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703 * R for Fq
/// = 411219337323952690830344109182130393590959634960952808951091963301565250764467583592890490
#[rustfmt::skip]
const GENERATOR_Y: Fq = field_new!(Fq, BigInteger320([
16522567711648317562u64,
4273808507945498262u64,
17459848913470201097u64,
16519670308098023011u64,
3551359510243u64,
]));
const GENERATOR_Y: Fq = field_new!(Fq, "452667754940241021433619311795265643711152068500301853535337412655162600774122192283142703");

Loading…
Cancel
Save