mirror of
https://github.com/arnaucube/ark-curves-cherry-picked.git
synced 2026-01-09 23:41:30 +01:00
Add optimization for bls12_381 and bn254
This commit is contained in:
@@ -29,6 +29,18 @@ impl Fp2Parameters for Fq2Parameters {
|
|||||||
fn mul_fp_by_nonresidue(fp: &Self::Fp) -> Self::Fp {
|
fn mul_fp_by_nonresidue(fp: &Self::Fp) -> Self::Fp {
|
||||||
-(*fp)
|
-(*fp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// x + -1 * y, computed as x - y
|
||||||
|
#[inline(always)]
|
||||||
|
fn add_and_mul_fp_by_nonresidue(x: &Self::Fp, y: &Self::Fp) -> Self::Fp {
|
||||||
|
*x - y
|
||||||
|
}
|
||||||
|
|
||||||
|
// x - (-1 * y), computed as x + y
|
||||||
|
#[inline(always)]
|
||||||
|
fn sub_and_mul_fp_by_nonresidue(x: &Self::Fp, y: &Self::Fp) -> Self::Fp {
|
||||||
|
*x + y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
|
pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
|
||||||
|
|||||||
@@ -32,6 +32,18 @@ impl Fp2Parameters for Fq2Parameters {
|
|||||||
fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
|
fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp {
|
||||||
-(*fe)
|
-(*fe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// x + -1 * y, computed as x - y
|
||||||
|
#[inline(always)]
|
||||||
|
fn add_and_mul_fp_by_nonresidue(x: &Self::Fp, y: &Self::Fp) -> Self::Fp {
|
||||||
|
*x - y
|
||||||
|
}
|
||||||
|
|
||||||
|
// x - (-1 * y), computed as x + y
|
||||||
|
#[inline(always)]
|
||||||
|
fn sub_and_mul_fp_by_nonresidue(x: &Self::Fp, y: &Self::Fp) -> Self::Fp {
|
||||||
|
*x + y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
|
pub const FQ2_ZERO: Fq2 = field_new!(Fq2, FQ_ZERO, FQ_ZERO);
|
||||||
|
|||||||
Reference in New Issue
Block a user