Skip to content

Commit

Permalink
Update gating
Browse files Browse the repository at this point in the history
  • Loading branch information
ytham committed Jan 4, 2025
1 parent 8024db3 commit 073315d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
10 changes: 8 additions & 2 deletions extensions/pairing/guest/src/curve_const/bls12_381.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
use halo2curves_axiom::bls12_381::{Fq, Fq2};
use lazy_static::lazy_static;
use num_bigint::BigUint;
use num_traits::Num;
use openvm_ecc_guest::algebra::{field::FieldExtension, Field};
#[cfg(feature = "halo2curves")]
use {
halo2curves_axiom::bls12_381::{Fq, Fq2},
openvm_ecc_guest::algebra::{field::FieldExtension, Field},
};

#[cfg(feature = "halo2curves")]
lazy_static! {
pub static ref BLS12_381_XI: Fq2 = Fq2::from_coeffs([Fq::ONE, Fq::ONE]);
}

lazy_static! {
// polyFactor = (1-x)/3
pub static ref POLY_FACTOR: BigUint = BigUint::from_str_radix("5044125407647214251", 10).unwrap();

Expand Down
10 changes: 8 additions & 2 deletions extensions/pairing/guest/src/curve_const/bn254.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
use halo2curves_axiom::bn256::{Fq, Fq2};
use lazy_static::lazy_static;
use num_bigint::BigUint;
use num_traits::Num;
use openvm_ecc_guest::algebra::field::FieldExtension;
#[cfg(feature = "halo2curves")]
use {
halo2curves_axiom::bn256::{Fq, Fq2},
openvm_ecc_guest::algebra::field::FieldExtension,
};

#[cfg(feature = "halo2curves")]
lazy_static! {
pub static ref BN254_XI: Fq2 = Fq2::from_coeffs([Fq::from_raw([9, 0, 0, 0]), Fq::one()]);
}

lazy_static! {
// exp1 = (p^12 - 1) / 3
pub static ref EXP1: BigUint = BigUint::from_str_radix(
"4030969696062745741797811005853058291874379204406359442560681893891674450106959530046539719647151210908190211459382793062006703141168852426020468083171325367934590379984666859998399967609544754664110191464072930598755441160008826659219834762354786403012110463250131961575955268597858015384895449311534622125256548620283853223733396368939858981844663598065852816056384933498610930035891058807598891752166582271931875150099691598048016175399382213304673796601585080509443902692818733420199004555566113537482054218823936116647313678747500267068559627206777530424029211671772692598157901876223857571299238046741502089890557442500582300718504160740314926185458079985126192563953772118929726791041828902047546977272656240744693339962973939047279285351052107950250121751682659529260304162131862468322644288196213423232132152125277136333208005221619443705106431645884840489295409272576227859206166894626854018093044908314720",
Expand Down
2 changes: 2 additions & 0 deletions extensions/pairing/guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ pub mod affine_point;
/// These should **only** be importable on a host machine.
#[cfg(all(feature = "halo2curves", not(target_os = "zkvm")))]
pub mod halo2curves_shims;

/// Traits for optimal Ate pairing check using intrinsic functions.
pub mod pairing;

/// Pairing curve constants. Only importable on a host machine.
#[cfg(all(
any(feature = "bls12_381", feature = "bn254", feature = "halo2curves"),
not(target_os = "zkvm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ openvm_algebra_moduli_setup::moduli_init! {
}

pub fn main() {
#[allow(clippy::type_complexity)]
let (p, q, expected): (Vec<AffinePoint<Fp>>, Vec<AffinePoint<Fp2>>, (Fp12, Fp12)) = read();
let actual = Bls12_381::pairing_check_hint(&p, &q);
assert_eq!(actual, expected);
Expand Down

0 comments on commit 073315d

Please sign in to comment.