openvm_ecc_guest/
lib.rs

1#![no_std]
2extern crate self as openvm_ecc_guest;
3#[macro_use]
4extern crate alloc;
5
6#[cfg(feature = "halo2curves")]
7pub use halo2curves_axiom as halo2curves;
8pub use once_cell;
9pub use openvm_algebra_guest as algebra;
10pub use openvm_ecc_sw_macros as sw_macros;
11use strum_macros::FromRepr;
12
13mod affine_point;
14pub use affine_point::*;
15mod group;
16pub use group::*;
17mod msm;
18pub use msm::*;
19
20/// ECDSA
21pub mod ecdsa;
22/// Weierstrass curve traits
23pub mod weierstrass;
24
25/// Types for Secp256k1 curve with intrinsic functions. Implements traits necessary for ECDSA.
26#[cfg(feature = "k256")]
27pub mod k256;
28
29/// a.k.a. Secp256r1
30#[cfg(feature = "p256")]
31pub mod p256;
32
33#[cfg(all(test, feature = "k256", feature = "p256", not(target_os = "zkvm")))]
34mod tests;
35
36/// This is custom-1 defined in RISC-V spec document
37pub const OPCODE: u8 = 0x2b;
38pub const SW_FUNCT3: u8 = 0b001;
39
40/// Short Weierstrass curves are configurable.
41/// The funct7 field equals `curve_idx * SHORT_WEIERSTRASS_MAX_KINDS + base_funct7`.
42#[derive(Debug, Copy, Clone, PartialEq, Eq, FromRepr)]
43#[repr(u8)]
44pub enum SwBaseFunct7 {
45    SwAddNe = 0,
46    SwDouble,
47    SwSetup,
48    HintDecompress,
49    HintNonQr,
50}
51
52impl SwBaseFunct7 {
53    pub const SHORT_WEIERSTRASS_MAX_KINDS: u8 = 8;
54}