Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
9d00214
SPARK prover with 2 gpa combined
batmendbar Sep 15, 2025
03e2726
Adds RS and WS
batmendbar Sep 16, 2025
dd1dd42
wip: batch whir
batmendbar Sep 17, 2025
f5ca88d
Adds test
batmendbar Sep 17, 2025
eb30b9f
Creates variable for number of variables
batmendbar Sep 17, 2025
a9bd8f9
Adds batched WHIR to sumcheck+rowwise
batmendbar Sep 18, 2025
6a67ee0
Adds B and C matrices
batmendbar Sep 18, 2025
8585d52
Merge branch 'main' into spark-batched-whir
batmendbar Sep 22, 2025
204259e
Writes request to file
batmendbar Sep 22, 2025
1f7a0eb
Pads matrices
batmendbar Sep 23, 2025
37524f9
Added cli flag and removed debug log
batmendbar Sep 23, 2025
3659823
Buggy: update
batmendbar Sep 24, 2025
745faf4
Parse initial commitments
batmendbar Sep 24, 2025
dd4ebe9
Buggy: current progress
batmendbar Sep 25, 2025
d958f97
Buggy: Merkle parse fix
batmendbar Sep 25, 2025
0a690a9
Fixes 3 poly
batmendbar Sep 26, 2025
cdd2c10
Buggy: current
batmendbar Sep 26, 2025
cf2ccb1
Adds partial RS WS
batmendbar Sep 26, 2025
9be0398
Single matrix
batmendbar Sep 29, 2025
10cf5ae
Cleanup
batmendbar Sep 30, 2025
a189da6
Adds B and C matrices
batmendbar Sep 30, 2025
2f4717b
Complete
batmendbar Sep 30, 2025
c6218eb
Bugg: RLC optimization - val not properly committed
batmendbar Oct 2, 2025
0462090
Rust rlc prover/verifier prototype
batmendbar Oct 2, 2025
dedc0dc
working rlc
batmendbar Oct 3, 2025
c8135bb
Cleanup rust prover
batmendbar Oct 3, 2025
a0b8b8d
cleanup circuit
batmendbar Oct 3, 2025
96d53cb
Cleanup
batmendbar Oct 3, 2025
2c0e940
Merge branch 'main' into spark-rlc
batmendbar Oct 6, 2025
8660d5d
Rust format
batmendbar Oct 6, 2025
962c6ca
feat: refactor
shreyas-londhe Oct 9, 2025
b0960cf
fix: spark proving
shreyas-londhe Oct 10, 2025
12bd1e1
feat: e2e working
shreyas-londhe Oct 11, 2025
775b2ef
chore: remove spark-prover
shreyas-londhe Oct 11, 2025
1990e2e
Merge pull request #214 from worldfnd/sl/spark
batmendbar Oct 15, 2025
b1a130b
Adds gpa4
batmendbar Oct 16, 2025
06f5b65
WIP: gpa4
batmendbar Oct 16, 2025
c48c44a
gpa4
batmendbar Oct 16, 2025
a46164b
WIP
batmendbar Oct 17, 2025
753a2c5
Finishes 4GPA
batmendbar Oct 17, 2025
8a013ad
Finish static dynamic separation
batmendbar Oct 17, 2025
fe0d3bf
Fix recursive verifier
batmendbar Oct 27, 2025
57ed864
Merge branch 'main' into spark-recursive-verifier
batmendbar Oct 27, 2025
cb179d4
Merge branch 'main' into spark-refactor
batmendbar Oct 29, 2025
72d058e
format
batmendbar Oct 29, 2025
c35e8a7
Fix server
batmendbar Oct 29, 2025
44d93ef
Fix documentation
batmendbar Oct 29, 2025
942e91b
Update CI
batmendbar Oct 29, 2025
7a92850
Add tracing to spark prove
batmendbar Oct 29, 2025
2ec2344
Update generate age check circuit keys
batmendbar Oct 29, 2025
23e36f0
Fix circuit key generation
batmendbar Oct 30, 2025
6e13c5a
Update Readme
batmendbar Oct 30, 2025
2fbaa5f
Format
batmendbar Oct 30, 2025
ac05363
Fix profiling
batmendbar Oct 30, 2025
186bc4b
Fix CI
batmendbar Oct 30, 2025
da45cc2
Fix CI
batmendbar Oct 30, 2025
3f3cb3f
implemented rust prover and verifier
batmendbar Oct 31, 2025
3fce992
Format
batmendbar Nov 3, 2025
992a47c
Modularized prover
batmendbar Nov 3, 2025
db4e5bd
Debug recursive verifier
batmendbar Nov 4, 2025
623e94f
Refactor
batmendbar Nov 4, 2025
c782444
Removed cloning
batmendbar Nov 4, 2025
4c862be
Parralelize with rayon
batmendbar Nov 4, 2025
d1b2653
Fix tracing
batmendbar Nov 4, 2025
d853edd
Merge with main
batmendbar Nov 4, 2025
c758f0a
Merge remaining files
batmendbar Nov 4, 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
17 changes: 13 additions & 4 deletions .github/workflows/circuit_keys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Build provekit-cli
run: cargo build --release --bin provekit-cli

- name: Build provekit-cli
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Build provekit-cli
- name: Build spark-cli

run: cargo build --release --bin spark-cli

- name: Setup Go
uses: actions/setup-go@v5
with:
Expand All @@ -53,14 +56,20 @@ jobs:
- name: Generate Gnark inputs
working-directory: ${{ env.CIRCUIT_DIR }}
run: |
cargo run --release --bin provekit-cli prepare ./target/${{ env.CIRCUIT_NAME }}.json -p ./noir-provekit-prover.pkp -v ./noir-provekit-verifier.pkv
cargo run --release --bin provekit-cli prove ./noir-provekit-prover.pkp ./Prover.toml -o ./noir-proof.np
cargo run --release --bin provekit-cli generate-gnark-inputs ./noir-provekit-prover.pkp ./noir-proof.np
cargo run --release --bin provekit-cli prepare ./target/${{ env.CIRCUIT_NAME }}.json --pkp ./prover.pkp --pkv ./verifier.pkv
cargo run --release --bin provekit-cli prove ./prover.pkp ./Prover.toml -o ./proof.np
cargo run --release --bin provekit-cli generate-gnark-inputs ./prover.pkp ./proof.np

- name: Generate Spark Gnark inputs
working-directory: ${{ env.CIRCUIT_DIR }}
run: |
cargo run --release --bin spark-cli -- prove --noir-proof-scheme ./prover.pkp --noir-proof ./proof.np
cargo run --release --bin spark-cli -- verify --spark-proof spark_proof.json --noir-proof ./proof.np

- name: Run Gnark verifier
working-directory: recursive-verifier
run: |
go run cmd/cli/main.go --config "../${{ env.CIRCUIT_DIR }}/params_for_recursive_verifier" --r1cs "../${{ env.CIRCUIT_DIR }}/r1cs.json" --saveKeys "./keys"
go run cmd/cli/main.go --evaluation spark --config "../${{ env.CIRCUIT_DIR }}/params_for_recursive_verifier" --r1cs "../${{ env.CIRCUIT_DIR }}/r1cs.json" --saveKeys "./keys" --spark_config "../${{ env.CIRCUIT_DIR }}/gnark_spark_proof.json"

- name: List keys
working-directory: recursive-verifier
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ jobs:
- name: Generate Gnark inputs
working-directory: noir-examples/noir-passport-examples/complete_age_check
run: |
cargo run --release --bin provekit-cli prepare ./target/complete_age_check.json -p ./noir-provekit-prover.pkp -v ./noir-provekit-verifier.pkv
cargo run --release --bin provekit-cli prove ./noir-provekit-prover.pkp ./Prover.toml -o ./noir-proof.np
cargo run --release --bin provekit-cli generate-gnark-inputs ./noir-provekit-prover.pkp ./noir-proof.np
cargo run --release --bin provekit-cli prepare ./target/complete_age_check.json --pkp ./prover.pkp --pkv ./verifier.pkv
cargo run --release --bin provekit-cli prove ./prover.pkp ./Prover.toml -o ./proof.np
cargo run --release --bin provekit-cli generate-gnark-inputs ./prover.pkp ./proof.np
cargo run --release --bin spark-cli -- prove --noir-proof-scheme ./prover.pkp --noir-proof ./proof.np
cargo run --release --bin spark-cli -- verify --spark-proof spark_proof.json --noir-proof ./proof.np

- name: Run Gnark verifier
working-directory: recursive-verifier
Expand Down Expand Up @@ -85,7 +87,7 @@ jobs:
MONITOR_PID=$!

# Run the main process
./gnark-verifier --config "../noir-examples/noir-passport-examples/complete_age_check/params_for_recursive_verifier" --r1cs "../noir-examples/noir-passport-examples/complete_age_check/r1cs.json" --pk_url ${{ vars.AGE_CHECK_PK }} --vk_url ${{ vars.AGE_CHECK_VK }}
./gnark-verifier --evaluation spark --config "../noir-examples/noir-passport-examples/complete_age_check/params_for_recursive_verifier" --spark_config "../noir-examples/noir-passport-examples/complete_age_check/gnark_spark_proof.json" --r1cs "../noir-examples/noir-passport-examples/complete_age_check/r1cs.json" --pk_url ${{ vars.AGE_CHECK_SPARK_PK }} --vk_url ${{ vars.AGE_CHECK_SPARK_VK }}

# Stop monitoring
kill $MONITOR_PID
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*.np
params_for_recursive_verifier
params
*.pkp
*.pkv
artifacts/

# Don't ignore benchmarking artifacts
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ members = [
"provekit/r1cs-compiler",
"provekit/prover",
"provekit/verifier",
"provekit/spark",
"tooling/cli",
"tooling/provekit-bench",
"tooling/provekit-gnark",
"tooling/spark-cli",
"tooling/verifier-server",
"ntt",
]
Expand Down Expand Up @@ -86,6 +88,7 @@ provekit-prover = { path = "provekit/prover" }
provekit-r1cs-compiler = { path = "provekit/r1cs-compiler" }
provekit-verifier = { path = "provekit/verifier" }
provekit-verifier-server = { path = "tooling/verifier-server" }
provekit-spark = { path = "provekit/spark" }

# 3rd party
anyhow = "1.0.93"
Expand Down
47 changes: 34 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,64 @@ noirup --version v1.0.0-beta.11

## Demo instructions

> _NOTE:_ The example below is being run for single example `poseidon-rounds`. You can use different example to run same commands.
> _NOTE:_ The example below is being run for single example `complete_age_check`. You can use different example to run same commands.

Compile the Noir circuit:
1. Compile the Noir circuit:

```sh
cd noir-examples/poseidon-rounds
cd noir-examples/noir-passport-examples/complete_age_check
nargo compile
```

Prepare the Noir program (generates prover and verifier files):

```sh
cargo run --release --bin provekit-cli prepare ./target/basic.json --pkp ./prover.pkp --pkv ./verifier.pkv
cargo run --release --bin provekit-cli prepare ./target/complete_age_check.json --pkp ./prover.pkp --pkv ./verifier.pkv
```

Generate the Noir Proof using the input Toml:
3. Generate the Noir Proof using the input Toml:

```sh
cargo run --release --bin provekit-cli prove ./prover.pkp ./Prover.toml -o ./proof.np
```

Verify the Noir Proof:
(Optional) Verify the Noir Proof:

```sh
cargo run --release --bin provekit-cli verify ./verifier.pkv ./proof.np
```

Generate inputs for Gnark circuit:
4. Generate inputs for Gnark circuit:

```sh
cargo run --release --bin provekit-cli generate-gnark-inputs ./prover.pkp ./proof.np
```

Recursively verify in a Gnark proof (reads the proof from `../ProveKit/prover/proof`):
5. Recursively verify in a Gnark proof (reads the proof from `../ProveKit/prover/proof`). We provide two methods to prove deferred evaluations.

5.1. Spark: Spark prover generates proof of MLE evaluation

```sh
cd ../../recursive-verifier
go run .
```
5.1.1 Generate the Spark Proof:
```sh
cargo run --release --bin spark-cli -- prove --noir-proof-scheme ./prover.pkp --noir-proof ./proof.np
```

(Optional) Verify the Spark Proof:
```sh
cargo run --release --bin spark-cli -- verify --spark-proof spark_proof.json --noir-proof ./proof.np
```

5.1.2 Recursively verify
```sh
cd ../../../recursive-verifier/cmd/cli
go run . --evaluation spark --config ../../../noir-examples/noir-passport-examples/complete_age_check/params_for_recursive_verifier --spark_config ../../../noir-examples/noir-passport-examples/complete_age_check/gnark_spark_proof.json --r1cs ../../../noir-examples/noir-passport-examples/complete_age_check/r1cs.json
```

5.2. Direct evaluation: verifier directly evaluates MLEs of R1CS matrices
```sh
cd ../../../recursive-verifier/cmd/cli
go run . --evaluation direct --config ../../../noir-examples/noir-passport-examples/complete_age_check/params_for_recursive_verifier --spark_config ../../../noir-examples/noir-passport-examples/complete_age_check/gnark_spark_proof.json --r1cs ../../../noir-examples/noir-passport-examples/complete_age_check/r1cs.json
```

### Benchmarking

Expand Down Expand Up @@ -160,9 +179,11 @@ ProveKit follows a modular architecture with clear separation of concerns:
- **`provekit/r1cs-compiler/`** - R1CS compilation logic and Noir integration
- **`provekit/prover/`** - Proving functionality with witness generation
- **`provekit/verifier/`** - Verification functionality
- **`provekit/spark/`** - Spark logic

### Tooling
- **`tooling/cli/`** - Command-line interface (`provekit-cli`)
- **`tooling/spark-cli/`** - Command-line interface for Spark(`spark-cli`)
- **`tooling/provekit-bench/`** - Benchmarking infrastructure
- **`tooling/provekit-gnark/`** - Gnark integration utilities

Expand All @@ -172,7 +193,7 @@ ProveKit follows a modular architecture with clear separation of concerns:

### Examples & Tests
- **`noir-examples/`** - Example circuits and test programs
- **`gnark-whir/`** - Go-based recursive verification using Gnark
- **`recursive-verifier/`** - Go-based recursive verification using Gnark

## Dependencies

Expand Down
1 change: 1 addition & 0 deletions provekit/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ark-crypto-primitives.workspace = true
ark-ff.workspace = true
ark-serialize.workspace = true
ark-std.workspace = true
ark-poly.workspace = true
spongefish.workspace = true
spongefish-pow.workspace = true
whir.workspace = true
Expand Down
76 changes: 76 additions & 0 deletions provekit/common/src/gnark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use {
crate::WhirConfig,
ark_poly::EvaluationDomain,
serde::{Deserialize, Serialize},
};

#[derive(Debug, Serialize, Deserialize)]

pub struct WHIRConfigGnark {
/// number of rounds
pub n_rounds: usize,
/// rate
pub rate: usize,
/// number of variables
pub n_vars: usize,
/// folding factor
pub folding_factor: Vec<usize>,
/// out of domain samples
pub ood_samples: Vec<usize>,
/// number of queries
pub num_queries: Vec<usize>,
/// proof of work bits
pub pow_bits: Vec<i32>,
/// final queries
pub final_queries: usize,
/// final proof of work bits
pub final_pow_bits: i32,
/// final folding proof of work bits
pub final_folding_pow_bits: i32,
/// domain generator string
pub domain_generator: String,
/// batch size
pub batch_size: usize,
}

impl WHIRConfigGnark {
pub fn new(whir_params: &WhirConfig) -> Self {
WHIRConfigGnark {
n_rounds: whir_params
.folding_factor
.compute_number_of_rounds(whir_params.mv_parameters.num_variables)
.0,
rate: whir_params.starting_log_inv_rate,
n_vars: whir_params.mv_parameters.num_variables,
folding_factor: (0..(whir_params
.folding_factor
.compute_number_of_rounds(whir_params.mv_parameters.num_variables)
.0))
.map(|round| whir_params.folding_factor.at_round(round))
.collect(),
ood_samples: whir_params
.round_parameters
.iter()
.map(|x| x.ood_samples)
.collect(),
num_queries: whir_params
.round_parameters
.iter()
.map(|x| x.num_queries)
.collect(),
pow_bits: whir_params
.round_parameters
.iter()
.map(|x| x.pow_bits as i32)
.collect(),
final_queries: whir_params.final_queries,
final_pow_bits: whir_params.final_pow_bits as i32,
final_folding_pow_bits: whir_params.final_folding_pow_bits as i32,
domain_generator: format!(
"{}",
whir_params.starting_domain.backing_domain.group_gen()
),
batch_size: whir_params.batch_size,
}
}
}
8 changes: 4 additions & 4 deletions provekit/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
pub mod file;
pub mod gnark;
mod interner;
mod noir_proof_scheme;
mod prover;
mod r1cs;
pub mod skyscraper;
pub mod spark;
mod sparse_matrix;
pub mod utils;
mod verifier;
mod whir_r1cs;
pub mod witness;

use crate::{
interner::{InternedFieldElement, Interner},
sparse_matrix::{HydratedSparseMatrix, SparseMatrix},
};
use crate::interner::{InternedFieldElement, Interner};
pub use {
acir::FieldElement as NoirElement,
noir_proof_scheme::{NoirProof, NoirProofScheme},
prover::Prover,
r1cs::R1CS,
sparse_matrix::{HydratedSparseMatrix, SparseMatrix},
verifier::Verifier,
whir::crypto::fields::Field256 as FieldElement,
whir_r1cs::{IOPattern, WhirConfig, WhirR1CSProof, WhirR1CSScheme},
Expand Down
2 changes: 2 additions & 0 deletions provekit/common/src/noir_proof_scheme.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::{
spark::SparkStatement,
whir_r1cs::{WhirR1CSProof, WhirR1CSScheme},
witness::{LayeredWitnessBuilders, NoirWitnessGenerator},
NoirElement, R1CS,
Expand All @@ -21,6 +22,7 @@ pub struct NoirProofScheme {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct NoirProof {
pub whir_r1cs_proof: WhirR1CSProof,
pub spark_statement: SparkStatement,
}

impl NoirProofScheme {
Expand Down
35 changes: 35 additions & 0 deletions provekit/common/src/spark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use {
crate::{utils::serde_ark, FieldElement},
ark_serialize::{CanonicalDeserialize, CanonicalSerialize},
serde::{Deserialize, Serialize},
};

#[derive(
Debug, Clone, PartialEq, Eq, CanonicalSerialize, Serialize, CanonicalDeserialize, Deserialize,
)]
pub struct Point {
#[serde(with = "serde_ark")]
pub row: Vec<FieldElement>,
#[serde(with = "serde_ark")]
pub col: Vec<FieldElement>,
}

#[derive(
Debug, Clone, PartialEq, Eq, CanonicalSerialize, Serialize, CanonicalDeserialize, Deserialize,
)]
pub struct ClaimedValues {
#[serde(with = "serde_ark")]
pub a: FieldElement,
#[serde(with = "serde_ark")]
pub b: FieldElement,
#[serde(with = "serde_ark")]
pub c: FieldElement,
}

#[derive(
Debug, Clone, PartialEq, Eq, CanonicalSerialize, Serialize, CanonicalDeserialize, Deserialize,
)]
pub struct SparkStatement {
pub point_to_evaluate: Point,
pub claimed_values: ClaimedValues,
}
1 change: 1 addition & 0 deletions provekit/common/src/utils/sumcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ pub fn calculate_evaluations_over_boolean_hypercube_for_eq(
}

/// Evaluates the equality polynomial recursively.
#[inline(always)]
fn eval_eq(eval: &[FieldElement], out: &mut [FieldElement], scalar: FieldElement) {
debug_assert_eq!(out.len(), 1 << eval.len());
let size = out.len();
Expand Down
1 change: 1 addition & 0 deletions provekit/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository.workspace = true
# Workspace crates
provekit-common.workspace = true
skyscraper.workspace = true
serde_json.workspace = true

# Noir language
acir.workspace = true
Expand Down
7 changes: 5 additions & 2 deletions provekit/prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ impl Prove for Prover {
.context("While verifying R1CS instance")?;

// Prove R1CS instance
let whir_r1cs_proof = self
let (whir_r1cs_proof, spark_statement) = self
.whir_for_witness
.prove(self.r1cs, witness)
.context("While proving R1CS instance")?;

Ok(NoirProof { whir_r1cs_proof })
Ok(NoirProof {
whir_r1cs_proof,
spark_statement,
})
}

fn create_witness_io_pattern(&self) -> IOPattern {
Expand Down
Loading
Loading