1use anyhow::Result;
2use num::BigUint;
3use std::thread::JoinHandle;
4
5#[cfg(feature = "arkworks")]
6pub mod ark_circom;
7#[cfg(feature = "arkworks")]
8pub mod arkworks;
9#[cfg(feature = "ethereum")]
10pub mod ethereum;
11#[cfg(feature = "arkworks")]
12pub mod serialization;
13
14pub struct CircomProof {
15 pub proof: Vec<u8>,
16 pub pub_inputs: Vec<u8>,
17}
18
19#[derive(Debug, Clone, Copy)]
20pub enum ProofLib {
21 #[cfg(feature = "arkworks")]
22 Arkworks,
23 #[cfg(feature = "rapidsnark")]
24 RapidSnark,
25}
26
27pub fn prove(
28 lib: ProofLib,
29 zkey_path: String,
30 witnesses: JoinHandle<Vec<BigUint>>,
31) -> Result<CircomProof> {
32 match lib {
33 #[cfg(feature = "arkworks")]
34 ProofLib::Arkworks => arkworks::generate_circom_proof(zkey_path, witnesses),
35 #[cfg(feature = "rapidsnark")]
36 ProofLib::RapidSnark => panic!("Not supported yet."),
37 }
38}
39
40pub fn verify(
41 lib: ProofLib,
42 zkey_path: String,
43 proof: Vec<u8>,
44 public_inputs: Vec<u8>,
45) -> Result<bool> {
46 match lib {
47 #[cfg(feature = "arkworks")]
48 ProofLib::Arkworks => arkworks::verify_circom_proof(zkey_path, proof, public_inputs),
49 #[cfg(feature = "rapidsnark")]
50 ProofLib::RapidSnark => panic!("Not supported yet."),
51 }
52}