From a216612bed48e6edcd151f91d196a7734c6fc6e5 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Thu, 20 Jan 2022 12:52:58 +0800 Subject: [PATCH] Get rid of warnings; fmt --- multiplier/src/lib.rs | 2 +- multiplier/src/main.rs | 3 +-- multiplier/src/public.rs | 32 ++++++++++++++------------------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/multiplier/src/lib.rs b/multiplier/src/lib.rs index 7950883..767579a 100644 --- a/multiplier/src/lib.rs +++ b/multiplier/src/lib.rs @@ -1,2 +1,2 @@ -pub mod public; pub mod ffi; +pub mod public; diff --git a/multiplier/src/main.rs b/multiplier/src/main.rs index b4dc5a8..c3f6176 100644 --- a/multiplier/src/main.rs +++ b/multiplier/src/main.rs @@ -8,7 +8,6 @@ use ark_groth16::{ }; fn groth16_proof_example() -> Result<()> { - let cfg = CircomConfig::::new( "./resources/circom2_multiplier2.wasm", "./resources/circom2_multiplier2.r1cs", @@ -44,6 +43,6 @@ fn main() { match groth16_proof_example() { Ok(_) => println!("Success"), - Err(_) => println!("Error") + Err(_) => println!("Error"), } } diff --git a/multiplier/src/public.rs b/multiplier/src/public.rs index 36425d3..2b46a9b 100644 --- a/multiplier/src/public.rs +++ b/multiplier/src/public.rs @@ -1,23 +1,19 @@ -use ark_circom::{CircomBuilder, CircomConfig, CircomCircuit}; +use ark_circom::{CircomBuilder, CircomCircuit, CircomConfig}; use ark_std::rand::thread_rng; use ark_bn254::Bn254; use ark_groth16::{ - ProvingKey, - Proof, - generate_random_parameters, - create_random_proof as prove, - prepare_verifying_key, - verify_proof, + create_random_proof as prove, generate_random_parameters, prepare_verifying_key, verify_proof, + Proof, ProvingKey, }; -use ark_serialize::{CanonicalSerialize, CanonicalDeserialize, SerializationError}; +use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; +// , SerializationError}; use std::io::{self, Read, Write}; - pub struct Multiplier { circom: CircomCircuit, - params: ProvingKey + params: ProvingKey, } impl Multiplier { @@ -26,7 +22,8 @@ impl Multiplier { let cfg = CircomConfig::::new( "./resources/circom2_multiplier2.wasm", "./resources/circom2_multiplier2.r1cs", - ).unwrap(); + ) + .unwrap(); let mut builder = CircomBuilder::new(cfg); builder.push_input("a", 3); @@ -37,18 +34,17 @@ impl Multiplier { let mut rng = thread_rng(); - let params = generate_random_parameters::(circom, &mut rng) - .unwrap(); + let params = generate_random_parameters::(circom, &mut rng).unwrap(); let circom = builder.build().unwrap(); - let inputs = circom.get_public_inputs().unwrap(); + //let inputs = circom.get_public_inputs().unwrap(); Multiplier { circom, params } } // TODO Input Read - pub fn prove(&self, mut result_data: W) -> io::Result<()> { + pub fn prove(&self, result_data: W) -> io::Result<()> { let mut rng = thread_rng(); // XXX: There's probably a better way to do this @@ -63,7 +59,7 @@ impl Multiplier { Ok(()) } - pub fn verify(&self, mut input_data: R) -> io::Result { + pub fn verify(&self, input_data: R) -> io::Result { let proof = Proof::deserialize(input_data).unwrap(); let pvk = prepare_verifying_key(&self.params.vk); @@ -80,14 +76,14 @@ impl Multiplier { #[test] fn multiplier_proof() { let mul = Multiplier::new(); - let inputs = mul.circom.get_public_inputs().unwrap(); - + //let inputs = mul.circom.get_public_inputs().unwrap(); let mut output_data: Vec = Vec::new(); let _ = mul.prove(&mut output_data); let proof_data = &output_data[..]; + // XXX Pass as arg? //let pvk = prepare_verifying_key(&mul.params.vk); let verified = mul.verify(proof_data).unwrap();