openvm_pairing_guest/
lib.rs

1#![no_std]
2use strum_macros::FromRepr;
3
4/// This is custom-1 defined in RISC-V spec document
5pub const OPCODE: u8 = 0x2b;
6pub const PAIRING_FUNCT3: u8 = 0b011;
7
8/// The funct7 field equals `pairing_idx * PAIRING_MAX_KINDS + base_funct7`.
9#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
10#[repr(u8)]
11pub enum PairingBaseFunct7 {
12    HintFinalExp = 0,
13}
14
15impl PairingBaseFunct7 {
16    pub const PAIRING_MAX_KINDS: u8 = 16;
17}
18
19extern crate alloc;
20extern crate self as openvm_ecc;
21
22#[cfg(feature = "halo2curves")]
23pub use halo2curves_axiom as halo2curves;
24pub use openvm_algebra_guest as algebra;
25
26/// Implementation of this library's traits on halo2curves types.
27/// Used for testing and also VM runtime execution.
28/// These should **only** be importable on a host machine.
29#[cfg(all(feature = "halo2curves", not(target_os = "zkvm")))]
30pub mod halo2curves_shims;
31/// Traits for optimal Ate pairing check using intrinsic functions.
32pub mod pairing;
33
34/// Types for BLS12-381 curve with intrinsic functions.
35#[cfg(feature = "bls12_381")]
36pub mod bls12_381;
37/// Types for BN254 curve with intrinsic functions.
38#[cfg(feature = "bn254")]
39pub mod bn254;