Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
96d4b77
change guest openvm to develop (#1366)
jonathanpwang Apr 4, 2025
803f740
poseidon-air: simplify horizen_round_consts impl (#1362)
tcoratger Feb 22, 2025
716468f
Added Twisted Edwards chip
Avaneesh-axiom Jan 23, 2025
6d8e6d5
renamed WeierstrassExtension to EccExtension (etc)
Avaneesh-axiom Jan 22, 2025
a5d42ae
fix linter errors and address PR comments
Avaneesh-axiom Jan 23, 2025
59253b0
cleanup TwistedEdwardsPoint trait
Avaneesh-axiom Jan 24, 2025
01316c1
fix name collisions
Avaneesh-axiom Jan 24, 2025
b5ca860
change serde serialization for CurveConfig.coeffs to tagged
Avaneesh-axiom Jan 24, 2025
75d9c02
fix typo bug
Avaneesh-axiom Jan 24, 2025
d3832d1
update setup_all_curves to setup_all_sw_curves or setup_all_te_curves
Avaneesh-axiom Jan 24, 2025
a9f1c30
Updated the OpenVM book and example code for twisted Edwards curves
Avaneesh-axiom Jan 24, 2025
27f3d4c
delete vmexe (accidentally commited)
Avaneesh-axiom Jan 24, 2025
d666018
Add Ed25519 curve to the guest library
Avaneesh-axiom Jan 24, 2025
1a9aa83
bugs
Avaneesh-axiom Jan 25, 2025
084daf9
Move IntrinsicCurve trait definition to lib.rs (since it's common to …
Avaneesh-axiom Jan 27, 2025
4933d50
Implement IntrinsicCurve trivially for ed25519
Avaneesh-axiom Jan 27, 2025
380f7d1
Update book/src/custom-extensions/ecc.md
Avaneesh-axiom Jan 28, 2025
a48b602
Remove num-bigint-dig dependancy
Avaneesh-axiom Jan 28, 2025
b0a24f3
Add decompression hints for ed25519 and rewrite curve config
Avaneesh-axiom Jan 28, 2025
fcc8bb8
Add negative of ed25519 generator
Avaneesh-axiom Jan 29, 2025
2a91eb9
Update ecc extension section in the book to match CurveConfig rewrite
Avaneesh-axiom Jan 29, 2025
64f6bcd
fix issues introduced after rebase
Avaneesh-axiom Jan 29, 2025
df3aca0
update README for ecc macros
Avaneesh-axiom Jan 29, 2025
028e5c4
rename ecc opcodes
Avaneesh-axiom Jan 29, 2025
13274f3
Update contributer docs for ecc extension
Avaneesh-axiom Jan 29, 2025
5ab2ec4
fix small bugs
Avaneesh-axiom Jan 29, 2025
bd2f957
fix messed up rebase
Avaneesh-axiom Jan 29, 2025
8842181
update Cargo.lock
Avaneesh-axiom Jan 29, 2025
7e371ef
fix linter errors
Avaneesh-axiom Jan 29, 2025
10393ae
Add CachedMulTable for preprocessed msm for twisted edwards curves
Avaneesh-axiom Jan 30, 2025
1590c05
Add hint fallback for twisted Edwards curves
Avaneesh-axiom Mar 28, 2025
171bf40
fix rebase issues
Avaneesh-axiom Mar 28, 2025
62031bf
Fixed decompression tests for twisted edwards curves
Avaneesh-axiom Mar 31, 2025
4d62231
Fix codespell error on te (twisted edwards) abbreviation
Avaneesh-axiom Mar 31, 2025
6a6b32e
Fix lint errors and typos
Avaneesh-axiom Mar 31, 2025
0d69083
Update docs
Avaneesh-axiom Mar 31, 2025
64e41c9
Remove code related to ecc phantom instructions
Avaneesh-axiom Jun 16, 2025
3d6c5f7
Add struct_name fields to curve configs
Avaneesh-axiom Jun 16, 2025
68909ce
Fix rebase issues
Avaneesh-axiom Jun 16, 2025
7aa8cbf
Add lazy setup for edwards curves
Avaneesh-axiom Jun 16, 2025
02d07b6
Delete commented code
Avaneesh-axiom Jun 16, 2025
9a69407
Add a bunch of #[inline(always)] for te curves
Avaneesh-axiom Jun 16, 2025
688d95d
Merge branch 'main' into feat/edwards-curve-support
Avaneesh-axiom Jun 16, 2025
34fbcda
Update comments on Group::is_identity impl
Avaneesh-axiom Jun 16, 2025
cf9e909
Add missing dep
Avaneesh-axiom Jun 16, 2025
e1f69d0
Fix bugs
Avaneesh-axiom Jun 16, 2025
ba8fb34
Update ecc example
Avaneesh-axiom Jun 16, 2025
9eb373c
Fix lint
Avaneesh-axiom Jun 16, 2025
652bf3c
Update ecc chip READMEs
Avaneesh-axiom Jun 16, 2025
021bb79
Fix import path bugs in pairing guest lib
Avaneesh-axiom Jun 16, 2025
39e2547
Minor change for clarity
Avaneesh-axiom Jun 16, 2025
ba2814a
Update ecc sw-macro and te-macro READMEs
Avaneesh-axiom Jun 16, 2025
d4beb7e
Fix lint
Avaneesh-axiom Jun 16, 2025
a67e46d
Merge branch 'main' into feat/edwards-curve-support
Avaneesh-axiom Jun 19, 2025
de5e835
fix: Handle decompression with x = 0 correctly
Avaneesh-axiom Jun 19, 2025
5a88dc6
Fix bad merge
Avaneesh-axiom Jun 19, 2025
cb4e446
Add #[serde(default)] to EccExtenison (allow omitting sw or te curves)
Avaneesh-axiom Jun 19, 2025
b821044
Merge branch 'main' into feat/edwards-curve-support
Avaneesh-axiom Jul 11, 2025
2e59e6f
Fix typo in ecc tests
Avaneesh-axiom Jul 11, 2025
197bb73
Merge branch 'feat/new-execution' into feat/edwards-curve-new-execution
Avaneesh-axiom Jul 11, 2025
2187ce0
fix: bug in edwards chip test setup
Avaneesh-axiom Jul 14, 2025
29c9c70
fix: lint
Avaneesh-axiom Jul 14, 2025
831d8a4
Merge branch 'feat/new-execution' into feat/edwards-curve-new-execution
Avaneesh-axiom Jul 16, 2025
9714147
Merge branch 'feat/new-execution' into feat/edwards-curve-new-execution
Avaneesh-axiom Aug 1, 2025
11d10fc
Use openvm_init
Avaneesh-axiom Aug 10, 2025
be1e5ec
fix bug: set should_finalize to true for edwards chips
Avaneesh-axiom Aug 10, 2025
24c3c36
Merge branch 'feat/ed25519' into feat/edwards-curve-new-execution
Avaneesh-axiom Aug 10, 2025
d4a9c83
Parse struct name in te_init as string
Avaneesh-axiom Jul 23, 2025
a79827d
fix lint
Avaneesh-axiom Aug 10, 2025
1849d45
fix bug: add quotes around sw_init args
Avaneesh-axiom Aug 10, 2025
55a1c2d
remove unused deps
Avaneesh-axiom Aug 10, 2025
3f0782e
Update openvm.toml format for ecc extension
Avaneesh-axiom Aug 10, 2025
16a8d32
delete debugging code
Avaneesh-axiom Aug 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ InOut
inout
LoadE
SelectE
ser
ser
te
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ members = [
"extensions/ecc/transpiler",
"extensions/ecc/guest",
"extensions/ecc/sw-macros",
"extensions/ecc/te-macros",
"extensions/ecc/tests",
"extensions/pairing/circuit",
"extensions/pairing/guest",
Expand Down Expand Up @@ -164,6 +165,7 @@ openvm-ecc-circuit = { path = "extensions/ecc/circuit", default-features = false
openvm-ecc-transpiler = { path = "extensions/ecc/transpiler", default-features = false }
openvm-ecc-guest = { path = "extensions/ecc/guest", default-features = false }
openvm-ecc-sw-macros = { path = "extensions/ecc/sw-macros", default-features = false }
openvm-ecc-te-macros = { path = "extensions/ecc/te-macros", default-features = false }
openvm-pairing-circuit = { path = "extensions/pairing/circuit", default-features = false }
openvm-pairing-transpiler = { path = "extensions/pairing/transpiler", default-features = false }
openvm-pairing-guest = { path = "extensions/pairing/guest", default-features = false }
Expand Down
12 changes: 4 additions & 8 deletions benchmarks/execute/benches/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use openvm_continuations::{
verifier::{common::types::VmVerifierPvs, leaf::types::LeafVmVerifierInput},
SC,
};
use openvm_ecc_circuit::{EccCpuProverExt, WeierstrassExtension, WeierstrassExtensionExecutor};
use openvm_ecc_circuit::{EccCpuProverExt, EccExtension, EccExtensionExecutor};
use openvm_ecc_transpiler::EccTranspilerExtension;
use openvm_keccak256_circuit::{Keccak256, Keccak256CpuProverExt, Keccak256Executor};
use openvm_keccak256_transpiler::Keccak256TranspilerExtension;
Expand Down Expand Up @@ -97,7 +97,7 @@ pub struct ExecuteConfig {
#[extension]
pub fp2: Fp2Extension,
#[extension]
pub weierstrass: WeierstrassExtension,
pub ecc: EccExtension,
#[extension(generics = true)]
pub pairing: PairingExtension,
}
Expand All @@ -121,7 +121,7 @@ impl Default for ExecuteConfig {
BN254_COMPLEX_STRUCT_NAME.to_string(),
bn_config.modulus.clone(),
)]),
weierstrass: WeierstrassExtension::new(vec![bn_config.clone()]),
ecc: EccExtension::new(vec![bn_config.clone()], vec![]),
pairing: PairingExtension::new(vec![PairingCurve::Bn254]),
}
}
Expand Down Expand Up @@ -179,11 +179,7 @@ where
inventory,
)?;
VmProverExtension::<E, _, _>::extend_prover(&AlgebraCpuProverExt, &config.fp2, inventory)?;
VmProverExtension::<E, _, _>::extend_prover(
&EccCpuProverExt,
&config.weierstrass,
inventory,
)?;
VmProverExtension::<E, _, _>::extend_prover(&EccCpuProverExt, &config.ecc, inventory)?;
VmProverExtension::<E, _, _>::extend_prover(&PairingProverExt, &config.pairing, inventory)?;
Ok(chip_complex)
}
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/guest/ecrecover/openvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ supported_moduli = [
"115792089237316195423570985008687907852837564279074904382605163141518161494337",
]

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Secp256k1Point"
modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"
scalar = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "7"
1 change: 1 addition & 0 deletions benchmarks/guest/ecrecover/openvm_init.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// 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::te_macros::te_init! { }
12 changes: 8 additions & 4 deletions benchmarks/guest/kitchen-sink/openvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,35 @@ supported_moduli = [
],
]

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Secp256k1Point"
modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"
scalar = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "7"

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "P256Point"
modulus = "115792089210356248762697446949407573530086143415290314195533631308867097853951"
scalar = "115792089210356248762697446949407573529996955224135760342422259061068512044369"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "115792089210356248762697446949407573530086143415290314195533631308867097853948"
b = "41058363725152142129326129780047268409114441015993725554835256314039467401291"

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Bn254G1Affine"
modulus = "21888242871839275222246405745257275088696311157297823662689037894645226208583"
scalar = "21888242871839275222246405745257275088548364400416034343698204186575808495617"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "3"

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Bls12_381G1Affine"
modulus = "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787"
scalar = "52435875175126190479447740508185965837690552500527637822603658699938581184513"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "4"

Expand Down
3 changes: 2 additions & 1 deletion benchmarks/guest/pairing/openvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ supported_moduli = [
supported_curves = ["Bn254"]

# bn254 (alt bn128)
[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Bn254G1Affine"
modulus = "21888242871839275222246405745257275088696311157297823662689037894645226208583"
scalar = "21888242871839275222246405745257275088548364400416034343698204186575808495617"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "3"
31 changes: 23 additions & 8 deletions book/src/custom-extensions/ecc.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ Developers can enable arbitrary Weierstrass curves by configuring this extension
- `WeierstrassPoint` trait:
It represents an affine point on a Weierstrass elliptic curve and it extends `Group`.

- `Coordinate` type is the type of the coordinates of the point, and it implements `IntMod`.
- `x()`, `y()` are used to get the affine coordinates
- `Coordinate` type is the type of the coordinates of the point, and it implements `Field`.
- `x()`, `y()` are used to get the affine coordinates.
- `from_xy` is a constructor for the point, which checks if the point is either identity or on the affine curve.
- The point supports elliptic curve operations through intrinsic functions `add_ne_nonidentity` and `double_nonidentity`.
- `decompress`: Sometimes an elliptic curve point is compressed and represented by its `x` coordinate and the odd/even parity of the `y` coordinate. `decompress` is used to decompress the point back to `(x, y)`.

- `TwistedEdwardsPoint` trait:
It represents an affine point on a twisted Edwards elliptic curve and it extends `Group`.

- `Coordinate` type is the type of the coordinates of the point, and it implements `Field`.
- `x()`, `y()` are used to get the affine coordinates.
- `from_xy` is a constructor for the point, which checks if the point is on the affine curve.
- The point supports elliptic curve addition through the `add_impl` method.

- `msm`: for multi-scalar multiplication.

- `ecdsa`: for doing ECDSA signature verification and public key recovery from signature.
Expand All @@ -31,17 +39,20 @@ Developers can enable arbitrary Weierstrass curves by configuring this extension

For elliptic curve cryptography, the `openvm-ecc-guest` crate provides macros similar to those in [`openvm-algebra-guest`](./algebra.md):

1. **Declare**: Use `sw_declare!` to define elliptic curves over the previously declared moduli. For example:
1. **Declare**: Use `sw_declare!` or `te_declare!` to define short Weierstrass or twisted Edwards elliptic curves, respectively, over the previously declared moduli. For example:

```rust
sw_declare! {
Bls12_381G1Affine { mod_type = Bls12_381Fp, b = BLS12_381_B },
P256Affine { mod_type = P256Coord, a = P256_A, b = P256_B },
}
te_declare! {
Edwards25519 { mod_type = Edwards25519Coord, a = CURVE_A, d = CURVE_D },
}
```
This creates `Bls12_381G1Affine` and `P256Affine` structs which implement the `Group` and `WeierstrassPoint` traits, and the `Edwards25519` struct which implements the `Group` and `TwistedEdwardsPoint` traits. The underlying memory layout of the structs uses the memory layout of the `Bls12_381Fp`, `P256Coord`, and `Edwards25519Coord` structs, respectively.

Each declared curve must specify the `mod_type` (implementing `IntMod`) and a constant `b` for the Weierstrass curve equation \\(y^2 = x^3 + ax + b\\). `a` is optional and defaults to 0 for short Weierstrass curves.
This creates `Bls12_381G1Affine` and `P256Affine` structs which implement the `Group` and `WeierstrassPoint` traits. The underlying memory layout of the structs uses the memory layout of the `Bls12_381Fp` and `P256Coord` structs, respectively.
Each declared curve must specify the `mod_type` (implementing `Field`) and a constant `b` for the Weierstrass curve equation \\(y^2 = x^3 + ax + b\\) or `a` and `d` for the twisted Edwards curve equation \\(ax^2 + y^2 = 1 + dx^2y^2\\). For short Weierstrass curves, `a` is optional and defaults to 0.

2. **Init**: Called once, the [`openvm::init!` macro](./overview.md#automating-the-init-step) produces a call to `sw_init!` that enumerates these curves and allows the compiler to produce optimized instructions:

Expand All @@ -51,17 +62,21 @@ openvm::init!();
sw_init! {
"Bls12_381G1Affine", "P256Affine",
}
te_init! {
Edwards25519,
}
*/
```

**Summary**:

- `sw_declare!`: Declares elliptic curve structures.
- `sw_declare!`: Declares short Weierstrass elliptic curve structures.
- `te_declare!`: Declares twisted Edwards elliptic curve structures.
- `init!`: Initializes them once, linking them to the underlying moduli.

To use elliptic curve operations on a struct defined with `sw_declare!`, it is expected that the struct for the curve's coordinate field was defined using `moduli_declare!`. In particular, the coordinate field needs to be initialized and set up as described in the [algebra extension](./algebra.md) chapter.
To use elliptic curve operations on a struct defined with `sw_declare!` or `te_declare!`, it is expected that the struct for the curve's coordinate field was defined using `moduli_declare!`. In particular, the coordinate field needs to be initialized and set up as described in the [algebra extension](./algebra.md) chapter.

For the basic operations provided by the `WeierstrassPoint` trait, the scalar field is not needed. For the ECDSA functions in the `ecdsa` module, the scalar field must also be declared, initialized, and set up.
For the basic operations provided by the `WeierstrassPoint` or `TwistedEdwardsPoint` traits, the scalar field is not needed. For the ECDSA functions in the `ecdsa` module, the scalar field must also be declared, initialized, and set up.

## ECDSA

Expand Down
29 changes: 24 additions & 5 deletions book/src/custom-extensions/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,39 @@ supported_moduli = ["<modulus_1>", "<modulus_2>", ...]
[app_vm_config.pairing]
supported_curves = ["Bls12_381", "Bn254"]

[[app_vm_config.ecc.supported_curves]]
struct_name = "<curve_name_1>"
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "<sw_curve_name_1>"
modulus = "<modulus_1>"
scalar = "<scalar_1>"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "<a_1>"
b = "<b_1>"

[[app_vm_config.ecc.supported_curves]]
struct_name = "<curve_name_2>"
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "<sw_curve_name_2>"
modulus = "<modulus_2>"
scalar = "<scalar_2>"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "<a_2>"
b = "<b_2>"

[[app_vm_config.ecc.supported_te_curves]]
struct_name = "<te_curve_name_1>"
modulus = "<modulus_1>"
scalar = "<scalar_1>"
[app_vm_config.ecc.supported_te_curves.coeffs]
a = "<a_1>"
d = "<d_1>"

[[app_vm_config.ecc.supported_te_curves]]
struct_name = "<te_curve_name_2>"
modulus = "<modulus_2>"
scalar = "<scalar_2>"
[app_vm_config.ecc.supported_te_curves.coeffs]
a = "<a_2>"
d = "<d_2>"
`
```

`rv32i`, `io`, and `rv32m` need to be always included if you make an `openvm.toml` file while the rest are optional and should be included if you want to use the corresponding extension.
All moduli and scalars must be provided in decimal format. Currently `pairing` supports only pre-defined `Bls12_381` and `Bn254` curves. To add more `ecc` curves you need to add more `[[app_vm_config.ecc.supported_curves]]` entries.
All moduli and scalars must be provided in decimal format. Currently `pairing` supports only pre-defined `Bls12_381` and `Bn254` curves. To add more `ecc` curves you need to add more `[[app_vm_config.ecc.supported_sw_curves]]` or `[[app_vm_config.ecc.supported_te_curves]]` entries.
7 changes: 4 additions & 3 deletions book/src/guest-libs/k256.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ For the guest program to build successfully, all used moduli and curves must be
[app_vm_config.modular]
supported_moduli = ["115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337"]

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "Secp256k1Point"
modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"
scalar = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "0"
b = "7"
```

The `supported_moduli` parameter is a list of moduli that the guest program will use. As mentioned in the [algebra extension](../custom-extensions/algebra.md) chapter, the order of moduli in `[app_vm_config.modular]` must match the order in the `moduli_init!` macro.

The `ecc.supported_curves` parameter is a list of supported curves that the guest program will use. They must be provided in decimal format in the `.toml` file. For multiple curves create multiple `[[app_vm_config.ecc.supported_curves]]` sections. The order of curves in `[[app_vm_config.ecc.supported_curves]]` must match the order in the `sw_init!` macro.
Also, the `struct_name` field must be the name of the elliptic curve struct created by `sw_declare!`.
The `ecc.supported_curves` parameter is a list of supported curves that the guest program will use. They must be provided in decimal format in the `.toml` file. For multiple curves create multiple `[[app_vm_config.ecc.supported_sw_curves]]`/`[[app_vm_config.ecc.supported_te_curves]]` sections. The order of curves in `[[app_vm_config.ecc.supported_sw/te_curves]]` must match the order in the `sw_init!`/`te_init!` macros respectively.
Also, the `struct_name` field must be the name of the elliptic curve struct created by `sw_declare!`/`te_declare!`.
In this example, the `Secp256k1Point` struct is created in `openvm_ecc_guest::k256`.

7 changes: 4 additions & 3 deletions book/src/guest-libs/p256.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ For the guest program to build successfully, all used moduli and curves must be
[app_vm_config.modular]
supported_moduli = ["115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369"]

[[app_vm_config.ecc.supported_curves]]
[[app_vm_config.ecc.supported_sw_curves]]
struct_name = "P256Point"
modulus = "115792089210356248762697446949407573530086143415290314195533631308867097853951"
scalar = "115792089210356248762697446949407573529996955224135760342422259061068512044369"
[app_vm_config.ecc.supported_sw_curves.coeffs]
a = "115792089210356248762697446949407573530086143415290314195533631308867097853948"
b = "41058363725152142129326129780047268409114441015993725554835256314039467401291"
```

The `supported_moduli` parameter is a list of moduli that the guest program will use. As mentioned in the [algebra extension](../custom-extensions/algebra.md) chapter, the order of moduli in `[app_vm_config.modular]` must match the order in the `moduli_init!` macro.

The `ecc.supported_curves` parameter is a list of supported curves that the guest program will use. They must be provided in decimal format in the `.toml` file. For multiple curves create multiple `[[app_vm_config.ecc.supported_curves]]` sections. The order of curves in `[[app_vm_config.ecc.supported_curves]]` must match the order in the `sw_init!` macro.
Also, the `struct_name` field must be the name of the elliptic curve struct created by `sw_declare!`.
The `ecc.supported_curves` parameter is a list of supported curves that the guest program will use. They must be provided in decimal format in the `.toml` file. For multiple curves create multiple `[[app_vm_config.ecc.supported_sw_curves]]`/`[[app_vm_config.ecc.supported_te_curves]]` sections. The order of curves in `[[app_vm_config.ecc.supported_sw_curves]]`/`[[app_vm_config.ecc.supported_te_curves]]` must match the order in the `sw_init!`/`te_init!` macros respectively.
Also, the `struct_name` field must be the name of the elliptic curve struct created by `sw_declare!`/`te_declare!`.
1 change: 1 addition & 0 deletions crates/circuits/mod-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ impl<AB: InteractionBuilder> SubAir<AB> for FieldExpr {
for i in 0..self.constraints.len() {
let expr = self.constraints[i]
.evaluate_overflow_expr::<AB>(&inputs, &vars, &constants, &flags);

self.check_carry_mod_to_zero.eval(
builder,
(
Expand Down
16 changes: 4 additions & 12 deletions crates/circuits/poseidon2-air/src/babybear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(crate) fn horizen_to_p3_babybear(horizen_babybear: HorizenBabyBear) -> BabyB
}

pub(crate) fn horizen_round_consts() -> Poseidon2Constants<BabyBear> {
let p3_rc16: Vec<Vec<BabyBear>> = RC16
let p3_rc16: Vec<Vec<_>> = RC16
.iter()
.map(|round| {
round
Expand All @@ -29,18 +29,10 @@ pub(crate) fn horizen_round_consts() -> Poseidon2Constants<BabyBear> {
.collect();
let p_end = BABY_BEAR_POSEIDON2_HALF_FULL_ROUNDS + BABY_BEAR_POSEIDON2_PARTIAL_ROUNDS;

let beginning_full_round_constants: [[BabyBear; POSEIDON2_WIDTH];
BABY_BEAR_POSEIDON2_HALF_FULL_ROUNDS] = from_fn(|i| p3_rc16[i].clone().try_into().unwrap());
let partial_round_constants: [BabyBear; BABY_BEAR_POSEIDON2_PARTIAL_ROUNDS] =
from_fn(|i| p3_rc16[i + BABY_BEAR_POSEIDON2_HALF_FULL_ROUNDS][0]);
let ending_full_round_constants: [[BabyBear; POSEIDON2_WIDTH];
BABY_BEAR_POSEIDON2_HALF_FULL_ROUNDS] =
from_fn(|i| p3_rc16[i + p_end].clone().try_into().unwrap());

Poseidon2Constants {
beginning_full_round_constants,
partial_round_constants,
ending_full_round_constants,
beginning_full_round_constants: from_fn(|i| p3_rc16[i].clone().try_into().unwrap()),
partial_round_constants: from_fn(|i| p3_rc16[i + BABY_BEAR_POSEIDON2_HALF_FULL_ROUNDS][0]),
ending_full_round_constants: from_fn(|i| p3_rc16[i + p_end].clone().try_into().unwrap()),
}
}

Expand Down
Loading
Loading