From c03ae8490fcba1ad5e0399dcbf40c6acc943a5c1 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Mon, 26 Jul 2021 18:13:46 +0300 Subject: [PATCH] chore: trim deps --- Cargo.toml | 36 ++++++++++++++++++------------------ README.md | 35 +++++++++++++++++++++++++++++++++++ src/ethereum.rs | 2 +- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0eec769..9ec4276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,34 +5,34 @@ edition = "2018" [dependencies] # WASM operations -wasmer = "1.0.1" -fnv = "1.0.3" -num-traits = "0.2.0" -num-bigint = { version = "0.4", features = ["rand"] } - - -color-eyre = "0.5" +wasmer = { version = "2.0" } +fnv = { version = "1.0.3", default-features = false } +num-traits = { version = "0.2.0", default-features = false } +num-bigint = { version = "0.4", default-features = false, features = ["rand"] } # ZKP Generation -ark-ec = "0.3.0" -ark-ff = "0.3.0" -ark-std = "0.3.0" -ark-bn254 = "0.3.0" -ark-r1cs-std = "0.3.1" +ark-ec = { version = "0.3.0", default-features = false } +ark-ff = { version = "0.3.0", default-features = false } +ark-std = { version = "0.3.0", default-features = false } +ark-bn254 = { version = "0.3.0" } ark-groth16 = { git = "https://github.com/kobigurk/groth16", version = "0.3.0", branch = "feat/customizable-r1cs-to-qap" } ark-poly = { version = "^0.3.0", default-features = false } -ark-relations = "0.3.0" +ark-relations = { version = "0.3.0", default-features = false } +ark-serialize = { version = "0.3.0", default-features = false } +# decoding of data hex = "0.4.3" byteorder = "1.4.3" -ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"] } -serde_json = "1.0.64" -serde = "1.0.126" +# ethereum compat +ethers-core = { git = "https://github.com/gakonst/ethers-rs", default-features = false } + +# error handling thiserror = "1.0.26" -ark-serialize = "0.3.0" +color-eyre = "0.5" [dev-dependencies] hex-literal = "0.2.1" tokio = { version = "1.7.1", features = ["macros"] } - +serde_json = "1.0.64" +ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["abigen"] } diff --git a/README.md b/README.md index 1d9378f..61b07d4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,41 @@ Clone the repository and run `cd ark-circom/ && cargo doc --open` ark-circom = { git = "https://github.com/gakonst/ark-circom-rs" } ``` +## Example + +```rust +// Load the WASM and R1CS for witness and proof generation +let cfg = CircomConfig::::new( + "./test-vectors/mycircuit.wasm", + "./test-vectors/mycircuit.r1cs", +)?; + +// Insert our public inputs as key value pairs +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(); + +// Run a trusted setup +let mut rng = thread_rng(); +let params = generate_random_parameters::(circom, &mut rng)?; + +// Get the populated instance of the circuit with the witness +let circom = builder.build()?; + +let inputs = circom.get_public_inputs().unwrap(); + +// Generate the proof +let proof = prove(circom, ¶ms, &mut rng)?; + +// Check that the proof is valid +let pvk = prepare_verifying_key(¶ms.vk); +let verified = verify_proof(&pvk, &proof, &inputs)?; +assert!(verified); +``` + ## Running the tests Tests require the following installed: diff --git a/src/ethereum.rs b/src/ethereum.rs index e6f28a0..78d2c35 100644 --- a/src/ethereum.rs +++ b/src/ethereum.rs @@ -1,7 +1,7 @@ //! Helpers for converting Arkworks types to U256-tuples as expected by the //! Solidity Groth16 Verifier smart contracts use ark_ff::{BigInteger, FromBytes, PrimeField}; -use ethers::types::U256; +use ethers_core::types::U256; use ark_bn254::{Bn254, Fq2, Fr, G1Affine, G2Affine};