mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-27 14:13:46 +01:00
GLV implementation for BLS12_377, BLS12_381 and BN254 (#158)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
use ark_ec::{
|
||||
models::{short_weierstrass::SWCurveConfig, CurveConfig},
|
||||
scalar_mul::glv::GLVConfig,
|
||||
short_weierstrass::{Affine, Projective},
|
||||
};
|
||||
use ark_ff::{AdditiveGroup, MontFp};
|
||||
use ark_ff::{AdditiveGroup, BigInt, MontFp, PrimeField};
|
||||
|
||||
use crate::{Fq, Fr};
|
||||
|
||||
@@ -49,6 +50,46 @@ impl SWCurveConfig for Config {
|
||||
}
|
||||
}
|
||||
|
||||
impl GLVConfig for Config {
|
||||
const ENDO_COEFFS: &'static [Self::BaseField] = &[MontFp!(
|
||||
"4922464560225523242118178942575080391082002530232324381063048548642823052024664478336818169867474395270858391911405337707247735739826664939444490469542109391530482826728203582549674992333383150446779312029624171857054392282775648"
|
||||
)];
|
||||
|
||||
const LAMBDA: Self::ScalarField =
|
||||
MontFp!("258664426012969093929703085429980814127835149614277183275038967946009968870203535512256352201271898244626862047231");
|
||||
|
||||
const SCALAR_DECOMP_COEFFS: [(bool, <Self::ScalarField as PrimeField>::BigInt); 4] = [
|
||||
(
|
||||
true,
|
||||
BigInt!("293634935485640680722085584138834120324914961969255022593"),
|
||||
),
|
||||
(
|
||||
false,
|
||||
BigInt!("293634935485640680722085584138834120315328839056164388863"),
|
||||
),
|
||||
(
|
||||
true,
|
||||
BigInt!("293634935485640680722085584138834120315328839056164388863"),
|
||||
),
|
||||
(
|
||||
true,
|
||||
BigInt!("587269870971281361444171168277668240640243801025419411456"),
|
||||
),
|
||||
];
|
||||
|
||||
fn endomorphism(p: &Projective<Self>) -> Projective<Self> {
|
||||
let mut res = (*p).clone();
|
||||
res.x *= Self::ENDO_COEFFS[0];
|
||||
res
|
||||
}
|
||||
|
||||
fn endomorphism_affine(p: &Affine<Self>) -> Affine<Self> {
|
||||
let mut res = (*p).clone();
|
||||
res.x *= Self::ENDO_COEFFS[0];
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
/// G1_GENERATOR_X =
|
||||
/// 6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237
|
||||
pub const G1_GENERATOR_X: Fq = MontFp!("6238772257594679368032145693622812838779005809760824733138787810501188623461307351759238099287535516224314149266511977132140828635950940021790489507611754366317801811090811367945064510304504157188661901055903167026722666149426237");
|
||||
|
||||
Reference in New Issue
Block a user