Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
424 changes: 59 additions & 365 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ poseidon2 = { path = "poseidon2" }
# Workspace members - ProveKit
provekit-bench = { path = "tooling/provekit-bench" }
provekit-cli = { path = "tooling/cli" }
provekit-common = { path = "provekit/common" , features = ["provekit_ntt"]}
# No default features: consumers pick the field (`bn254`/`goldilocks`) plus
# `parallel`/`provekit_ntt` explicitly — required so the goldilocks build can
# exclude the default `bn254` feature.
provekit-common = { path = "provekit/common", default-features = false }
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-verifier = { path = "provekit/verifier" }
provekit-verifier = { path = "provekit/verifier", default-features = false }
provekit-verifier-server = { path = "tooling/verifier-server" }
provekit-wasm = { path = "tooling/provekit-wasm" }

Expand Down Expand Up @@ -130,7 +133,6 @@ rand = "0.9.1"
rand08 = { package = "rand", version = "0.8" }
rayon = "1.10.0"
reqwest = "0.12.23"
ruint = { version = "1.12.3", features = ["num-traits", "rand"] }
seq-macro = "0.3.6"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion playground/passport-input-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ark-ff.workspace = true
base64.workspace = true
hex.workspace = true
noirc_abi.workspace = true
provekit-common.workspace = true
provekit-common = { workspace = true, features = ["bn254", "parallel", "provekit_ntt"] }
provekit-prover = { workspace = true, features = ["witness-generation"] }
serde.workspace = true
serde_json.workspace = true
Expand Down
19 changes: 14 additions & 5 deletions provekit/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[package]
name = "provekit-common"
version = "1.0.0"
# Warns when both field features are on (silent BN254 precedence); see build.rs.
build = "build.rs"
edition.workspace = true
rust-version.workspace = true
authors.workspace = true
Expand All @@ -9,9 +11,16 @@ homepage.workspace = true
repository.workspace = true

[features]
default = ["parallel"]
default = ["parallel", "bn254"]
# At least one field feature must be enabled; `bn254` takes precedence when
# both are on (so `--all-features` builds as BN254). `bn254` is the
# production default; `goldilocks` selects the Goldilocks cubic extension
# (Field64_3, ~192 bits) for off-chain, crate-scoped builds only — always
# pair it with `--no-default-features`.
bn254 = ["dep:mavros-vm", "dep:mavros-artifacts"]
goldilocks = []
parallel = []
provekit_ntt = []
provekit_ntt = ["bn254"]

[dependencies]
# Workspace crates
Expand Down Expand Up @@ -41,7 +50,6 @@ hex.workspace = true
itertools.workspace = true
postcard.workspace = true
rayon.workspace = true
ruint.workspace = true
serde.workspace = true
serde_json.workspace = true
blake3.workspace = true
Expand All @@ -53,8 +61,8 @@ zerocopy.workspace = true
# Target-specific dependencies: only on non-WASM targets
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
zstd.workspace = true
mavros-vm.workspace = true
mavros-artifacts.workspace = true
mavros-vm = { workspace = true, optional = true }
mavros-artifacts = { workspace = true, optional = true }
xz2.workspace = true

[package.metadata.cargo-machete]
Expand All @@ -69,6 +77,7 @@ proptest.workspace = true
[[bench]]
name = "rs_bench"
harness = false
required-features = ["bn254"]

[lints]
workspace = true
27 changes: 27 additions & 0 deletions provekit/common/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Build script for `provekit-common`.
//!
//! Surfaces the one field-feature footgun the `compile_error!` in `src/lib.rs`
//! cannot catch. `bn254` wins cfg precedence over `goldilocks` (so the crate
//! builds as BN254 whenever both are on — the intended resolution under
//! `--all-features`, which CI uses). But several BN254-only features pull in
//! `bn254` transitively (`provekit_ntt`, and the prover's
//! `witness-generation`), so an explicit `--features goldilocks,<that>` build
//! silently compiles as BN254 instead of Goldilocks. `compile_error!` only
//! fires when *no* field is selected, never here.
//!
//! A `cargo:warning` makes the override visible without failing the build
//! (a hard error would break the legitimate `--all-features` path). Build-
//! script warnings are advisory, so this is safe even under `-D warnings`.
fn main() {
let bn254 = std::env::var_os("CARGO_FEATURE_BN254").is_some();
let goldilocks = std::env::var_os("CARGO_FEATURE_GOLDILOCKS").is_some();
if bn254 && goldilocks {
println!(
"cargo:warning=provekit-common: both `bn254` and `goldilocks` features are enabled; \
FieldElement is BN254 (bn254 takes precedence), so `goldilocks` is inert. For a real \
Goldilocks build use `--no-default-features --features goldilocks` and drop any \
feature that pulls in bn254 (provekit_ntt, the prover's witness-generation). This \
warning is expected under --all-features."
);
}
}
12 changes: 11 additions & 1 deletion provekit/common/src/file/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ mod buf_ext;
mod counting_writer;
mod json;

#[cfg(feature = "bn254")]
use crate::{NoirProof, NoirProofScheme, Prover, Verifier};
use {
self::{
bin::{
Expand All @@ -13,7 +15,7 @@ use {
counting_writer::CountingWriter,
json::{read_json, write_json},
},
crate::{HashConfig, NoirProof, NoirProofScheme, Prover, Verifier},
crate::HashConfig,
anyhow::Result,
serde::{Deserialize, Serialize},
std::{ffi::OsStr, path::Path},
Expand All @@ -34,6 +36,7 @@ pub(crate) trait MaybeHashAware {
}

/// Impl for Prover (has hash config).
#[cfg(feature = "bn254")]
impl MaybeHashAware for Prover {
fn maybe_hash_config(&self) -> Option<HashConfig> {
match self {
Expand All @@ -44,20 +47,23 @@ impl MaybeHashAware for Prover {
}

/// Impl for Verifier (has hash config).
#[cfg(feature = "bn254")]
impl MaybeHashAware for Verifier {
fn maybe_hash_config(&self) -> Option<HashConfig> {
Some(self.hash_config)
}
}

/// Impl for NoirProof (no hash config).
#[cfg(feature = "bn254")]
impl MaybeHashAware for NoirProof {
fn maybe_hash_config(&self) -> Option<HashConfig> {
None
}
}

/// Impl for NoirProofScheme (has hash config).
#[cfg(feature = "bn254")]
impl MaybeHashAware for NoirProofScheme {
fn maybe_hash_config(&self) -> Option<HashConfig> {
match self {
Expand All @@ -67,27 +73,31 @@ impl MaybeHashAware for NoirProofScheme {
}
}

#[cfg(feature = "bn254")]
impl FileFormat for NoirProofScheme {
const FORMAT: [u8; 8] = crate::binary_format::NOIR_PROOF_SCHEME_FORMAT;
const EXTENSION: &'static str = "nps";
const VERSION: (u16, u16) = crate::binary_format::NOIR_PROOF_SCHEME_VERSION;
const COMPRESSION: Compression = Compression::Zstd;
}

#[cfg(feature = "bn254")]
impl FileFormat for Prover {
const FORMAT: [u8; 8] = crate::binary_format::PROVER_FORMAT;
const EXTENSION: &'static str = "pkp";
const VERSION: (u16, u16) = crate::binary_format::PROVER_VERSION;
const COMPRESSION: Compression = Compression::Xz;
}

#[cfg(feature = "bn254")]
impl FileFormat for Verifier {
const FORMAT: [u8; 8] = crate::binary_format::VERIFIER_FORMAT;
const EXTENSION: &'static str = "pkv";
const VERSION: (u16, u16) = crate::binary_format::VERIFIER_VERSION;
const COMPRESSION: Compression = Compression::Zstd;
}

#[cfg(feature = "bn254")]
impl FileFormat for NoirProof {
const FORMAT: [u8; 8] = crate::binary_format::NOIR_PROOF_FORMAT;
const EXTENSION: &'static str = "np";
Expand Down
Loading
Loading