sw_declare

Macro sw_declare 

Source
sw_declare!() { /* proc-macro */ }
Expand description

This macro generates the code to setup the elliptic curve for a given modular type. Also it places the curve parameters into a special static variable to be later extracted from the ELF and used by the VM. Usage:

sw_declare! {
    Secp256k1Point { mod_type = Secp256k1Coord, b = CURVE_B },
}

This creates a struct Secp256k1Point representing an affine point on the short Weierstrass curve y^2 = x^3 + a*x + b with coordinate type mod_type (a type generated by moduli_declare!). The curve coefficients a (optional, defaults to zero) and b are constants of the coordinate type.

The generated point type stores raw affine coordinates. Deserializing these points does not check that they are on the curve. Validate points from untrusted input before using group operations, scalar multiplication, or MSM.

For this macro to work, you must import the elliptic_curve crate and the openvm_ecc_guest crate.