Skip to content

Commit 83bf5e0

Browse files
mm-zkolesHolem
andauthored
chore: fixing issue with public inputs chunking, and other small fixes (#9)
Co-authored-by: Oles Holembovskyy <[email protected]>
1 parent c04cde9 commit 83bf5e0

File tree

10 files changed

+162
-119
lines changed

10 files changed

+162
-119
lines changed

Cargo.toml

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

1515
[dependencies]
16-
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "mmzk_0418_without_field" }
16+
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "mmzk_0418_without_field" , features = ["log_tracing"]}
1717
# boojum = { path = "../zksync-crypto/crates/boojum"}
1818
bellman = { git = "https://github.com/matter-labs/zksync-crypto.git", package="zksync_bellman", branch = "mmzk_0418_without_field" }
1919
# bellman = { path = "../zksync-crypto/crates/bellman", package="zksync_bellman"}
2020
rescue_poseidon = { git = "https://github.com/matter-labs/zksync-crypto.git", package="rescue_poseidon", branch = "mmzk_0418_without_field" }
2121
# rescue_poseidon = { path = "../zksync-crypto/crates/rescue-poseidon"}
2222
snark_wrapper = { git = "https://github.com/matter-labs/zksync-crypto.git", package="snark_wrapper", branch = "mmzk_0418_without_field" }
2323
# snark_wrapper = { path = "../zksync-crypto/crates/snark-wrapper"}
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"}
24+
risc_verifier = {git="https://github.com/matter-labs/air_compiler.git", package="final_reduced_risc_v_machine_verifier", features=["proof_utils"], branch="main"}
2525
# 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"}
26+
execution_utils = {git="https://github.com/matter-labs/air_compiler.git", package="execution_utils", branch="main"}
2727
# execution_utils = {path="../air_compiler/execution_utils"}
2828
circuit_mersenne_field = {path="circuit_mersenne_field"}
2929
serde_json = { version = "*" }

circuit_mersenne_field/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ edition = "2021"
66
[dependencies]
77
boojum = { git = "https://github.com/matter-labs/zksync-crypto.git", package="boojum", branch = "mmzk_0418_without_field" }
88
# boojum = { path = "../../zksync-crypto/crates/boojum"}
9-
mersenne_field = {git="https://github.com/matter-labs/air_compiler.git", package="field", branch="oh_binaries_updated"}
9+
mersenne_field = {git="https://github.com/matter-labs/air_compiler.git", package="field", branch="main"}
1010
# mersenne_field = {path="../../air_compiler/field", package="field"}
1111
rand = "0.8"

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2025-03-31
1+
nightly-2025-02-28

src/circuits/risc_wrapper.rs

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use boojum::{
22
cs::{
3+
CSGeometry, GateConfigurationHolder, LookupParameters, StaticToolboxHolder,
34
cs_builder::{CsBuilder, CsBuilderImpl},
45
gates::{
56
ConstantsAllocatorGate, FmaGateInBaseFieldWithoutConstant, NopGate, PublicInputGate,
@@ -8,22 +9,21 @@ use boojum::{
89
},
910
implementations::prover::ProofConfig,
1011
traits::{circuit::CircuitBuilder, cs::ConstraintSystem, gate::GatePlacementStrategy},
11-
CSGeometry, GateConfigurationHolder, LookupParameters, StaticToolboxHolder,
1212
},
1313
field::SmallField,
1414
gadgets::{
1515
num::Num,
1616
tables::{
17-
byte_split::{create_byte_split_table, ByteSplitTable},
18-
xor8::{create_xor8_table, Xor8Table},
17+
byte_split::{ByteSplitTable, create_byte_split_table},
18+
xor8::{Xor8Table, create_xor8_table},
1919
},
20-
traits::{allocatable::CSAllocatable, witnessable::WitnessHookable},
20+
traits::allocatable::CSAllocatable,
2121
u16::UInt16,
2222
u32::UInt32,
2323
},
2424
};
2525
use circuit_mersenne_field::{
26-
extension_trait::CircuitFieldExpression, MersenneField, MersenneQuartic,
26+
MersenneField, MersenneQuartic, extension_trait::CircuitFieldExpression,
2727
};
2828
use std::mem::MaybeUninit;
2929

@@ -45,14 +45,14 @@ use risc_verifier::prover::risc_v_simulator::cycle::state::NUM_REGISTERS;
4545
use risc_verifier::prover::cs::definitions::*;
4646

4747
use risc_verifier::verifier_common::{
48-
transcript::Blake2sBufferingTranscript, DefaultNonDeterminismSource, ProofOutput,
49-
ProofPublicInputs,
48+
DefaultNonDeterminismSource, ProofOutput, ProofPublicInputs,
49+
transcript::Blake2sBufferingTranscript,
5050
};
5151

52-
use boojum::gadgets::tables::create_range_check_15_bits_table;
53-
use boojum::gadgets::tables::create_range_check_16_bits_table;
5452
use boojum::gadgets::tables::RangeCheck15BitsTable;
5553
use boojum::gadgets::tables::RangeCheck16BitsTable;
54+
use boojum::gadgets::tables::create_range_check_15_bits_table;
55+
use boojum::gadgets::tables::create_range_check_16_bits_table;
5656
use risc_verifier::prover::prover_stages::Proof as RiscProof;
5757

5858
const NUM_RISC_WRAPPER_PUBLIC_INPUTS: usize = 4;
@@ -287,7 +287,7 @@ impl<F: SmallField, V: CircuitLeafInclusionVerifier<F>> RiscWrapperCircuit<F, V>
287287

288288
// we carry registers 10-17 to the next layer - those are the output of the base program
289289
let output_registers_values: Vec<_> = final_registers_state
290-
.chunks(2)
290+
.chunks(3)
291291
.skip(10)
292292
.take(8)
293293
.flat_map(|chunk| chunk[0].decompose_into_bytes(cs))
@@ -460,23 +460,6 @@ pub(crate) fn check_proof_state<F: SmallField, CS: ConstraintSystem<F>>(
460460
NUM_DELEGATION_CHALLENGES > 0,
461461
);
462462

463-
dbg!(
464-
proof_state
465-
.memory_challenges
466-
.memory_argument_linearization_challenges
467-
.witness_hook(cs)(),
468-
proof_state
469-
.memory_challenges
470-
.memory_argument_gamma
471-
.witness_hook(cs)(),
472-
memory_argument_challenges
473-
.memory_argument_linearization_challenges
474-
.witness_hook(cs)(),
475-
memory_argument_challenges
476-
.memory_argument_gamma
477-
.witness_hook(cs)(),
478-
);
479-
480463
memory_argument_challenges.enforce_equal(cs, &proof_state.memory_challenges);
481464
if NUM_DELEGATION_CHALLENGES > 0 {
482465
delegation_argument_challenges

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use clap::Parser;
1111
use bellman::kate_commitment::{Crs, CrsForMonomialForm};
1212
use bellman::worker::Worker as BellmanWorker;
1313

14+
use zkos_wrapper::{Bn256, L1_VERIFIER_DOMAIN_SIZE_LOG};
1415
use zkos_wrapper::{
1516
circuits::RiscWrapperWitness, get_compression_setup, get_risc_wrapper_setup,
1617
get_snark_wrapper_setup, prove_compression, prove_risc_wrapper, prove_snark_wrapper,
1718
verify_compression_proof, verify_risc_wrapper_proof, verify_snark_wrapper_proof,
1819
};
19-
use zkos_wrapper::{Bn256, L1_VERIFIER_DOMAIN_SIZE_LOG};
2020

2121
#[derive(Parser)]
2222
#[command(version, about, long_about = None)]
@@ -40,6 +40,8 @@ fn deserialize_from_file<T: serde::de::DeserializeOwned>(filename: &str) -> T {
4040
fn main() -> Result<(), Box<dyn std::error::Error>> {
4141
let cli = Cli::parse();
4242

43+
println!("=== Phase 1: Creating the Risc wrapper proof");
44+
4345
let worker = boojum::worker::Worker::new_with_num_threads(4);
4446

4547
let program_proof = deserialize_from_file(&cli.input);
@@ -75,6 +77,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
7577
&Path::new(&cli.output_dir.clone()).join("risc_proof.json"),
7678
);
7779

80+
println!("=== Phase 2: Creating compression proof");
81+
7882
let (
7983
finalization_hint,
8084
setup_base,
@@ -105,6 +109,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
105109
&Path::new(&cli.output_dir.clone()).join("compression_proof.json"),
106110
);
107111

112+
println!("=== Phase 3: Creating SNARK proof");
113+
108114
{
109115
let worker = BellmanWorker::new_with_cpus(4);
110116

src/tests/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ use crate::transcript::*;
22
use crate::wrapper_inner_verifier::skeleton::*;
33
use crate::wrapper_utils::verifier_traits::CircuitBlake2sForEverythingVerifier;
44
use crate::wrapper_utils::verifier_traits::CircuitLeafInclusionVerifier;
5+
use boojum::cs::LookupParameters;
56
use boojum::cs::gates::FmaGateInBaseFieldWithoutConstant;
67
use boojum::cs::gates::NopGate;
78
use boojum::cs::gates::SelectionGate;
89
use boojum::cs::gates::ZeroCheckGate;
9-
use boojum::cs::LookupParameters;
10-
use boojum::gadgets::tables::create_range_check_15_bits_table;
11-
use boojum::gadgets::tables::create_range_check_16_bits_table;
1210
use boojum::gadgets::tables::RangeCheck15BitsTable;
1311
use boojum::gadgets::tables::RangeCheck16BitsTable;
12+
use boojum::gadgets::tables::create_range_check_15_bits_table;
13+
use boojum::gadgets::tables::create_range_check_16_bits_table;
1414
use boojum::{
1515
cs::{
16+
CSGeometry,
1617
gates::{ConstantsAllocatorGate, ReductionGate, U32TriAddCarryAsChunkGate, UIntXAddGate},
1718
traits::{cs::ConstraintSystem, gate::GatePlacementStrategy},
18-
CSGeometry,
1919
},
2020
dag::CircuitResolverOpts,
2121
gadgets::blake2s::mixing_function::Word,
2222
gadgets::{
2323
tables::{
24-
byte_split::{create_byte_split_table, ByteSplitTable},
25-
xor8::{create_xor8_table, Xor8Table},
24+
byte_split::{ByteSplitTable, create_byte_split_table},
25+
xor8::{Xor8Table, create_xor8_table},
2626
},
2727
traits::witnessable::WitnessHookable,
2828
u32::UInt32,
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
pub(crate) const FINAL_RISC_CIRCUIT_END_PARAMS: [u32; 8usize] = [
2-
1084790708u32,
3-
5361886u32,
4-
780007677u32,
5-
2427515337u32,
6-
1615785659u32,
7-
2910616041u32,
8-
872871208u32,
9-
2091005209u32,
2+
3720499768u32,
3+
1999558729u32,
4+
2634397082u32,
5+
2874636721u32,
6+
2927295123u32,
7+
1198777685u32,
8+
3190458316u32,
9+
1220676032u32,
1010
];
1111
pub(crate) const FINAL_RISC_CIRCUIT_AUX_REGISTERS_VALUES: [u32; 8usize] = [
12-
2369219390u32,
13-
1113127411u32,
14-
3416575085u32,
15-
2776983668u32,
16-
99649126u32,
17-
2857787559u32,
18-
4051254451u32,
19-
3927721995u32,
12+
3771437303u32,
13+
594675024u32,
14+
1830865157u32,
15+
950617708u32,
16+
2250245805u32,
17+
2186801436u32,
18+
381060896u32,
19+
953695755u32,
2020
];

wrapper_generator/Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@ name = "wrapper_generator"
55
version = "0.1.0"
66
edition = "2024"
77

8+
[lib]
9+
path = "src/lib.rs"
10+
11+
[[bin]]
12+
name = "cli"
13+
path = "src/main.rs"
14+
815
[dependencies]
916
clap = { version = "4.5.21", features = ["derive"] }
10-
zkos_verifier_generator = {git="https://github.com/matter-labs/air_compiler.git", package="verifier_generator", branch="oh_binaries_updated"}
17+
zkos_verifier_generator = {git="https://github.com/matter-labs/air_compiler.git", package="verifier_generator", branch="main"}
1118
# zkos_verifier_generator = {path="../../air_compiler/verifier_generator", package="verifier_generator"}
12-
prover = {git="https://github.com/matter-labs/air_compiler.git", package="prover", branch="oh_binaries_updated"}
19+
prover = {git="https://github.com/matter-labs/air_compiler.git", package="prover", branch="main"}
1320
# prover = {path="../../air_compiler/prover", package="prover"}
14-
execution_utils = {git="https://github.com/matter-labs/air_compiler.git", package="execution_utils", branch="oh_binaries_updated"}
21+
execution_utils = {git="https://github.com/matter-labs/air_compiler.git", package="execution_utils", branch="main"}
1522
# execution_utils = {path="../../air_compiler/execution_utils"}
16-
setups = {git="https://github.com/matter-labs/air_compiler.git", package="setups", branch="oh_binaries_updated"}
23+
setups = {git="https://github.com/matter-labs/air_compiler.git", package="setups", branch="main"}
1724
# setups = {path="../../air_compiler/circuit_defs/setups"}
1825
serde_json = "*"
1926
serde = { version = "1", default-features = false, features = ["derive", "alloc"]}

0 commit comments

Comments
 (0)