mirror of https://github.com/vacp2p/zerokit.git
parent
9e1dc8f4c6
commit
fb81e32977
|
@ -6,4 +6,30 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
|
# WASM operations
|
||||||
|
# wasmer = { version = "2.0" }
|
||||||
|
# fnv = { version = "1.0.3", default-features = false }
|
||||||
|
# num = { version = "0.4.0" }
|
||||||
|
# num-traits = { version = "0.2.0", default-features = false }
|
||||||
|
num-bigint = { version = "0.4", default-features = false, features = ["rand"] }
|
||||||
|
|
||||||
|
# ZKP Generation
|
||||||
|
# ark-ec = { version = "0.3.0", default-features = false, features = ["parallel"] }
|
||||||
|
# ark-ff = { version = "0.3.0", default-features = false, features = ["parallel", "asm"] }
|
||||||
|
ark-std = { version = "0.3.0", default-features = false, features = ["parallel"] }
|
||||||
|
ark-bn254 = { version = "0.3.0" }
|
||||||
|
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", features = ["parallel"] }
|
||||||
|
# ark-poly = { version = "^0.3.0", default-features = false, features = ["parallel"] }
|
||||||
|
# ark-relations = { version = "0.3.0", default-features = false }
|
||||||
|
# ark-serialize = { version = "0.3.0", default-features = false }
|
||||||
|
|
||||||
ark-circom = { git = "https://github.com/gakonst/ark-circom", features = ["circom-2"] }
|
ark-circom = { git = "https://github.com/gakonst/ark-circom", features = ["circom-2"] }
|
||||||
|
|
||||||
|
# error handling
|
||||||
|
# thiserror = "1.0.26"
|
||||||
|
color-eyre = "0.5"
|
||||||
|
|
||||||
|
# decoding of data
|
||||||
|
# hex = "0.4.3"
|
||||||
|
# byteorder = "1.4.3"
|
||||||
|
|
|
@ -1,3 +1,49 @@
|
||||||
|
use ark_circom::{CircomBuilder, CircomConfig};
|
||||||
|
use ark_std::rand::thread_rng;
|
||||||
|
use color_eyre::Result;
|
||||||
|
|
||||||
|
use ark_bn254::Bn254;
|
||||||
|
use ark_groth16::{
|
||||||
|
create_random_proof as prove, generate_random_parameters, prepare_verifying_key, verify_proof,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn groth16_proof_example() -> Result<()> {
|
||||||
|
|
||||||
|
let cfg = CircomConfig::<Bn254>::new(
|
||||||
|
"./resources/circom2_multiplier2.wasm",
|
||||||
|
"./resources/circom2_multiplier2.r1cs",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
let mut builder = CircomBuilder::new(cfg);
|
||||||
|
builder.push_input("a", 3);
|
||||||
|
builder.push_input("b", 11);
|
||||||
|
|
||||||
|
// create an empty instance for setting it up
|
||||||
|
let circom = builder.setup();
|
||||||
|
|
||||||
|
let mut rng = thread_rng();
|
||||||
|
let params = generate_random_parameters::<Bn254, _, _>(circom, &mut rng)?;
|
||||||
|
|
||||||
|
let circom = builder.build()?;
|
||||||
|
|
||||||
|
let inputs = circom.get_public_inputs().unwrap();
|
||||||
|
|
||||||
|
let proof = prove(circom, ¶ms, &mut rng)?;
|
||||||
|
|
||||||
|
let pvk = prepare_verifying_key(¶ms.vk);
|
||||||
|
|
||||||
|
let verified = verify_proof(&pvk, &proof, &inputs)?;
|
||||||
|
|
||||||
|
assert!(verified);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
match groth16_proof_example() {
|
||||||
|
Ok(_) => println!("Success"),
|
||||||
|
Err(_) => println!("Error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue