Skip to content

Commit

Permalink
Merge branch 'main' into nev@expose-curveEndo
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnevadoc authored Jul 5, 2024
2 parents dffa8bc + d34e9e4 commit 4cdb5f3
Show file tree
Hide file tree
Showing 35 changed files with 1,695 additions and 3,484 deletions.
19 changes: 10 additions & 9 deletions derive/src/field/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,6 @@ pub(crate) fn impl_field(input: TokenStream) -> TokenStream {
}
}

impl ::core::ops::Neg for #field {
type Output = #field;

#[inline]
fn neg(self) -> #field {
-&self
}
}

impl #field {
pub const SIZE: usize = #num_limbs * 8;
Expand Down Expand Up @@ -393,8 +385,17 @@ pub(crate) fn impl_field(input: TokenStream) -> TokenStream {
self.square()
}

// Returns the multiplicative inverse of the element. If it is zero, the method fails.
#[inline(always)]
fn invert(&self) -> CtOption<Self> {
self.invert()
const BYINVERTOR: crate::ff_ext::inverse::BYInverter<#by_inverter_constant> =
crate::ff_ext::inverse::BYInverter::<#by_inverter_constant>::new(&#modulus_limbs_ident, &#r2);

if let Some(inverse) = BYINVERTOR.invert::<{ Self::NUM_LIMBS }>(&self.0) {
subtle::CtOption::new(Self(inverse), subtle::Choice::from(1))
} else {
subtle::CtOption::new(Self::zero(), subtle::Choice::from(0))
}
}

#sqrt_impl
Expand Down
5 changes: 2 additions & 3 deletions src/bn256/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use crate::ff::{Field, PrimeField};
use crate::group::Curve;
use crate::group::{cofactor::CofactorGroup, prime::PrimeCurveAffine, Group, GroupEncoding};
use crate::{
impl_add_binop_specify_output, impl_binops_additive, impl_binops_additive_specify_output,
impl_binops_multiplicative, impl_binops_multiplicative_mixed, impl_sub_binop_specify_output,
new_curve_impl,
impl_binops_additive, impl_binops_additive_specify_output, impl_binops_multiplicative,
impl_binops_multiplicative_mixed, new_curve_impl,
};
use crate::{Coordinates, CurveAffine, CurveExt};
use core::cmp;
Expand Down
Loading

0 comments on commit 4cdb5f3

Please sign in to comment.