openvm_pairing_guest/bn254/
mod.rs

1#[cfg(not(target_os = "zkvm"))]
2use hex_literal::hex;
3#[cfg(not(target_os = "zkvm"))]
4use lazy_static::lazy_static;
5#[cfg(not(target_os = "zkvm"))]
6use num_bigint::BigUint;
7
8#[cfg(all(test, feature = "halo2curves", not(target_os = "zkvm")))]
9pub mod tests;
10
11#[cfg(not(target_os = "zkvm"))]
12lazy_static! {
13    pub static ref BN254_MODULUS: BigUint = BigUint::from_bytes_be(&hex!(
14        "30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47"
15    ));
16    pub static ref BN254_ORDER: BigUint = BigUint::from_bytes_be(&hex!(
17        "30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"
18    ));
19}
20
21pub const BN254_XI_ISIZE: [isize; 2] = [9, 1];
22pub const BN254_NUM_LIMBS: usize = 32;
23pub const BN254_LIMB_BITS: usize = 8;
24pub const BN254_BLOCK_SIZE: usize = 32;
25
26pub const BN254_SEED: u64 = 0x44e992b44a6909f1;
27// Encodes 6x+2 where x is the BN254 seed.
28// 6*x+2 = sum_i BN254_PSEUDO_BINARY_ENCODING[i] * 2^i
29// where BN254_PSEUDO_BINARY_ENCODING[i] is in {-1, 0, 1}
30// Validated against BN254_SEED_ABS by a test in tests.rs
31pub const BN254_PSEUDO_BINARY_ENCODING: [i8; 66] = [
32    0, 0, 0, 1, 0, 1, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, -1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0,
33    -1, 0, 0, 1, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 1, 0, -1, 0, 0, 0, -1, 0, -1, 0,
34    0, 0, 1, 0, -1, 0, 1,
35];
36
37#[cfg(not(target_os = "zkvm"))]
38// Used in WeierstrassExtension config
39pub const BN254_ECC_STRUCT_NAME: &str = "Bn254G1Affine";
40
41#[cfg(not(target_os = "zkvm"))]
42// Used in Fp2Extension config
43pub const BN254_COMPLEX_STRUCT_NAME: &str = "Bn254Fp2";