Get rid of warnings; fmt

This commit is contained in:
Oskar Thoren 2022-01-20 12:52:58 +08:00
parent ac4056b3de
commit a216612bed
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
3 changed files with 16 additions and 21 deletions

View File

@ -1,2 +1,2 @@
pub mod public;
pub mod ffi;
pub mod public;

View File

@ -8,7 +8,6 @@ use ark_groth16::{
};
fn groth16_proof_example() -> Result<()> {
let cfg = CircomConfig::<Bn254>::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"),
}
}

View File

@ -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<Bn254>,
params: ProvingKey<Bn254>
params: ProvingKey<Bn254>,
}
impl Multiplier {
@ -26,7 +22,8 @@ impl Multiplier {
let cfg = CircomConfig::<Bn254>::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::<Bn254, _, _>(circom, &mut rng)
.unwrap();
let params = generate_random_parameters::<Bn254, _, _>(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<W: Write>(&self, mut result_data: W) -> io::Result<()> {
pub fn prove<W: Write>(&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<R: Read>(&self, mut input_data: R) -> io::Result<bool> {
pub fn verify<R: Read>(&self, input_data: R) -> io::Result<bool> {
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<u8> = 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();