openvm_pairing_guest/halo2curves_shims/bls12_381/
curve.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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};

lazy_static! {
    pub static ref BLS12_381_XI: Fq2 = Fq2::from_coeffs([Fq::ONE, Fq::ONE]);

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

    // finalExpFactor = ((q^12 - 1) / r) / (27 * polyFactor)
    pub static ref FINAL_EXP_FACTOR: BigUint = BigUint::from_str_radix("2366356426548243601069753987687709088104621721678962410379583120840019275952471579477684846670499039076873213559162845121989217658133790336552276567078487633052653005423051750848782286407340332979263075575489766963251914185767058009683318020965829271737924625612375201545022326908440428522712877494557944965298566001441468676802477524234094954960009227631543471415676620753242466901942121887152806837594306028649150255258504417829961387165043999299071444887652375514277477719817175923289019181393803729926249507024121957184340179467502106891835144220611408665090353102353194448552304429530104218473070114105759487413726485729058069746063140422361472585604626055492939586602274983146215294625774144156395553405525711143696689756441298365274341189385646499074862712688473936093315628166094221735056483459332831845007196600723053356837526749543765815988577005929923802636375670820616189737737304893769679803809426304143627363860243558537831172903494450556755190448279875942974830469855835666815454271389438587399739607656399812689280234103023464545891697941661992848552456326290792224091557256350095392859243101357349751064730561345062266850238821755009430903520645523345000326783803935359711318798844368754833295302563158150573540616830138810935344206231367357992991289265295323280", 10).unwrap();

    // lambda = q - x, the optimal exponent
    pub static ref LAMBDA: BigUint = BigUint::from_str_radix("4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129030796414117214202539", 10).unwrap();

    // t = -x = 15132376222941642752
    pub static ref SEED_NEG: BigUint = BigUint::from_str_radix("15132376222941642752", 10).unwrap();
}

pub struct Bls12_381;