diff --git a/Cargo.lock b/Cargo.lock index 1f61c3581..3895588b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,6 +251,27 @@ dependencies = [ "ark-std 0.5.0", ] +[[package]] +name = "ark-circom-witnesscalc" +version = "0.1.0" +source = "git+https://github.com/HarryR/ark-circom-witnesscalc.git#590afa5d354be1ff5eaa2d16bf3831c15614e1f8" +dependencies = [ + "anyhow", + "ark-bn254", + "ark-crypto-primitives", + "ark-ec", + "ark-ff 0.5.0", + "ark-groth16", + "ark-relations", + "ark-serialize 0.5.0", + "ark-std 0.5.0", + "byteorder", + "circom-witnesscalc 0.2.2", + "hex", + "serde", + "serde_json", +] + [[package]] name = "ark-crypto-primitives" version = "0.5.0" @@ -1119,11 +1140,12 @@ dependencies = [ [[package]] name = "circom-prover" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "ark-bls12-381", "ark-bn254", + "ark-circom-witnesscalc", "ark-crypto-primitives", "ark-ec", "ark-ff 0.5.0", @@ -1133,7 +1155,7 @@ dependencies = [ "ark-serialize 0.5.0", "ark-std 0.5.0", "byteorder", - "circom-witnesscalc", + "circom-witnesscalc 0.2.1", "hex-literal", "num", "num-bigint", @@ -1177,6 +1199,34 @@ dependencies = [ "wtns-file", ] +[[package]] +name = "circom-witnesscalc" +version = "0.2.2" +source = "git+https://github.com/HarryR/circom-witnesscalc#40cfe1e641b267265dd252921de78b52915ed3fc" +dependencies = [ + "anyhow", + "ark-bn254", + "ark-ff 0.5.0", + "ark-serialize 0.5.0", + "bindgen", + "byteorder", + "indicatif", + "libc", + "memmap2", + "num-bigint", + "num-traits", + "prost", + "prost-build", + "rand 0.8.5", + "ruint", + "serde", + "serde_json", + "tempfile", + "thiserror 2.0.16", + "winnow 0.7.12", + "wtns-file", +] + [[package]] name = "clang-sys" version = "1.8.1" diff --git a/circom-prover/Cargo.toml b/circom-prover/Cargo.toml index 34c69b2d0..3d5b69d0f 100644 --- a/circom-prover/Cargo.toml +++ b/circom-prover/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "circom-prover" -version = "0.1.2" +version = "0.1.3" edition = "2021" description = "Circom prover is a Rust library for generating and verifying proofs for Circom circuits." license = "MIT OR Apache-2.0" @@ -16,6 +16,11 @@ name = "circom_prover" default = ["rustwitness", "arkworks"] beta = ["witnesscalc", "rapidsnark"] +ark-circom-witnesscalc = [ + "dep:ark-circom-witnesscalc", + "arkworks" +] + # Witness Generation rustwitness = ["rust-witness"] witnesscalc = ["witnesscalc-adapter"] @@ -87,6 +92,8 @@ ark-poly = { version = "=0.5.0", default-features = false, features = [ ], optional = true } rand = { version = "0.8", features = ["std"] } +ark-circom-witnesscalc = { git = "https://github.com/HarryR/ark-circom-witnesscalc.git", optional = true } + # witnesscalc-adapter witnesscalc-adapter = { version = "0.1", optional = true } diff --git a/circom-prover/src/lib.rs b/circom-prover/src/lib.rs index 467ae183e..d7d83a528 100644 --- a/circom-prover/src/lib.rs +++ b/circom-prover/src/lib.rs @@ -13,6 +13,9 @@ use witness::WitnessFn; #[cfg(feature = "witnesscalc")] pub use witnesscalc_adapter; +#[cfg(feature = "ark-circom-witnesscalc")] +pub use ark_circom_witnesscalc; + #[cfg(feature = "circom-witnesscalc")] #[doc(hidden)] pub mod __macro_deps { @@ -39,6 +42,22 @@ impl CircomProver { pub fn verify(proof_lib: ProofLib, proof: CircomProof, zkey_path: String) -> Result { prover::verify(proof_lib, zkey_path, proof) } + + #[cfg(feature = "ark-circom-witnesscalc")] + pub fn prove_to_json( + json_input_str: &str, + ark_pkey_data: &[u8], + cwc_graph_data: &[u8], + r1cs_data: &[u8], + ) -> Result { + let (proof, public_inputs) = ark_circom_witnesscalc::proof_oneshot(json_input_str, ark_pkey_data, cwc_graph_data, r1cs_data); + ark_circom_witnesscalc::proof_to_json(&proof, &public_inputs) + } + + #[cfg(feature = "ark-circom-witnesscalc")] + pub fn verify_json(vkey_json: &str, proof_json: &str) -> Result { + ark_circom_witnesscalc::verify_proof_json(vkey_json, proof_json) + } } #[cfg(test)]