Context
From PR #246 review (@ashpect):
The Prove trait currently has cfg-gated methods that change the API surface between native and WASM targets:
pub trait Prove {
#[cfg(all(feature = "witness-generation", not(target_arch = "wasm32")))]
fn prove(self, input_map: InputMap) -> Result<NoirProof>;
#[cfg(all(feature = "witness-generation", not(target_arch = "wasm32")))]
fn prove_with_toml(self, prover_toml: impl AsRef<Path>) -> Result<NoirProof>;
fn prove_with_witness(self, witness: WitnessMap<NoirElement>) -> Result<NoirProof>;
}
Generic code written on native that calls .prove() will fail to compile on WASM with a confusing "method not found" error.
Proposed Change
Split into a stable base trait and a native-only extension:
/// Always available (including WASM)
pub trait Prove {
fn prove_with_witness(self, witness: WitnessMap<NoirElement>) -> Result<NoirProof>;
}
/// Native-only extension
#[cfg(not(target_arch = "wasm32"))]
pub trait ProveFromInput: Prove {
fn prove(self, input_map: InputMap) -> Result<NoirProof>;
fn prove_with_toml(self, prover_toml: impl AsRef<Path>) -> Result<NoirProof>;
}
Also noted: the double-gating #[cfg(all(feature = "witness-generation", not(target_arch = "wasm32")))] is redundant — the WASM Cargo.toml already uses default-features = false which excludes witness-generation. The feature flag alone should suffice.
Impact
- All callers of
.prove() and .prove_with_toml() would need to import ProveFromInput instead of Prove
- No behavioral change, purely a type-system improvement