diff --git a/benchmarks/guest/ecrecover/openvm_init.rs b/benchmarks/guest/ecrecover/openvm_init.rs index bec9f527e9..dc6d4917dd 100644 --- a/benchmarks/guest/ecrecover/openvm_init.rs +++ b/benchmarks/guest/ecrecover/openvm_init.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/benchmarks/guest/kitchen-sink/openvm_init.rs b/benchmarks/guest/kitchen-sink/openvm_init.rs index c4a80b3602..fdec4a6bdb 100644 --- a/benchmarks/guest/kitchen-sink/openvm_init.rs +++ b/benchmarks/guest/kitchen-sink/openvm_init.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "1000000000000000003", "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337", "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369", "21888242871839275222246405745257275088696311157297823662689037894645226208583", "21888242871839275222246405745257275088548364400416034343698204186575808495617", "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", "52435875175126190479447740508185965837690552500527637822603658699938581184513", "2305843009213693951", "7" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 5 }, Bls12_381Fp2 { mod_idx = 7 } } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point, P256Point, Bn254G1Affine, Bls12_381G1Affine } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 5 }, "Bls12_381Fp2" { mod_idx = 7 } } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point", "P256Point", "Bn254G1Affine", "Bls12_381G1Affine" } diff --git a/benchmarks/guest/pairing/openvm_init.rs b/benchmarks/guest/pairing/openvm_init.rs index 5baf894946..25f8df7f78 100644 --- a/benchmarks/guest/pairing/openvm_init.rs +++ b/benchmarks/guest/pairing/openvm_init.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583", "21888242871839275222246405745257275088548364400416034343698204186575808495617" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { Bn254G1Affine } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! { "Bn254G1Affine" } diff --git a/book/src/custom-extensions/algebra.md b/book/src/custom-extensions/algebra.md index 2e1f830153..c4bcc936b1 100644 --- a/book/src/custom-extensions/algebra.md +++ b/book/src/custom-extensions/algebra.md @@ -80,7 +80,7 @@ moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } complex_init! { - Bn254Fp2 { mod_idx = 0 }, + "Bn254Fp2" { mod_idx = 0 }, } */ ``` diff --git a/book/src/custom-extensions/ecc.md b/book/src/custom-extensions/ecc.md index ba0fff90d6..de8f31ab62 100644 --- a/book/src/custom-extensions/ecc.md +++ b/book/src/custom-extensions/ecc.md @@ -49,7 +49,7 @@ This creates `Bls12_381G1Affine` and `P256Affine` structs which implement the `G openvm::init!(); /* This expands to sw_init! { - Bls12_381G1Affine, P256Affine, + "Bls12_381G1Affine", "P256Affine", } */ ``` diff --git a/docs/specs/ISA.md b/docs/specs/ISA.md index 67365d7857..eb4eb5004c 100644 --- a/docs/specs/ISA.md +++ b/docs/specs/ISA.md @@ -711,7 +711,7 @@ r32_ec_point(a) -> EcPoint { | EC_ADD_NE\ | `a,b,c,1,2` | Set `r32_ec_point(a) = r32_ec_point(b) + r32_ec_point(c)` (curve addition). Assumes that `r32_ec_point(b), r32_ec_point(c)` both lie on the curve and are not the identity point. Further assumes that `r32_ec_point(b).x, r32_ec_point(c).x` are not equal in the coordinate field. | | SETUP_EC_ADD_NE\ | `a,b,c,1,2` | `assert(r32_ec_point(b).x == C::MODULUS)` in the chip for EC ADD. For the sake of implementation convenience it also writes something (can be anything) into `[r32{0}(a): 2*C::COORD_SIZE]_2`. It is required for proper functionality that `assert(r32_ec_point(b).x != r32_ec_point(c).x)` | | EC_DOUBLE\ | `a,b,_,1,2` | Set `r32_ec_point(a) = 2 * r32_ec_point(b)`. This doubles the input point. Assumes that `r32_ec_point(b)` lies on the curve and is not the identity point. | -| SETUP_EC_DOUBLE\ | `a,b,_,1,2` | `assert(r32_ec_point(b).x == C::MODULUS)` in the chip for EC DOUBLE. For the sake of implementation convenience it also writes something (can be anything) into `[r32{0}(a): 2*C::COORD_SIZE]_2`. It is required for proper functionality that `assert(r32_ec_point(b).y != 0 mod C::MODULUS)` | +| SETUP_EC_DOUBLE\ | `a,b,_,1,2` | `assert(r32_ec_point(b).x == C::MODULUS && r32_ec_point(b).y == C::A)` in the chip for EC DOUBLE. For the sake of implementation convenience it also writes something (can be anything) into `[r32{0}(a): 2*C::COORD_SIZE]_2`. It is required for proper functionality that `assert(r32_ec_point(b).y != 0 mod C::MODULUS)` | ### Pairing Extension diff --git a/docs/specs/RISCV.md b/docs/specs/RISCV.md index 32d0cc63fa..82ad9c1445 100644 --- a/docs/specs/RISCV.md +++ b/docs/specs/RISCV.md @@ -76,7 +76,7 @@ the guest must take care to validate all data and account for behavior in cases |--------------|-----|-------------|---------|--------|------------------------------------------------------------------------------------------------------------------------------| | nativestorew | R | 0001011 | 111 | 0x2 | Stores the 4-byte word `rs1` at address `rd` in native address space. The address `rd` must be aligned to a 4-byte boundary. | -`nativestorew` connects RV32 address space and native address space. We put it in RV32 extension because its +`nativestorew` connects RV32 address space and native address space. We put it in RV32 extension because its implementation is here. But we use `funct3 = 111` because the native extension has an available slot. ## Keccak Extension @@ -182,7 +182,7 @@ The elliptic curve extension supports arithmetic over short Weierstrass curves, | --------------- | --- | ----------- | ------ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | sw_add_ne\ | R | 0101011 | 001 | `idx*8` | `EcPoint([rd:2*C::COORD_SIZE]_2) = EcPoint([rs1:2*C::COORD_SIZE]_2) + EcPoint([rs2:2*C::COORD_SIZE]_2)`. Assumes that input affine points are not identity and do not have same x-coordinate. | | sw_double\ | R | 0101011 | 001 | `idx*8+1` | `EcPoint([rd:2*C::COORD_SIZE]_2) = 2 * EcPoint([rs1:2*C::COORD_SIZE]_2)`. Assumes that input affine point is not identity. `rs2` is unused and must be set to `x0`. | -| setup\ | R | 0101011 | 001 | `idx*8+2` | `assert([rs1: C::COORD_SIZE]_2 == C::MODULUS)` in the chip defined by the register index of `rs2`. For the sake of implementation convenience it also writes an unconstrained value into `[rd: 2*C::COORD_SIZE]_2`. If `ind(rs2) != 0`, then this instruction is setup for `sw_add_ne`. Otherwise it is setup for `sw_double`. When `ind(rs2) != 0` (add_ne), it is required for proper functionality that `[rs2: C::COORD_SIZE]_2 != [rs1: C::COORD_SIZE]_2`; otherwise (double), it is required that `[rs1 + C::COORD_SIZE: C::COORD_SIZE]_2 != C::Fp::ZERO` | +| setup\ | R | 0101011 | 001 | `idx*8+2` | If `ind(rs2) != 0`, then this instruction is setup for `sw_add_ne`. Otherwise it is setup for `sw_double`. If setup for `sw_add_ne`, it checks `assert([rs1: C::COORD_SIZE]_2 == C::MODULUS)`, and if setup for `sw_double`, checks `assert([rs1: 2*C::COORD_SIZE]_2 == [C::MODULUS, CURVE_A])`. For the sake of implementation convenience it also writes an unconstrained value into `[rd: 2*C::COORD_SIZE]_2`. When `ind(rs2) != 0` (add_ne), it is required for proper functionality that `[rs2: C::COORD_SIZE]_2 != [rs1: C::COORD_SIZE]_2`; otherwise (double), it is required that `[rs1 + C::COORD_SIZE: C::COORD_SIZE]_2 != C::Fp::ZERO` | Since `funct7` is 7-bits, up to 16 curves can be supported simultaneously. We use `idx*8` to leave some room for future expansion. diff --git a/examples/algebra/Cargo.toml b/examples/algebra/Cargo.toml index 9d369431c8..f9a0350c9f 100644 --- a/examples/algebra/Cargo.toml +++ b/examples/algebra/Cargo.toml @@ -17,3 +17,8 @@ num-bigint = { version = "0.4.6", features = ["serde"] } [features] default = [] + +# remove this if copying example outside of monorepo +[patch."https://github.com/openvm-org/openvm.git"] +openvm = { path = "../../crates/toolchain/openvm" } +openvm-algebra-guest = { path = "../../extensions/algebra/guest" } diff --git a/examples/algebra/openvm_init.rs b/examples/algebra/openvm_init.rs index 1de98b97a1..75324d5509 100644 --- a/examples/algebra/openvm_init.rs +++ b/examples/algebra/openvm_init.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "998244353", "1000000007" } -openvm_algebra_guest::complex_macros::complex_init! { Complex1 { mod_idx = 0 }, Complex2 { mod_idx = 1 } } +openvm_algebra_guest::complex_macros::complex_init! { "Complex1" { mod_idx = 0 }, "Complex2" { mod_idx = 1 } } diff --git a/examples/algebra/src/main.rs b/examples/algebra/src/main.rs index e2265a2c97..3a45d1c463 100644 --- a/examples/algebra/src/main.rs +++ b/examples/algebra/src/main.rs @@ -28,7 +28,7 @@ moduli_init! { // The order of these structs does not matter, // given that we specify the `mod_idx` parameters properly. openvm_algebra_complex_macros::complex_init! { - Complex1 { mod_idx = 0 }, Complex2 { mod_idx = 1 }, + "Complex1" { mod_idx = 0 }, "Complex2" { mod_idx = 1 }, } */ diff --git a/examples/ecc/openvm_init.rs b/examples/ecc/openvm_init.rs index bec9f527e9..dc6d4917dd 100644 --- a/examples/ecc/openvm_init.rs +++ b/examples/ecc/openvm_init.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/examples/ecc/src/main.rs b/examples/ecc/src/main.rs index f95b6272ad..5114b9968f 100644 --- a/examples/ecc/src/main.rs +++ b/examples/ecc/src/main.rs @@ -13,9 +13,7 @@ openvm_algebra_guest::moduli_macros::moduli_init! { "0xFFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141" } -openvm_ecc_guest::sw_macros::sw_init! { - Secp256k1Point, -} +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } */ // ANCHOR_END: init diff --git a/examples/pairing/openvm_init.rs b/examples/pairing/openvm_init.rs index 991d1237fc..f25d37c998 100644 --- a/examples/pairing/openvm_init.rs +++ b/examples/pairing/openvm_init.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } diff --git a/examples/pairing/src/main.rs b/examples/pairing/src/main.rs index 1a85b2e271..681527ca99 100644 --- a/examples/pairing/src/main.rs +++ b/examples/pairing/src/main.rs @@ -19,7 +19,7 @@ openvm_algebra_moduli_macros::moduli_init! { } openvm_algebra_complex_macros::complex_init! { - Bls12_381Fp2 { mod_idx = 0 }, + "Bls12_381Fp2" { mod_idx = 0 }, } */ // ANCHOR_END: init diff --git a/extensions/algebra/circuit/src/fp2_extension.rs b/extensions/algebra/circuit/src/fp2_extension.rs index 41ed9924e5..a7b481fe6e 100644 --- a/extensions/algebra/circuit/src/fp2_extension.rs +++ b/extensions/algebra/circuit/src/fp2_extension.rs @@ -62,7 +62,7 @@ impl Fp2Extension { .iter() .map(|(name, modulus)| { format!( - "{} {{ mod_idx = {} }}", + "\"{}\" {{ mod_idx = {} }}", name, get_index_of_modulus(modulus, modular_config) ) diff --git a/extensions/algebra/complex-macros/README.md b/extensions/algebra/complex-macros/README.md index 8536b9c371..fb510736c4 100644 --- a/extensions/algebra/complex-macros/README.md +++ b/extensions/algebra/complex-macros/README.md @@ -22,7 +22,7 @@ openvm_algebra_moduli_macros::moduli_init!( ); openvm_algebra_complex_macros::complex_init! { - Complex { mod_idx = 0 }, + "Complex" { mod_idx = 0 }, } */ @@ -39,7 +39,7 @@ The crate provides two macros: `complex_declare!` and `complex_init!`. The signa - `complex_declare!` receives comma-separated list of moduli classes descriptions. Each description looks like `ComplexStruct { mod_type = ModulusName }`. Here `ModulusName` is the name of any struct that implements `trait IntMod` -- in particular, the ones created by `moduli_declare!` do, and `ComplexStruct` is the name for the complex arithmetic struct to create. -- `complex_init!` receives comma-separated list of struct descriptions. Each description looks like `ComplexStruct { mod_idx = idx }`. Here `ComplexStruct` is the name of the complex struct used in `complex_declare!`, and `idx` is the index of the modulus **in the `moduli_init!` macro**. +- `complex_init!` receives comma-separated list of struct descriptions. Each description looks like `"ComplexStruct" { mod_idx = idx }`. Here `ComplexStruct` is the name of the complex struct used in `complex_declare!`, and `idx` is the index of the modulus **in the `moduli_init!` macro**. What happens under the hood: @@ -96,7 +96,7 @@ complex_declare! { pub type Fp2 = Bn254Fp2; complex_init! { - Fp2 { mod_idx = 0 }, + "Fp2" { mod_idx = 0 }, } ``` diff --git a/extensions/algebra/complex-macros/src/lib.rs b/extensions/algebra/complex-macros/src/lib.rs index ba25ee7279..dfd31f66fa 100644 --- a/extensions/algebra/complex-macros/src/lib.rs +++ b/extensions/algebra/complex-macros/src/lib.rs @@ -1,10 +1,12 @@ extern crate proc_macro; -use openvm_macros_common::MacroArgs; +use openvm_macros_common::{MacroArgs, Param}; use proc_macro::TokenStream; use syn::{ parse::{Parse, ParseStream}, - parse_macro_input, Expr, ExprPath, Path, Token, + parse_macro_input, + punctuated::Punctuated, + Expr, ExprPath, LitStr, Path, Token, }; /// This macro is used to declare the complex extension fields. @@ -529,6 +531,38 @@ pub fn complex_declare(input: TokenStream) -> TokenStream { TokenStream::from_iter(output) } +// Override the MacroArgs struct to use LitStr for item names instead of Ident. +// This removes the need to import the complex struct when using the complex_init macro. +struct ComplexInitArgs { + pub items: Vec, +} + +struct ComplexInitItem { + pub name: LitStr, + pub params: Punctuated, +} + +impl Parse for ComplexInitArgs { + fn parse(input: ParseStream) -> syn::Result { + Ok(ComplexInitArgs { + items: input + .parse_terminated(ComplexInitItem::parse, Token![,])? + .into_iter() + .collect(), + }) + } +} + +impl Parse for ComplexInitItem { + fn parse(input: ParseStream) -> syn::Result { + let name = input.parse()?; + let content; + syn::braced!(content in input); + let params = content.parse_terminated(Param::parse, Token![,])?; + Ok(ComplexInitItem { name, params }) + } +} + /// This macro is used to initialize the complex extension fields. /// It must be called after `moduli_init!` is called. /// @@ -543,14 +577,14 @@ pub fn complex_declare(input: TokenStream) -> TokenStream { /// the `moduli_init!` macro (not `moduli_declare!`). #[proc_macro] pub fn complex_init(input: TokenStream) -> TokenStream { - let MacroArgs { items } = parse_macro_input!(input as MacroArgs); + let ComplexInitArgs { items } = parse_macro_input!(input as ComplexInitArgs); let mut externs = Vec::new(); let span = proc_macro::Span::call_site(); for (complex_idx, item) in items.into_iter().enumerate() { - let struct_name = item.name.to_string(); + let struct_name = item.name.value(); let struct_name = syn::Ident::new(&struct_name, span.into()); let mut intmod_idx: Option = None; for param in item.params { diff --git a/extensions/algebra/tests/programs/openvm_init_complex_redundant_modulus.rs b/extensions/algebra/tests/programs/openvm_init_complex_redundant_modulus.rs index c32e692510..523c9d5c6f 100644 --- a/extensions/algebra/tests/programs/openvm_init_complex_redundant_modulus.rs +++ b/extensions/algebra/tests/programs/openvm_init_complex_redundant_modulus.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "998244353", "1000000007", "1000000009", "987898789" } -openvm_algebra_guest::complex_macros::complex_init! { Complex2 { mod_idx = 2 } } +openvm_algebra_guest::complex_macros::complex_init! { "Complex2" { mod_idx = 2 } } diff --git a/extensions/algebra/tests/programs/openvm_init_complex_secp256k1.rs b/extensions/algebra/tests/programs/openvm_init_complex_secp256k1.rs index af98350ae4..938958f392 100644 --- a/extensions/algebra/tests/programs/openvm_init_complex_secp256k1.rs +++ b/extensions/algebra/tests/programs/openvm_init_complex_secp256k1.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663" } -openvm_algebra_guest::complex_macros::complex_init! { Complex { mod_idx = 0 } } +openvm_algebra_guest::complex_macros::complex_init! { "Complex" { mod_idx = 0 } } diff --git a/extensions/algebra/tests/programs/openvm_init_complex_two_moduli.rs b/extensions/algebra/tests/programs/openvm_init_complex_two_moduli.rs index 1de98b97a1..75324d5509 100644 --- a/extensions/algebra/tests/programs/openvm_init_complex_two_moduli.rs +++ b/extensions/algebra/tests/programs/openvm_init_complex_two_moduli.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "998244353", "1000000007" } -openvm_algebra_guest::complex_macros::complex_init! { Complex1 { mod_idx = 0 }, Complex2 { mod_idx = 1 } } +openvm_algebra_guest::complex_macros::complex_init! { "Complex1" { mod_idx = 0 }, "Complex2" { mod_idx = 1 } } diff --git a/extensions/ecc/circuit/src/weierstrass_extension.rs b/extensions/ecc/circuit/src/weierstrass_extension.rs index 6eb8c7cb1c..660276a200 100644 --- a/extensions/ecc/circuit/src/weierstrass_extension.rs +++ b/extensions/ecc/circuit/src/weierstrass_extension.rs @@ -84,7 +84,7 @@ impl WeierstrassExtension { let supported_curves = self .supported_curves .iter() - .map(|curve_config| curve_config.struct_name.to_string()) + .map(|curve_config| format!("\"{}\"", curve_config.struct_name)) .collect::>() .join(", "); diff --git a/extensions/ecc/sw-macros/README.md b/extensions/ecc/sw-macros/README.md index 71f8d553f4..091fcd20f5 100644 --- a/extensions/ecc/sw-macros/README.md +++ b/extensions/ecc/sw-macros/README.md @@ -28,7 +28,7 @@ openvm_algebra_guest::moduli_macros::moduli_init! { } openvm_ecc_guest::sw_macros::sw_init! { - Secp256k1Point, + "Secp256k1Point", } */ @@ -45,7 +45,7 @@ The crate provides two macros: `sw_declare!` and `sw_init!`. The signatures are: - `sw_declare!` receives comma-separated list of moduli classes descriptions. Each description looks like `SwStruct { mod_type = ModulusName, a = a_expr, b = b_expr }`. Here `ModulusName` is the name of a struct that implements `trait IntMod` -- in particular, the ones created by `moduli_declare!` do -- and has `NUM_LIMBS` divisible by 4. Parameters `a` and `b` correspond to the coefficients of the equation defining the curve. They **must be compile-time constants**. The parameter `a` may be omitted, in which case it defaults to `0` (or, more specifically, to `::ZERO`). The parameter `b` is required. -- `sw_init!` receives comma-separated list of struct names. The struct name must exactly match the name in `sw_declare!` -- type defs are not allowed (see point 5 below). +- `sw_init!` receives comma-separated list of struct names as string literals. Each struct name must exactly match the name in `sw_declare!` -- type defs are not allowed (see point 5 below). What happens under the hood: @@ -107,7 +107,7 @@ sw_declare! { pub type Sw = Secp256k1Point; sw_init! { - Sw, + "Sw", } ``` diff --git a/extensions/ecc/sw-macros/src/lib.rs b/extensions/ecc/sw-macros/src/lib.rs index 7af9e77daf..160301ea96 100644 --- a/extensions/ecc/sw-macros/src/lib.rs +++ b/extensions/ecc/sw-macros/src/lib.rs @@ -5,7 +5,7 @@ use proc_macro::TokenStream; use quote::format_ident; use syn::{ parse::{Parse, ParseStream}, - parse_macro_input, Expr, ExprPath, Path, Token, + parse_macro_input, ExprPath, LitStr, Token, }; /// This macro generates the code to setup the elliptic curve for a given modular type. Also it @@ -28,9 +28,8 @@ pub fn sw_declare(input: TokenStream) -> TokenStream { let span = proc_macro::Span::call_site(); for item in items.into_iter() { - let struct_name = item.name.to_string(); - let struct_name = syn::Ident::new(&struct_name, span.into()); - let struct_path: syn::Path = syn::parse_quote!(#struct_name); + let struct_name_str = item.name.to_string(); + let struct_name = syn::Ident::new(&struct_name_str, span.into()); let mut intmod_type: Option = None; let mut const_a: Option = None; let mut const_b: Option = None; @@ -71,16 +70,7 @@ pub fn sw_declare(input: TokenStream) -> TokenStream { macro_rules! create_extern_func { ($name:ident) => { let $name = syn::Ident::new( - &format!( - "{}_{}", - stringify!($name), - struct_path - .segments - .iter() - .map(|x| x.ident.to_string()) - .collect::>() - .join("_") - ), + &format!("{}_{}", stringify!($name), struct_name_str), span.into(), ); }; @@ -89,13 +79,13 @@ pub fn sw_declare(input: TokenStream) -> TokenStream { create_extern_func!(sw_double_extern_func); create_extern_func!(sw_setup_extern_func); - let group_ops_mod_name = format_ident!("{}_ops", struct_name.to_string().to_lowercase()); + let group_ops_mod_name = format_ident!("{}_ops", struct_name_str.to_lowercase()); let result = TokenStream::from(quote::quote_spanned! { span.into() => extern "C" { fn #sw_add_ne_extern_func(rd: usize, rs1: usize, rs2: usize); fn #sw_double_extern_func(rd: usize, rs1: usize); - fn #sw_setup_extern_func(); + fn #sw_setup_extern_func(uninit: *mut core::ffi::c_void, p1: *const u8, p2: *const u8); } #[derive(Eq, PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)] @@ -196,8 +186,21 @@ pub fn sw_declare(input: TokenStream) -> TokenStream { #[cfg(target_os = "zkvm")] fn set_up_once() { static is_setup: ::openvm_ecc_guest::once_cell::race::OnceBool = ::openvm_ecc_guest::once_cell::race::OnceBool::new(); + is_setup.get_or_init(|| { - unsafe { #sw_setup_extern_func(); } + // p1 is (x1, y1), and x1 must be the modulus. + // y1 can be anything for SetupEcAdd, but must equal `a` for SetupEcDouble + let modulus_bytes = <::Coordinate as openvm_algebra_guest::IntMod>::MODULUS; + let mut one = [0u8; <::Coordinate as openvm_algebra_guest::IntMod>::NUM_LIMBS]; + one[0] = 1; + let curve_a_bytes = openvm_algebra_guest::IntMod::as_le_bytes(&<#struct_name as openvm_ecc_guest::weierstrass::WeierstrassPoint>::CURVE_A); + // p1 should be (p, a) + let p1 = [modulus_bytes.as_ref(), curve_a_bytes.as_ref()].concat(); + // (EcAdd only) p2 is (x2, y2), and x1 - x2 has to be non-zero to avoid division over zero in add. + let p2 = [one.as_ref(), one.as_ref()].concat(); + let mut uninit: core::mem::MaybeUninit<[Self; 2]> = core::mem::MaybeUninit::uninit(); + + unsafe { #sw_setup_extern_func(uninit.as_mut_ptr() as *mut core::ffi::c_void, p1.as_ptr(), p2.as_ptr()); } <#intmod_type as openvm_algebra_guest::IntMod>::set_up_once(); true }); @@ -410,23 +413,14 @@ pub fn sw_declare(input: TokenStream) -> TokenStream { } struct SwDefine { - items: Vec, + items: Vec, } impl Parse for SwDefine { fn parse(input: ParseStream) -> syn::Result { - let items = input.parse_terminated(::parse, Token![,])?; + let items = input.parse_terminated(::parse, Token![,])?; Ok(Self { - items: items - .into_iter() - .map(|e| { - if let Expr::Path(p) = e { - p.path - } else { - panic!("expected path"); - } - }) - .collect(), + items: items.into_iter().map(|e| e.value()).collect(), }) } } @@ -439,19 +433,15 @@ pub fn sw_init(input: TokenStream) -> TokenStream { let span = proc_macro::Span::call_site(); - for (ec_idx, item) in items.into_iter().enumerate() { - let str_path = item - .segments - .iter() - .map(|x| x.ident.to_string()) - .collect::>() - .join("_"); + for (ec_idx, struct_id) in items.into_iter().enumerate() { + // Unique identifier shared by sw_define! and sw_init! used for naming the extern funcs. + // Currently it's just the struct type name. let add_ne_extern_func = - syn::Ident::new(&format!("sw_add_ne_extern_func_{}", str_path), span.into()); + syn::Ident::new(&format!("sw_add_ne_extern_func_{}", struct_id), span.into()); let double_extern_func = - syn::Ident::new(&format!("sw_double_extern_func_{}", str_path), span.into()); + syn::Ident::new(&format!("sw_double_extern_func_{}", struct_id), span.into()); let setup_extern_func = - syn::Ident::new(&format!("sw_setup_extern_func_{}", str_path), span.into()); + syn::Ident::new(&format!("sw_setup_extern_func_{}", struct_id), span.into()); externs.push(quote::quote_spanned! { span.into() => #[no_mangle] @@ -481,30 +471,18 @@ pub fn sw_init(input: TokenStream) -> TokenStream { } #[no_mangle] - extern "C" fn #setup_extern_func() { + extern "C" fn #setup_extern_func(uninit: *mut core::ffi::c_void, p1: *const u8, p2: *const u8) { #[cfg(target_os = "zkvm")] { - use super::#item; - // p1 is (x1, y1), and x1 must be the modulus. - // y1 can be anything for SetupEcAdd, but must equal `a` for SetupEcDouble - let modulus_bytes = <<#item as openvm_ecc_guest::weierstrass::WeierstrassPoint>::Coordinate as openvm_algebra_guest::IntMod>::MODULUS; - let mut one = [0u8; <<#item as openvm_ecc_guest::weierstrass::WeierstrassPoint>::Coordinate as openvm_algebra_guest::IntMod>::NUM_LIMBS]; - one[0] = 1; - let curve_a_bytes = openvm_algebra_guest::IntMod::as_le_bytes(&<#item as openvm_ecc_guest::weierstrass::WeierstrassPoint>::CURVE_A); - // p1 should be (p, a) - let p1 = [modulus_bytes.as_ref(), curve_a_bytes.as_ref()].concat(); - // (EcAdd only) p2 is (x2, y2), and x1 - x2 has to be non-zero to avoid division over zero in add. - let p2 = [one.as_ref(), one.as_ref()].concat(); - let mut uninit: core::mem::MaybeUninit<[#item; 2]> = core::mem::MaybeUninit::uninit(); openvm::platform::custom_insn_r!( opcode = ::openvm_ecc_guest::OPCODE, funct3 = ::openvm_ecc_guest::SW_FUNCT3 as usize, funct7 = ::openvm_ecc_guest::SwBaseFunct7::SwSetup as usize + #ec_idx * (::openvm_ecc_guest::SwBaseFunct7::SHORT_WEIERSTRASS_MAX_KINDS as usize), - rd = In uninit.as_mut_ptr(), - rs1 = In p1.as_ptr(), - rs2 = In p2.as_ptr() + rd = In uninit, + rs1 = In p1, + rs2 = In p2 ); openvm::platform::custom_insn_r!( opcode = ::openvm_ecc_guest::OPCODE, @@ -512,10 +490,12 @@ pub fn sw_init(input: TokenStream) -> TokenStream { funct7 = ::openvm_ecc_guest::SwBaseFunct7::SwSetup as usize + #ec_idx * (::openvm_ecc_guest::SwBaseFunct7::SHORT_WEIERSTRASS_MAX_KINDS as usize), - rd = In uninit.as_mut_ptr(), - rs1 = In p1.as_ptr(), + rd = In uninit, + rs1 = In p1, rs2 = Const "x0" // will be parsed as 0 and therefore transpiled to SETUP_EC_DOUBLE ); + + } } }); diff --git a/extensions/ecc/tests/programs/examples/invalid_setup.rs b/extensions/ecc/tests/programs/examples/invalid_setup.rs index 6ee2ba4f58..f32c553b68 100644 --- a/extensions/ecc/tests/programs/examples/invalid_setup.rs +++ b/extensions/ecc/tests/programs/examples/invalid_setup.rs @@ -14,8 +14,8 @@ openvm_algebra_moduli_macros::moduli_init! { // the order of the curves here does not match the order in supported_curves openvm_ecc_sw_macros::sw_init! { - P256Point, - Secp256k1Point, + "P256Point", + "Secp256k1Point", } openvm::entry!(main); diff --git a/extensions/ecc/tests/programs/openvm_init_decompress_k256.rs b/extensions/ecc/tests/programs/openvm_init_decompress_k256.rs index b6137ae9ee..a873a01d64 100644 --- a/extensions/ecc/tests/programs/openvm_init_decompress_k256.rs +++ b/extensions/ecc/tests/programs/openvm_init_decompress_k256.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337", "115792089237316195423570985008687907853269984665640564039457584007913129639501", "1000000007", "26959946667150639794667015087019630673557916260026308143510066298881", "26959946667150639794667015087019625940457807714424391721682722368061" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point, CurvePoint5mod8, CurvePoint1mod4 } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point", "CurvePoint5mod8", "CurvePoint1mod4" } diff --git a/extensions/ecc/tests/programs/openvm_init_ec_k256.rs b/extensions/ecc/tests/programs/openvm_init_ec_k256.rs index bec9f527e9..dc6d4917dd 100644 --- a/extensions/ecc/tests/programs/openvm_init_ec_k256.rs +++ b/extensions/ecc/tests/programs/openvm_init_ec_k256.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/extensions/ecc/tests/programs/openvm_init_ec_nonzero_a_p256.rs b/extensions/ecc/tests/programs/openvm_init_ec_nonzero_a_p256.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/extensions/ecc/tests/programs/openvm_init_ec_nonzero_a_p256.rs +++ b/extensions/ecc/tests/programs/openvm_init_ec_nonzero_a_p256.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/extensions/ecc/tests/programs/openvm_init_ec_two_curves_k256_p256.rs b/extensions/ecc/tests/programs/openvm_init_ec_two_curves_k256_p256.rs index 8689190544..d42d03051d 100644 --- a/extensions/ecc/tests/programs/openvm_init_ec_two_curves_k256_p256.rs +++ b/extensions/ecc/tests/programs/openvm_init_ec_two_curves_k256_p256.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337", "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point, P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point", "P256Point" } diff --git a/extensions/ecc/tests/programs/openvm_init_ecdsa_k256.rs b/extensions/ecc/tests/programs/openvm_init_ecdsa_k256.rs index bec9f527e9..dc6d4917dd 100644 --- a/extensions/ecc/tests/programs/openvm_init_ecdsa_k256.rs +++ b/extensions/ecc/tests/programs/openvm_init_ecdsa_k256.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/examples/add.rs b/guest-libs/k256/tests/programs/examples/add.rs index c6989f44f5..7f7a9d735f 100644 --- a/guest-libs/k256/tests/programs/examples/add.rs +++ b/guest-libs/k256/tests/programs/examples/add.rs @@ -10,7 +10,7 @@ use openvm_k256::Secp256k1Point; mod test_vectors; use test_vectors::ADD_TEST_VECTORS; -openvm::init!("openvm_init_simple.rs"); +openvm::init!("openvm_init_add.rs"); openvm::entry!(main); diff --git a/guest-libs/k256/tests/programs/examples/mul.rs b/guest-libs/k256/tests/programs/examples/mul.rs index 65cb74fb22..e15128a190 100644 --- a/guest-libs/k256/tests/programs/examples/mul.rs +++ b/guest-libs/k256/tests/programs/examples/mul.rs @@ -10,7 +10,7 @@ use openvm_k256::Secp256k1Point; mod test_vectors; use test_vectors::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}; -openvm::init!("openvm_init_simple.rs"); +openvm::init!("openvm_init_mul.rs"); openvm::entry!(main); diff --git a/guest-libs/k256/tests/programs/openvm_init_add.rs b/guest-libs/k256/tests/programs/openvm_init_add.rs index bec9f527e9..dc6d4917dd 100644 --- a/guest-libs/k256/tests/programs/openvm_init_add.rs +++ b/guest-libs/k256/tests/programs/openvm_init_add.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/openvm_init_ecdsa.rs b/guest-libs/k256/tests/programs/openvm_init_ecdsa.rs index bec9f527e9..dc6d4917dd 100644 --- a/guest-libs/k256/tests/programs/openvm_init_ecdsa.rs +++ b/guest-libs/k256/tests/programs/openvm_init_ecdsa.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/openvm_init_linear_combination.rs b/guest-libs/k256/tests/programs/openvm_init_linear_combination.rs index bec9f527e9..dc6d4917dd 100644 --- a/guest-libs/k256/tests/programs/openvm_init_linear_combination.rs +++ b/guest-libs/k256/tests/programs/openvm_init_linear_combination.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/openvm_init_mul.rs b/guest-libs/k256/tests/programs/openvm_init_mul.rs index bec9f527e9..dc6d4917dd 100644 --- a/guest-libs/k256/tests/programs/openvm_init_mul.rs +++ b/guest-libs/k256/tests/programs/openvm_init_mul.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/openvm_init_scalar_sqrt.rs b/guest-libs/k256/tests/programs/openvm_init_scalar_sqrt.rs index bec9f527e9..dc6d4917dd 100644 --- a/guest-libs/k256/tests/programs/openvm_init_scalar_sqrt.rs +++ b/guest-libs/k256/tests/programs/openvm_init_scalar_sqrt.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } +openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" } diff --git a/guest-libs/k256/tests/programs/openvm_init_simple.rs b/guest-libs/k256/tests/programs/openvm_init_simple.rs deleted file mode 100644 index bec9f527e9..0000000000 --- a/guest-libs/k256/tests/programs/openvm_init_simple.rs +++ /dev/null @@ -1,3 +0,0 @@ -// This file is automatically generated by cargo openvm. Do not rename or edit. -openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" } -openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point } diff --git a/guest-libs/p256/tests/programs/examples/add.rs b/guest-libs/p256/tests/programs/examples/add.rs index b1c4d62fb4..c21c43ab32 100644 --- a/guest-libs/p256/tests/programs/examples/add.rs +++ b/guest-libs/p256/tests/programs/examples/add.rs @@ -7,7 +7,7 @@ use openvm_p256::NistP256; #[allow(unused)] use openvm_p256::P256Point; -openvm::init!("openvm_init_simple.rs"); +openvm::init!("openvm_init_add.rs"); openvm::entry!(main); diff --git a/guest-libs/p256/tests/programs/openvm_init_add.rs b/guest-libs/p256/tests/programs/openvm_init_add.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/guest-libs/p256/tests/programs/openvm_init_add.rs +++ b/guest-libs/p256/tests/programs/openvm_init_add.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/guest-libs/p256/tests/programs/openvm_init_ecdsa.rs b/guest-libs/p256/tests/programs/openvm_init_ecdsa.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/guest-libs/p256/tests/programs/openvm_init_ecdsa.rs +++ b/guest-libs/p256/tests/programs/openvm_init_ecdsa.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/guest-libs/p256/tests/programs/openvm_init_linear_combination.rs b/guest-libs/p256/tests/programs/openvm_init_linear_combination.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/guest-libs/p256/tests/programs/openvm_init_linear_combination.rs +++ b/guest-libs/p256/tests/programs/openvm_init_linear_combination.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/guest-libs/p256/tests/programs/openvm_init_mul.rs b/guest-libs/p256/tests/programs/openvm_init_mul.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/guest-libs/p256/tests/programs/openvm_init_mul.rs +++ b/guest-libs/p256/tests/programs/openvm_init_mul.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/guest-libs/p256/tests/programs/openvm_init_scalar_sqrt.rs b/guest-libs/p256/tests/programs/openvm_init_scalar_sqrt.rs index 02f8b5c05d..a2cd709ba0 100644 --- a/guest-libs/p256/tests/programs/openvm_init_scalar_sqrt.rs +++ b/guest-libs/p256/tests/programs/openvm_init_scalar_sqrt.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } +openvm_ecc_guest::sw_macros::sw_init! { "P256Point" } diff --git a/guest-libs/p256/tests/programs/openvm_init_simple.rs b/guest-libs/p256/tests/programs/openvm_init_simple.rs deleted file mode 100644 index 02f8b5c05d..0000000000 --- a/guest-libs/p256/tests/programs/openvm_init_simple.rs +++ /dev/null @@ -1,3 +0,0 @@ -// This file is automatically generated by cargo openvm. Do not rename or edit. -openvm_algebra_guest::moduli_macros::moduli_init! { "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369" } -openvm_ecc_guest::sw_macros::sw_init! { P256Point } diff --git a/guest-libs/pairing/tests/programs/openvm_init_bls_ec_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_bls_ec_bls12_381.rs index 95a4e46fd3..e8bbe47154 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_bls_ec_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_bls_ec_bls12_381.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", "52435875175126190479447740508185965837690552500527637822603658699938581184513" } -openvm_ecc_guest::sw_macros::sw_init! { Bls12_381G1Affine } +openvm_ecc_guest::sw_macros::sw_init! { "Bls12_381G1Affine" } diff --git a/guest-libs/pairing/tests/programs/openvm_init_bls_final_exp_hint_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_bls_final_exp_hint_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_bls_final_exp_hint_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_bls_final_exp_hint_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_bn_ec_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_bn_ec_bn254.rs index 64de28e83a..e8911a04a3 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_bn_ec_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_bn_ec_bn254.rs @@ -1,3 +1,3 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583", "21888242871839275222246405745257275088548364400416034343698204186575808495617" } -openvm_ecc_guest::sw_macros::sw_init! { Bn254G1Affine } +openvm_ecc_guest::sw_macros::sw_init! { "Bn254G1Affine" } diff --git a/guest-libs/pairing/tests/programs/openvm_init_bn_final_exp_hint_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_bn_final_exp_hint_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_bn_final_exp_hint_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_bn_final_exp_hint_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_fp12_mul_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_check_fallback_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_line_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_loop_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bls12_381.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bls12_381.rs index 00181b03ef..ec5d5ed804 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bls12_381.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bls12_381.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" } -openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bls12_381Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {} diff --git a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bn254.rs b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bn254.rs index c130859ad8..1a1e1f95ea 100644 --- a/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bn254.rs +++ b/guest-libs/pairing/tests/programs/openvm_init_pairing_miller_step_bn254.rs @@ -1,4 +1,4 @@ // This file is automatically generated by cargo openvm. Do not rename or edit. openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" } -openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } } -openvm_ecc_guest::sw_macros::sw_init! { } +openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } } +openvm_ecc_guest::sw_macros::sw_init! {}