Skip to content
Draft
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
54 changes: 52 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion circom-prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"]
Expand Down Expand Up @@ -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 }

Expand Down
19 changes: 19 additions & 0 deletions circom-prover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -39,6 +42,22 @@ impl CircomProver {
pub fn verify(proof_lib: ProofLib, proof: CircomProof, zkey_path: String) -> Result<bool> {
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<String> {
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<bool> {
ark_circom_witnesscalc::verify_proof_json(vkey_json, proof_json)
}
}

#[cfg(test)]
Expand Down