Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a3a6f30
Add SPARK
batmendbar Mar 18, 2026
c53d3d2
Merge main into adds-spark-squashed
batmendbar Mar 18, 2026
5d9fef0
Remove comments
batmendbar Mar 18, 2026
6108fc8
Format
batmendbar Mar 18, 2026
fb9f3fc
Cleanup
batmendbar Mar 18, 2026
0fb0d8e
split commitments
batmendbar Mar 20, 2026
3cdbf0d
Merge branch 'main' into adds-spark-squashed
batmendbar Mar 24, 2026
f9bcf09
combine files
batmendbar Mar 24, 2026
ff5c3bd
format
batmendbar Mar 24, 2026
2a65bae
recompute timestamps on prover
batmendbar Mar 24, 2026
6e94a18
change file write
batmendbar Mar 25, 2026
44390ac
file write and ci change
batmendbar Mar 25, 2026
af2245b
fix ci
batmendbar Mar 25, 2026
abba4c4
format
batmendbar Mar 25, 2026
7c7d47d
update tracing
batmendbar Mar 25, 2026
c69eab7
combines prepare and spark-prove into a server
batmendbar Mar 26, 2026
5e15c6e
parallelize and update end-to-end.yml
batmendbar Mar 26, 2026
c7d174a
cleanup
batmendbar Mar 26, 2026
d96ad02
cleanup
batmendbar Mar 26, 2026
69ab9c7
cleanup
batmendbar Mar 26, 2026
941d799
format
batmendbar Mar 26, 2026
09056f9
organize tracing
batmendbar Apr 8, 2026
8bbeb5d
Format and organize
batmendbar Apr 8, 2026
db411d5
merge
batmendbar Apr 8, 2026
1062d1d
Adds temporary transcript draining
batmendbar Apr 8, 2026
c5cbc91
format
batmendbar Apr 27, 2026
70111ef
Separate spark query from noir proof
batmendbar Apr 27, 2026
ce1c677
limit message size
batmendbar Apr 27, 2026
76cbf24
stop user-given server write
batmendbar Apr 27, 2026
19f6ab9
zero check
batmendbar Apr 28, 2026
0afba35
write spark commitment to a file
batmendbar Apr 29, 2026
96530fa
cli command to natively verify spark proofs
batmendbar Apr 29, 2026
58e01e7
move spark commitments to setup
batmendbar Apr 29, 2026
83d95eb
use request in DS instance
batmendbar Apr 29, 2026
9c3eae6
format
batmendbar Apr 29, 2026
a2d65c1
Merge branch 'main' into adds-spark-squashed
batmendbar Apr 29, 2026
dcec2d0
fix CI errors
batmendbar Apr 29, 2026
b0ddd0d
remove spark server
batmendbar Apr 30, 2026
6a7f053
merge whir proofs
batmendbar May 4, 2026
e7cf195
use reference to optimize
batmendbar May 4, 2026
9762059
optimize gpa4 vector building
batmendbar May 4, 2026
1b3f44b
initialize once optimization
batmendbar May 4, 2026
a4fd935
gpa base layer refactor
batmendbar May 4, 2026
dc07d98
simplify rayon
batmendbar May 5, 2026
7bbbd5c
adds hash engine to spark
batmendbar May 5, 2026
d233b5c
adds cli flag for spark
batmendbar May 5, 2026
52f8b94
Removes clone
batmendbar May 5, 2026
1b2bdce
format
batmendbar May 5, 2026
98c6a08
fix docs
batmendbar May 5, 2026
e7839be
Decouple from batching randomness
batmendbar May 7, 2026
d45bb7c
Spark batch request
batmendbar May 7, 2026
3d31fca
separate path for single request
batmendbar May 7, 2026
aadb89f
format
batmendbar May 7, 2026
7a2ca2a
update spark.md
batmendbar May 7, 2026
14cc661
update ci
batmendbar May 7, 2026
55cdbd8
cleanup
batmendbar May 12, 2026
73240c7
merge with main
batmendbar May 14, 2026
835986c
Merge branch 'main' into adds-spark-squashed
batmendbar Jun 5, 2026
6b2d19d
Serialize Spark Witness
batmendbar Jun 8, 2026
d0615ee
Ensure requests share the same row
batmendbar Jun 8, 2026
6462834
SPARK uses snake case
batmendbar Jun 8, 2026
1612ea1
Combine spark query files
batmendbar Jun 8, 2026
d04875c
Use specified hash in spark
batmendbar Jun 8, 2026
f1b7b9a
Adds helper function for hint reading
batmendbar Jun 9, 2026
fd5ebb6
Groups function parameters
batmendbar Jun 9, 2026
9e368e2
Save timestamps as integers
batmendbar Jun 9, 2026
e9161cc
Remove gpa duplication
batmendbar Jun 9, 2026
5be9e49
Simplified Spark structs
batmendbar Jun 9, 2026
0bd4615
fix spark flag
batmendbar Jun 9, 2026
df0edfa
format
batmendbar Jun 9, 2026
990a448
Move SparkSetup into PKV
batmendbar Jun 9, 2026
6faaf66
cleanup
batmendbar Jun 9, 2026
707765f
cleanup
batmendbar Jun 24, 2026
b47e33d
Merge branch 'main' into adds-spark-squashed
batmendbar Jun 25, 2026
930b401
cleanup
batmendbar Jun 25, 2026
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
*.pkp
*.pkv
*.np
*.sp
*.spc
*.spctx
spark_proofs/
params_for_recursive_verifier
params
artifacts/
spartan_vm_debug/
mavros_debug/
mavros/

# Don't ignore benchmarking artifacts
!tooling/provekit-bench/benches/*
Expand Down
34 changes: 26 additions & 8 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 @@ -17,6 +17,7 @@ members = [
"tooling/provekit-wasm",
"tooling/verifier-server",
"ntt",
"provekit/spark",
"poseidon2",
"playground/passport-input-gen",
]
Expand Down Expand Up @@ -102,6 +103,7 @@ provekit-ffi = { path = "tooling/provekit-ffi" }
provekit-gnark = { path = "tooling/provekit-gnark" }
provekit-prover = { path = "provekit/prover", default-features = false }
provekit-r1cs-compiler = { path = "provekit/r1cs-compiler" }
provekit-spark = { path = "provekit/spark" }
provekit-verifier = { path = "provekit/verifier" }
provekit-verifier-server = { path = "tooling/verifier-server" }
provekit-wasm = { path = "tooling/provekit-wasm" }
Expand Down
10 changes: 8 additions & 2 deletions provekit/common/src/file/binary_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ pub const PROVER_FORMAT: [u8; 8] = *b"PrvKitPr";
pub const PROVER_VERSION: (u16, u16) = (1, 2);

pub const VERIFIER_FORMAT: [u8; 8] = *b"PrvKitVr";
pub const VERIFIER_VERSION: (u16, u16) = (1, 3);
pub const VERIFIER_VERSION: (u16, u16) = (1, 4);

pub const NOIR_PROOF_SCHEME_FORMAT: [u8; 8] = *b"NrProScm";
pub const NOIR_PROOF_SCHEME_VERSION: (u16, u16) = (1, 2);

pub const NOIR_PROOF_FORMAT: [u8; 8] = *b"NPSProof";
pub const NOIR_PROOF_VERSION: (u16, u16) = (1, 1);
pub const NOIR_PROOF_VERSION: (u16, u16) = (1, 2);

pub const SPARK_PROOF_FORMAT: [u8; 8] = *b"SparkPrf";
pub const SPARK_PROOF_VERSION: (u16, u16) = (1, 0);

pub const SPARK_CONTEXT_FORMAT: [u8; 8] = *b"SparkCtx";
pub const SPARK_CONTEXT_VERSION: (u16, u16) = (1, 0);
5 changes: 3 additions & 2 deletions provekit/common/src/file/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ mod buf_ext;
mod counting_writer;
mod json;

pub use self::bin::Compression;
use {
self::{
bin::{
deserialize_from_bytes, read_bin, read_hash_config as read_hash_config_bin,
serialize_to_bytes, write_bin, Compression,
serialize_to_bytes, write_bin,
},
buf_ext::BufExt,
counting_writer::CountingWriter,
Expand All @@ -29,7 +30,7 @@ pub trait FileFormat: Serialize + for<'a> Deserialize<'a> {
}

/// Helper trait to optionally extract hash config.
pub(crate) trait MaybeHashAware {
pub trait MaybeHashAware {
fn maybe_hash_config(&self) -> Option<HashConfig>;
}

Expand Down
4 changes: 3 additions & 1 deletion provekit/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod file;
pub use file::binary_format;
pub mod hash_config;
mod interner;
pub mod interner;
mod mavros;
mod noir_proof_scheme;
pub mod ntt;
Expand All @@ -11,6 +11,7 @@ pub mod prefix_covector;
mod prover;
mod r1cs;
pub mod skyscraper;
pub mod spark;
pub mod sparse_matrix;
mod transcript_sponge;
pub mod u256_arith;
Expand All @@ -32,6 +33,7 @@ pub use {
prefix_covector::{OffsetCovector, PrefixCovector, SparseCovector},
prover::{NoirProver, Prover},
r1cs::R1CS,
spark::{MatrixDimensions, SparkSetup, SparkWhirConfigs},
transcript_sponge::TranscriptSponge,
verifier::Verifier,
whir_r1cs::{R1csHash, WhirConfig, WhirR1CSProof, WhirR1CSScheme, WhirZkConfig},
Expand Down
72 changes: 72 additions & 0 deletions provekit/common/src/spark.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
use {
crate::{utils::serde_ark, FieldElement, HashConfig, WhirConfig, WhirR1CSProof},
anyhow::{Context, Result},
serde::{Deserialize, Serialize},
sha3::{Digest, Sha3_256},
};

/// A single column-axis SPARK query: an evaluation point on the column axis
/// plus three claimed evaluations (for the A, B, C matrices). The row axis is
/// shared across all queries in a [`SparkQueryBatch`].
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SparkColQuery {
#[serde(with = "serde_ark")]
pub col: Vec<FieldElement>,
#[serde(with = "serde_ark")]
pub claimed_a: FieldElement,
#[serde(with = "serde_ark")]
pub claimed_b: FieldElement,
#[serde(with = "serde_ark")]
pub claimed_c: FieldElement,
}

/// A batch of SPARK queries that all share the same row evaluation point.
/// The shared-row invariant is structural: a batch *cannot* express a
/// mixed-row set, so the SPARK prover and verifier do not need a runtime
/// check.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SparkQueryBatch {
#[serde(with = "serde_ark")]
pub row: Vec<FieldElement>,
pub queries: Vec<SparkColQuery>,
}

impl SparkQueryBatch {
/// Stable Fiat-Shamir instance binding for the batch.
pub fn hash_bytes(&self) -> Result<[u8; 32]> {
let bytes =
postcard::to_allocvec(self).context("serializing SparkQueryBatch for hash_bytes")?;
Ok(Sha3_256::digest(&bytes).into())
}
}

/// Dimensions of the (padded) sparse R1CS matrix that SPARK is committing to.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MatrixDimensions {
pub num_rows: usize,
pub num_cols: usize,
pub nonzero_terms: usize,
}

/// WHIR configurations used by SPARK for each committed polynomial axis.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SparkWhirConfigs {
pub row: WhirConfig,
pub col: WhirConfig,
pub num_terms_2batched: WhirConfig,
pub num_terms_5batched: WhirConfig,
}

/// Verifier-side SPARK setup: WHIR configs, matrix dimensions, the preprocessed
/// commitment transcript, and the hash config used to seed Fiat-Shamir.
///
/// This struct is embedded in [`Verifier`](crate::Verifier) so the SPARK
/// commitments come from the trusted `.pkv` key rather than an attacker-
/// supplied setup file.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SparkSetup {
pub whir_configs: SparkWhirConfigs,
pub matrix_dimensions: MatrixDimensions,
pub transcript: WhirR1CSProof,
pub hash_config: HashConfig,
}
5 changes: 5 additions & 0 deletions provekit/common/src/utils/sumcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ fn eval_eq(
}
}

/// Evaluates a quadratic polynomial on a value
pub fn eval_quadratic_poly(poly: [FieldElement; 3], point: FieldElement) -> FieldElement {
poly[0] + point * (poly[1] + point * poly[2])
}

/// Evaluates a cubic polynomial on a value
pub fn eval_cubic_poly(poly: [FieldElement; 4], point: FieldElement) -> FieldElement {
poly[0] + point * (poly[1] + point * (poly[2] + point * poly[3]))
Expand Down
12 changes: 8 additions & 4 deletions provekit/common/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{
noir_proof_scheme::NoirProofScheme, utils::serde_jsonify, whir_r1cs::WhirR1CSScheme,
HashConfig, R1CS,
noir_proof_scheme::NoirProofScheme, spark::SparkSetup, utils::serde_jsonify,
whir_r1cs::WhirR1CSScheme, HashConfig, R1CS,
},
noirc_abi::Abi,
serde::{Deserialize, Serialize},
Expand All @@ -11,13 +11,15 @@ use {
/// serialized to a `.pkv` file by `prepare` and loaded by `verify` (or by
/// `generate-gnark-inputs` for the recursive path).
///
/// Holds the R1CS, the WHIR-for-witness commitment configuration, and the
/// ABI needed to bind public inputs back to their Noir-level names.
/// Holds the R1CS, the WHIR-for-witness commitment configuration, the SPARK
/// setup (when `prepare --spark` was used), and the ABI needed to bind public
/// inputs back to their Noir-level names.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Verifier {
pub hash_config: HashConfig,
pub r1cs: R1CS,
pub whir_for_witness: Option<WhirR1CSScheme>,
pub spark_setup: Option<SparkSetup>,
#[serde(with = "serde_jsonify")]
pub abi: Abi,
}
Expand All @@ -28,12 +30,14 @@ impl Verifier {
NoirProofScheme::Noir(d) => Self {
r1cs: d.r1cs,
whir_for_witness: Some(d.whir_for_witness),
spark_setup: None,
abi: d.witness_generator.abi.clone(),
hash_config: d.hash_config,
},
NoirProofScheme::Mavros(d) => Self {
r1cs: d.r1cs,
whir_for_witness: Some(d.whir_for_witness),
spark_setup: None,
abi: d.abi.clone(),
hash_config: d.hash_config,
},
Expand Down
Loading
Loading