Skip to content

Commit 688d95d

Browse files
Merge branch 'main' into feat/edwards-curve-support
2 parents 9a69407 + 63d21e8 commit 688d95d

File tree

42 files changed

+424
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+424
-196
lines changed

.github/workflows/benchmarks.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
else
8383
RUN_E2E=${{ github.event.inputs.run-benchmark-e2e || 'false' }}
8484
fi
85+
if [[ "$RUN_E2E" == "true" ]]; then
86+
FEATURE_FLAGS="evm,${FEATURE_FLAGS}"
87+
fi
8588
if [[ "${{ github.event.inputs.aggregation }}" == "true" ]]; then
8689
FEATURE_FLAGS="aggregation,${FEATURE_FLAGS}"
8790
fi

.github/workflows/sdk.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,4 @@ jobs:
9696
working-directory: crates/sdk
9797
run: |
9898
export RUST_BACKTRACE=1
99-
cargo nextest run --cargo-profile=fast --test-threads=2 --features parallel
100-
99+
cargo nextest run --cargo-profile=fast --test-threads=2 --features parallel,evm-verify

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSIONING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# OpenVM Versioning
2+
3+
OpenVM follows the naming convention of [semantic versioning](https://semver.org/) (semver) but with different principles:
4+
5+
* `major`: Only changes upon significant proof system or ISA updates
6+
* `minor`: Breaking changes where the vkey (`MultiStarkVerifyingKey`) changes
7+
* `patch`: Backward-compatible changes that preserve vkey compatibility
8+
9+
Due to the security critical nature of the OpenVM codebase, we do _not_ follow semver precisely in the sense that breaking code-level API changes will not always result in a major version upgrade. However we follow the principles of semver where we treat the true API of the codebase to be the verification of the proofs generated by the OpenVM framework.
10+
11+
## Versioning Principles
12+
13+
The core principle of OpenVM versioning is: **"Patch upgrade should be backward compatible"**.
14+
15+
This means if we upgrade from v1.0.0 to v1.0.1, the old verifier of v1.0.0 should be able to verify the new proof generated by v1.0.1. **Crucially, this means the vkey (`MultiStarkVerifyingKey`) does not change across patch versions.**
16+
17+
## Backward Compatibility Guarantees
18+
19+
The following properties must remain fixed across patch versions (changing these requires a minor version upgrade):
20+
21+
1. **vkey (`MultiStarkVerifyingKey` struct)**
22+
- This ensures that a patch-upgraded prover (v1.x.y) can generate proofs that the original verifier (v1.x.0) can verify
23+
24+
2. **Commit structures**
25+
- `app_vm_commit`, `leaf_vm_commit`, `internal_vm_commit`
26+
- This includes both the VM itself and the serialization (how the commit is computed)
27+
28+
3. **`VmConfig` format**
29+
30+
4. **Build toolchain**
31+
- RISC-V custom instructions
32+
- Transpiler
33+
- ISA
34+
- And thus the resulting `VmExe`
35+
36+
5. **Output of the `prove` command (CLI+SDK)**
37+
- The proof format (struct itself and the content)
38+
39+
## Exceptions
40+
41+
Changes that are purely additive without modifying existing objects are exceptions to the above rules and can be included in patch versions. Examples include:
42+
43+
- Adding a new instruction
44+
- Adding a new prove type (STARK)
45+
- Adding a new extension (new `StarkVerifyingKey` for a new circuit)
46+
47+
While rare and ideally avoided, we reserve the option to change formatting of certain outputs or structs (e.g., `VmConfig` or `VmExe`) in a patch version if the change is purely cosmetic and a migration tool is provided to easily convert from the old format to the new format.
48+
49+
## Patch-level Changes
50+
51+
Other changes that aren't security critical and don't modify any of the above components can be included in patch upgrades:
52+
53+
- Prover improvements
54+
- VirtualMachine optimizations
55+
- Executor enhancements
56+
- SDK and CLI updates
57+
- Guest library changes

audits/v1-internal/circuit-primitives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ Two cases to consider:
535535

536536
The SubAir doesn't explicitly enforce that only the first differing index has a non-zero `diff_inv_marker` value, or that it contains the exact inverse. It only requires that the weighted sum of differences equals 1 when arrays differ. However, the trace generation sets these values correctly for efficiency.
537537

538-
#### 3.2.6 [is_less_than](https://github.com/openvm-org/openvm/blob/main/crates/circuits/primitives/is_less_than.rs)
538+
#### 3.2.6 [is_less_than](https://github.com/openvm-org/openvm/blob/main/crates/circuits/primitives/src/is_less_than)
539539
Less than comparison for outputting a boolean indicating `x` < `y`
540540

541541
**Assumptions:**

audits/v1-internal/native-compiler.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Commit: 336f1a475e5aa3513c4c5a266399f4128c119bba
1414
**Severity:** Medium
1515
**Context:** https://github.com/openvm-org/openvm/blob/336f1a475e5aa3513c4c5a266399f4128c119bba/extensions/native/compiler/src/asm/compiler.rs#L598
1616

17-
**Description:** When allocating memory, `HEAP_PTR` and `A0` could overflow as a field element. This could lead
18-
an exploit when the size of memory allocation is based on inputs.
17+
**Description:** When allocating memory, `HEAP_PTR` and `A0` could overflow as a field element. This could lead
18+
an exploit when the size of memory allocation is based on inputs.
1919

20-
The exploit could change `HEAP_PTR` to an arbitrary address, which could point to a loop variable or an
21-
end condition. The the exploit could write an arbitrary value into the address and takes control of the
20+
The exploit could change `HEAP_PTR` to an arbitrary address, which could point to a loop variable or an
21+
end condition. The the exploit could write an arbitrary value into the address and takes control of the
2222
control flow.
2323

2424
**Proof of concept:** N/A
@@ -38,8 +38,8 @@ save columns, `RANGE_CHECK` is put into the existing `JalChip`.
3838
**Severity:** High
3939
**Context:** https://github.com/openvm-org/openvm/blob/336f1a475e5aa3513c4c5a266399f4128c119bba/extensions/native/compiler/src/conversion/mod.rs#L274
4040

41-
**Description:**
42-
ASM compiler compiles `Assert*` DSL instructions into a conditional jump + a ASM instruction `Trap`, which only results a phantom instruction. The expolit can generate a valid execution trace which ignores all assertions in the program.
41+
**Description:**
42+
ASM compiler compiles `Assert*` DSL instructions into a conditional jump + a ASM instruction `Trap`, which only results a phantom instruction. The exploit can generate a valid execution trace which ignores all assertions in the program.
4343

4444
**Proof of concept:** N/A
4545

@@ -54,11 +54,11 @@ assertions anymore.
5454
**Severity:** Medium
5555
**Context:**: https://github.com/openvm-org/openvm/blob/336f1a475e5aa3513c4c5a266399f4128c119bba/extensions/native/compiler/src/constraints/halo2/compiler.rs#L317
5656

57-
**Description:**
58-
The order of `Bn254Fr` is less than `2^254`. A number of 254 bits could overflow. Therefore the bit decomposition
57+
**Description:**
58+
The order of `Bn254Fr` is less than `2^254`. A number of 254 bits could overflow. Therefore the bit decomposition
5959
of a specific `Bn254Fr` doesn't guarantee an unique representation.
6060

61-
**Recommendation:**
61+
**Recommendation:**
6262
Constraints the bit representation is not in `[p, 2^254)` where `p` is the order of `Bn254Fr`.
6363

6464
**Resolution:** https://github.com/openvm-org/openvm/commit/bff6d573ce7e5304fed5a9e40df9a76647be42ea
@@ -67,15 +67,15 @@ Constraints the bit representation is not in `[p, 2^254)` where `p` is the order
6767
**Severity:** Low
6868
**Context:**: https://github.com/openvm-org/openvm/blob/336f1a475e5aa3513c4c5a266399f4128c119bba/extensions/native/compiler/src/asm/compiler.rs#L40
6969

70-
**Description:**
70+
**Description:**
7171
In compiled programs, frame pointers could be negative, which means stackoverflow. Usually compilers support
7272
recursion so they cannot check stackoverflow at compile time. But ASM compiler can determine all frame pointers
7373
at compile time so it has the ability to check.
7474

7575
This exploit can happen only when users create lots of stack variables and never access stack variables in
7676
out of bound addresses(>=`2^29`). So it's very unlikely unless users are malicious.
7777

78-
**Recommendation:**
78+
**Recommendation:**
7979
Assert frame pointers cannot be negative.
8080

8181
**Resolution:** https://github.com/openvm-org/openvm/pull/1416
@@ -98,7 +98,7 @@ Most DSL instructions are trivially converted into the corresponding ASM instruc
9898
Notably, immediate `Ext` DSL instructions result 5 ASM instruction - the compiler needs to write the immediate `Ext` as 4 `Felt`s first.
9999

100100
### 3.2 Analysis of Halo2 Compiler
101-
The Halo2 compiler in `src/asm` converts DSL instructions into Halo2 circuit constraints. The Halo2 compiler
101+
The Halo2 compiler in `src/asm` converts DSL instructions into Halo2 circuit constraints. The Halo2 compiler
102102
doesn't support jump and heap allocation. So it's simpler than the ASM compiler. Almost all DSL instructions
103103
are simply converted into the corresponding Halo2 circuit constraints.
104104

audits/v1-internal/poseidon2-air.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Author: https://github.com/MonkeyKing-1
66

77
Scope: Plonky3 poseidon2 and poseidon2 air
88

9-
Understanding how the Plonky3 posiedon2 air works, make sure it is sound.
9+
Understanding how the Plonky3 poseidon2 air works, make sure it is sound.
1010

1111
## 2. Findings
1212

@@ -40,7 +40,7 @@ The external linear layer takes the current state and does some case work based
4040

4141
- Length 2: compute sum of elements of state and add to each element of state.
4242
- Length 3: compute sum of elements of state and add to each element of state.
43-
- Length is multiple of 4: Multiply every four elements by M, giving a new state. Compute the sum of elements with indices that are 0 mod 4, 1 mod 4, etc, computing four sums. Then add these sums to the elements that contributed to them. In other words, perform this multiplication:
43+
- Length is multiple of 4: Multiply every four elements by M, giving a new state. Compute the sum of elements with indices that are 0 mod 4, 1 mod 4, etc, computing four sums. Then add these sums to the elements that contributed to them. In other words, perform this multiplication:
4444
`[[2M M ... M], [M 2M ... M], ..., [M M ... 2M]]`.
4545

4646
### Internal Linear Layer

benchmarks/guest/ecrecover/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ openvm = { path = "../../../crates/toolchain/openvm", features = ["std"] }
99
openvm-algebra-guest = { path = "../../../extensions/algebra/guest", default-features = false }
1010
openvm-ecc-guest = { path = "../../../extensions/ecc/guest", default-features = false }
1111
openvm-keccak256 = { path = "../../../guest-libs/keccak256/", default-features = false }
12-
revm-precompile = { version = "21.0.0", default-features = false }
12+
revm-precompile = { git = "https://github.com/bluealloy/revm.git", tag = "v75", default-features = false }
1313
# IMPORTANT: must be same version as used by revm; revm does not re-export this feature so we enable it here
14-
alloy-primitives = { version = "1.0", default-features = false, features = [
14+
alloy-primitives = { version = "1.2.0", default-features = false, features = [
1515
"native-keccak",
1616
] }
1717
k256 = { version = "0.13.3", default-features = false }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[app_vm_config.rv32i]
2+
[app_vm_config.rv32m]
3+
[app_vm_config.io]
4+
[app_vm_config.keccak]
5+
6+
[app_vm_config.modular]
7+
supported_moduli = [
8+
"115792089237316195423570985008687907853269984665640564039457584007908834671663",
9+
"115792089237316195423570985008687907852837564279074904382605163141518161494337",
10+
]
11+
12+
[[app_vm_config.ecc.supported_curves]]
13+
struct_name = "Secp256k1Point"
14+
modulus = "115792089237316195423570985008687907853269984665640564039457584007908834671663"
15+
scalar = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
16+
a = "0"
17+
b = "7"

benchmarks/guest/kitchen-sink/Cargo.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ openvm = { path = "../../../crates/toolchain/openvm", default-features = false,
99
"std",
1010
] }
1111
openvm-algebra-guest = { path = "../../../extensions/algebra/guest", default-features = false }
12-
openvm-ecc-guest = { path = "../../../extensions/ecc/guest", default-features = false, features = [
13-
"k256",
14-
"p256",
15-
] }
16-
openvm-pairing-guest = { path = "../../../extensions/pairing/guest", default-features = false, features = [
12+
openvm-ecc-guest = { path = "../../../extensions/ecc/guest", default-features = false }
13+
openvm-pairing = { path = "../../../guest-libs/pairing/", features = [
1714
"bn254",
1815
"bls12_381",
1916
] }
20-
openvm-pairing = { path = "../../../guest-libs/pairing/", features = ["bn254", "bls12_381"] }
2117
openvm-keccak256 = { path = "../../../guest-libs/keccak256/", default-features = false }
2218
openvm-sha2 = { path = "../../../guest-libs/sha2/", default-features = false }
23-
openvm-ruint = { path = "../../../guest-libs/ruint/", default-features = false }
19+
openvm-k256 = { path = "../../../guest-libs/k256/", package = "k256" }
20+
openvm-p256 = { path = "../../../guest-libs/p256/", package = "p256" }
21+
openvm-ruint = { path = "../../../guest-libs/ruint/", package = "ruint", default-features = false }
2422
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
2523
serde = "1.0"
2624

0 commit comments

Comments
 (0)