arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
Add optimization for bls12_381 and bn254
ValarDragon dojha12@gmail.com
Fri, 05 Feb 2021 12:48:57 -0600
commit

64ece6414f731050df64a36b2ab409189ca14df2

parent

bb033e9949d47e49cae158b47b3d3d1946ee8c23

2 files changed, 24 insertions(+), 0 deletions(-)

jump to
M bls12_381/src/fields/fq2.rs → bls12_381/src/fields/fq2.rs

@@ -29,6 +29,18 @@ #[inline(always)]

fn mul_fp_by_nonresidue(fp: &Self::Fp) -> Self::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);
M bn254/src/fields/fq2.rs → bn254/src/fields/fq2.rs

@@ -32,6 +32,18 @@ #[inline(always)]

fn mul_fp_by_nonresidue(fe: &Self::Fp) -> Self::Fp { -(*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);