Skip to content

Commit

Permalink
Revert "changed final_exp to avoid unwrap"
Browse files Browse the repository at this point in the history
This reverts commit 2c3b0c6.
  • Loading branch information
jotabulacios committed Nov 4, 2024
1 parent 2c3b0c6 commit 1e57ac7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::traits::ByteConversion;
use crate::unsigned_integer::element::U384;

pub const BLS12377_PRIME_FIELD_ORDER: U384 = U384::from_hex_unchecked("1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508c00000000001");
pub const FP2_RESIDUE: FieldElement<BLS12377PrimeField> =FieldElement::from_hex_unchecked("0x1ae3a4617c510eac63b05c06ca1493b1a22d9f300f5138f1ef3622fba094800170b5d44300000008508bffffffffffc");
pub const FP2_RESIDUE: FieldElement<BLS12377PrimeField> =FieldElement::from_hex_unchecked("1AE3A4617C510EAC63B05C06CA1493B1A22D9F300F5138F1EF3622FBA094800170B5D44300000008508BFFFFFFFFFFC");

// FPBLS12377
#[derive(Clone, Debug)]
Expand Down Expand Up @@ -298,7 +298,6 @@ impl FieldElement<Degree12ExtensionField> {
])
}
}

impl HasQuadraticNonResidue<Degree2ExtensionField> for LevelTwoResidue {
fn residue() -> FieldElement<Degree2ExtensionField> {
FieldElement::new([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::{
twist::BLS12377TwistCurve,
};
use crate::{cyclic_group::IsGroup, elliptic_curve::traits::IsPairing, errors::PairingError};

use crate::{
elliptic_curve::short_weierstrass::{
curves::bls12_377::field_extension::Degree6ExtensionField,
Expand Down Expand Up @@ -118,7 +119,7 @@ impl IsPairing for BLS12377AtePairing {
result *= miller(&p, &q);
}
}
final_exponentiation(&result)
Ok(final_exponentiation(&result))
}
}

Expand Down Expand Up @@ -288,8 +289,9 @@ pub fn cyclotomic_square(a: &Fp12E) -> Fp12E {
// To understand more about how to reduce the final exponentiation
// read "Efficient Final Exponentiation via Cyclotomic Structure for
// Pairings over Families of Elliptic Curves" (https://eprint.iacr.org/2020/875.pdf)
pub fn final_exponentiation(f: &Fp12E) -> Result<Fp12E, PairingError> {
let f_easy_aux = f.conjugate() * f.inv().map_err(|_| PairingError::DivisionByZero)?;

pub fn final_exponentiation(f: &Fp12E) -> Fp12E {
let f_easy_aux = f.conjugate() * f.inv().unwrap();
let mut f_easy = frobenius_square(&f_easy_aux) * &f_easy_aux;

let mut v2 = cyclotomic_square(&f_easy); // v2 = f²
Expand Down Expand Up @@ -320,7 +322,7 @@ pub fn final_exponentiation(f: &Fp12E) -> Result<Fp12E, PairingError> {
v0 *= &v2; // v0 = f^((x-1)².(x+p).(x²+p²-1))

f_easy *= &v0;
Ok(f_easy)
f_easy
}

pub fn cyclotomic_pow_x(f: &Fp12E) -> Fp12E {
Expand Down
1 change: 0 additions & 1 deletion math/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub enum DeserializationError {
#[derive(Debug, PartialEq, Eq)]
pub enum PairingError {
PointNotInSubgroup,
DivisionByZero,
}

impl From<ByteConversionError> for DeserializationError {
Expand Down

0 comments on commit 1e57ac7

Please sign in to comment.