Skip to content

Commit c04cde9

Browse files
authored
Oh updated wrapper (#8)
1 parent 9875a1f commit c04cde9

Some content is hidden

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

45 files changed

+284059
-294033
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,49 @@ jobs:
2222
run: cargo build --verbose
2323
- name: tests
2424
# We need to increase the stack size for the tests (due to quotient computation)
25-
run: RUST_MIN_STACK=67108864 cargo test --release -- --nocapture --test-threads=1
25+
run: RUST_MIN_STACK=67108864 cargo test all_layers_full_test --release -- --nocapture
26+
27+
mersenne_tests:
28+
name: mersenne_tests
29+
runs-on: [matterlabs-ci-runner-c3d]
30+
steps:
31+
- uses: actions/checkout@v3
32+
- uses: actions-rust-lang/setup-rust-toolchain@v1
33+
with:
34+
rustflags: ""
35+
- name: Setup
36+
run: |
37+
rustup set profile minimal
38+
git config --global --add url."https://${{ secrets.ZKSYNC_ADMIN_BOT_ORG_REPO_WRITE }}:[email protected]/".insteadOf https://github.com/
39+
- name: Compile
40+
working-directory: ./circuit_mersenne_field
41+
run: cargo build --verbose
42+
- name: tests
43+
working-directory: ./circuit_mersenne_field
44+
run: cargo test --release -- --nocapture --test-threads=1
45+
46+
wrapper_generated:
47+
name: wrapper_generated
48+
runs-on: [matterlabs-ci-runner-c3d]
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: actions-rust-lang/setup-rust-toolchain@v1
52+
with:
53+
rustflags: ""
54+
- name: Setup
55+
run: |
56+
rustup set profile default
57+
git config --global --add url."https://${{ secrets.ZKSYNC_ADMIN_BOT_ORG_REPO_WRITE }}:[email protected]/".insteadOf https://github.com/
58+
- name: Regenerate wrapper
59+
working-directory: ./wrapper_generator
60+
run: cargo run --release
61+
- name: Check if anything has changed
62+
run: |
63+
MODIFIED_FILES=$(git status --porcelain)
64+
if [ -n "$MODIFIED_FILES" ]; then
65+
echo "The following files were modified - did you run wrapper_generator? "
66+
echo "$MODIFIED_FILES"
67+
exit 1
68+
else
69+
echo "No files were modified."
70+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/target
22
Cargo.lock
33
wrapper_generator/target
4+
circuit_mersenne_field/target

Cargo.toml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,23 @@ name = "cli"
1313
path = "src/main.rs"
1414

1515
[dependencies]
16-
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "oh_mersenne_field" }
16+
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "mmzk_0418_without_field" }
1717
# boojum = { path = "../zksync-crypto/crates/boojum"}
18-
bellman = { git = "https://github.com/matter-labs/zksync-crypto.git", package="zksync_bellman", branch = "oh_mersenne_field" }
19-
rescue_poseidon = { git = "https://github.com/matter-labs/zksync-crypto.git", package="rescue_poseidon", branch = "oh_mersenne_field" }
18+
bellman = { git = "https://github.com/matter-labs/zksync-crypto.git", package="zksync_bellman", branch = "mmzk_0418_without_field" }
19+
# bellman = { path = "../zksync-crypto/crates/bellman", package="zksync_bellman"}
20+
rescue_poseidon = { git = "https://github.com/matter-labs/zksync-crypto.git", package="rescue_poseidon", branch = "mmzk_0418_without_field" }
2021
# rescue_poseidon = { path = "../zksync-crypto/crates/rescue-poseidon"}
21-
snark_wrapper = { git = "https://github.com/matter-labs/zksync-crypto.git", package="snark_wrapper", branch = "oh_mersenne_field" }
22+
snark_wrapper = { git = "https://github.com/matter-labs/zksync-crypto.git", package="snark_wrapper", branch = "mmzk_0418_without_field" }
2223
# snark_wrapper = { path = "../zksync-crypto/crates/snark-wrapper"}
23-
risc_verifier = {git="https://github.com/matter-labs/air_compiler.git", package="reduced_machine_for_wrapper_verifier", features=["proof_utils"], branch="oh_for_zkos_wrapper"}
24-
# risc_verifier = {path="../air_compiler/circuit_defs/reduced_machine_for_wrapper/verifier", package="reduced_machine_for_wrapper_verifier", features=["proof_utils"]}
24+
risc_verifier = {git="https://github.com/matter-labs/air_compiler.git", package="final_reduced_risc_v_machine_verifier", features=["proof_utils"], branch="oh_binaries_updated"}
25+
# risc_verifier = {path="../air_compiler/circuit_defs/final_reduced_risc_v_machine/verifier", package="final_reduced_risc_v_machine_verifier", features=["proof_utils"]}
26+
execution_utils = {git="https://github.com/matter-labs/air_compiler.git", package="execution_utils", branch="oh_binaries_updated"}
27+
# execution_utils = {path="../air_compiler/execution_utils"}
28+
circuit_mersenne_field = {path="circuit_mersenne_field"}
2529
serde_json = { version = "*" }
2630
serde = { version = "1", default-features = false, features = ["derive", "alloc"]}
2731
clap = { version = "4.5.21", features = ["derive"] }
2832

2933
[dev-dependencies]
3034
rand = "0.8.4"
3135
hex = "0.4.3"
32-
#zkos_verifier_worker = { path = "../air_compiler/worker", package="worker" }

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ Library for verifying zkos with boojum
33

44
It takes the zkos proof (in json format), and returns the boojum proof.
55

6-
Currently it also requires you to provide the file with final register inputs.
7-
86
You can use it as a library, or as a cli tool:
97

108
```
11-
cargo run --release -- --input testing_data/risc_proof --registers-input testing_data/register_final_values --output tmp.json
9+
cargo run --release -- --input testing_data/risc_proof --output-dir tmp.json
1210
```

circuit_mersenne_field/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "circuit_mersenne_field"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "mmzk_0418_without_field" }
8+
# boojum = { path = "../../zksync-crypto/crates/boojum"}
9+
mersenne_field = {git="https://github.com/matter-labs/air_compiler.git", package="field", branch="oh_binaries_updated"}
10+
# mersenne_field = {path="../../air_compiler/field", package="field"}
11+
rand = "0.8"
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
use super::*;
2+
3+
pub trait CircuitFieldExpression<F: SmallField, BaseField> {
4+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &BaseField) -> Self;
5+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &BaseField) -> Self;
6+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &BaseField) -> Self;
7+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
8+
&self,
9+
cs: &mut CS,
10+
mul_base: &BaseField,
11+
add: &Self,
12+
) -> Self;
13+
}
14+
15+
impl<F: SmallField> CircuitFieldExpression<F, MersenneField<F>> for MersenneField<F> {
16+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
17+
self.add(cs, base)
18+
}
19+
20+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
21+
self.sub(cs, base)
22+
}
23+
24+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
25+
self.mul(cs, base)
26+
}
27+
28+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
29+
&self,
30+
cs: &mut CS,
31+
mul_base: &MersenneField<F>,
32+
add: &Self,
33+
) -> Self {
34+
self.mul_and_add(cs, mul_base, add)
35+
}
36+
}
37+
38+
impl<F: SmallField> CircuitFieldExpression<F, MersenneField<F>> for MersenneComplex<F> {
39+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
40+
Self {
41+
x: self.x.add(cs, base),
42+
y: self.y,
43+
}
44+
}
45+
46+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
47+
Self {
48+
x: self.x.sub(cs, base),
49+
y: self.y,
50+
}
51+
}
52+
53+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
54+
Self {
55+
x: self.x.mul(cs, base),
56+
y: self.y.mul(cs, base),
57+
}
58+
}
59+
60+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
61+
&self,
62+
cs: &mut CS,
63+
mul_base: &MersenneField<F>,
64+
add: &Self,
65+
) -> Self {
66+
Self {
67+
x: self.x.mul_and_add(cs, mul_base, &add.x),
68+
y: self.y.mul_and_add(cs, mul_base, &add.y),
69+
}
70+
}
71+
}
72+
73+
impl<F: SmallField> CircuitFieldExpression<F, MersenneField<F>> for MersenneQuartic<F> {
74+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
75+
Self {
76+
x: self.x.add_base(cs, base),
77+
y: self.y,
78+
}
79+
}
80+
81+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
82+
Self {
83+
x: self.x.sub_base(cs, base),
84+
y: self.y,
85+
}
86+
}
87+
88+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneField<F>) -> Self {
89+
Self {
90+
x: self.x.mul_by_base(cs, base),
91+
y: self.y.mul_by_base(cs, base),
92+
}
93+
}
94+
95+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
96+
&self,
97+
cs: &mut CS,
98+
mul_base: &MersenneField<F>,
99+
add: &Self,
100+
) -> Self {
101+
Self {
102+
x: self.x.mul_by_base_and_add(cs, mul_base, &add.x),
103+
y: self.y.mul_by_base_and_add(cs, mul_base, &add.y),
104+
}
105+
}
106+
}
107+
108+
impl<F: SmallField> CircuitFieldExpression<F, MersenneComplex<F>> for MersenneComplex<F> {
109+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
110+
self.add(cs, base)
111+
}
112+
113+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
114+
self.sub(cs, base)
115+
}
116+
117+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
118+
self.mul(cs, base)
119+
}
120+
121+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
122+
&self,
123+
cs: &mut CS,
124+
mul_base: &MersenneComplex<F>,
125+
add: &Self,
126+
) -> Self {
127+
self.mul_and_add(cs, mul_base, add)
128+
}
129+
}
130+
131+
impl<F: SmallField> CircuitFieldExpression<F, MersenneComplex<F>> for MersenneQuartic<F> {
132+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
133+
Self {
134+
x: self.x.add(cs, base),
135+
y: self.y,
136+
}
137+
}
138+
139+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
140+
Self {
141+
x: self.x.sub(cs, base),
142+
y: self.y,
143+
}
144+
}
145+
146+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneComplex<F>) -> Self {
147+
Self {
148+
x: self.x.mul(cs, base),
149+
y: self.y.mul(cs, base),
150+
}
151+
}
152+
153+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
154+
&self,
155+
cs: &mut CS,
156+
mul_base: &MersenneComplex<F>,
157+
add: &Self,
158+
) -> Self {
159+
Self {
160+
x: self.x.mul_and_add(cs, mul_base, &add.x),
161+
y: self.y.mul_and_add(cs, mul_base, &add.y),
162+
}
163+
}
164+
}
165+
166+
impl<F: SmallField> CircuitFieldExpression<F, MersenneQuartic<F>> for MersenneQuartic<F> {
167+
fn add_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneQuartic<F>) -> Self {
168+
self.add(cs, base)
169+
}
170+
171+
fn sub_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneQuartic<F>) -> Self {
172+
self.sub(cs, base)
173+
}
174+
175+
fn mul_by_base<CS: ConstraintSystem<F>>(&self, cs: &mut CS, base: &MersenneQuartic<F>) -> Self {
176+
self.mul(cs, base)
177+
}
178+
179+
fn mul_by_base_and_add<CS: ConstraintSystem<F>>(
180+
&self,
181+
cs: &mut CS,
182+
mul_base: &MersenneQuartic<F>,
183+
add: &Self,
184+
) -> Self {
185+
self.mul_and_add(cs, mul_base, add)
186+
}
187+
}

0 commit comments

Comments
 (0)