Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
calculate extension field zeta in compile time

bring back some removed comments
  • Loading branch information
kilic committed Jun 13, 2024
1 parent aecd32b commit a7c9345
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
2 changes: 2 additions & 0 deletions derive/src/field/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ fn impl_add(field: &syn::Ident, num_limbs: usize) -> TokenStream {
gen.extend(quote! { let ( #d_i, carry) = adc(self.0[#i], rhs.0[#i], #carry); });
});

// Attempt to subtract the modulus, to ensure the value
// is smaller than the modulus.
(0..num_limbs).for_each(|i| {
let borrow = select(i == 0, quote! {0}, quote! {borrow});
let d_i = fmtid!("d_{}", i);
Expand Down
7 changes: 0 additions & 7 deletions src/bn256/fq2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,6 @@ impl FromUniformBytes<96> for Fq2 {
}
}

const ZETA: Fq = Fq::from_raw([
0x5763473177fffffe,
0xd4f263f1acdb5c4f,
0x59e26bcea0d48bac,
0x0000000000000000,
]);

#[cfg(test)]
mod test {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/derive/field/tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ macro_rules! impl_tower2 {
impl WithSmallOrderMulGroup<3> for $tower {
// $field::ZETA ^2
const ZETA: Self = $tower {
c0: ZETA,
c0: $field::ZETA.mul_const(&$field::ZETA),
c1: $field::ZERO,
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/pluto_eris/fp12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,16 @@ impl Field for Fp12 {
}

fn sqrt(&self) -> CtOption<Self> {
// The square root method is typically only required for finding y-coordinate
// given the x-coordinate of an EC point. Fields over which we have not
// defined a curve do not need this method.
unimplemented!()
}

fn sqrt_ratio(_num: &Self, _div: &Self) -> (Choice, Self) {
// The square root method is typically only required for finding y-coordinate
// given the x-coordinate of an EC point. Fields over which we have not
// defined a curve do not need this method.
unimplemented!()
}

Expand Down
10 changes: 0 additions & 10 deletions src/pluto_eris/fp2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,6 @@ impl Fp2 {
}
}

const ZETA: Fp = Fp::from_raw([
0x8ffff80f80000002,
0xd9fa5d8a200bc439,
0x1b50d5e1ff708dc8,
0xf43f8cddf9a5c478,
0xa803ca76be3924a5,
0x0130e0000d7f28e4,
0x2400000000002400,
]);

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit a7c9345

Please sign in to comment.