Serialize proof

This commit is contained in:
Oskar Thoren 2022-01-19 13:09:38 +08:00
parent b382046584
commit 78f3ce4fdd
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
2 changed files with 18 additions and 4 deletions

View File

@ -22,7 +22,7 @@ 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-serialize = { version = "0.3.0", default-features = false }
ark-circom = { git = "https://github.com/gakonst/ark-circom", features = ["circom-2"] }

View File

@ -9,6 +9,9 @@ use ark_groth16::{
prepare_verifying_key,
verify_proof
};
use ark_serialize::{CanonicalSerialize, CanonicalDeserialize, SerializationError};
use std::io::{self, Read, Write};
pub struct Multiplier {
@ -43,9 +46,20 @@ impl Multiplier {
Multiplier { circom, params }
}
// TODO Return proof
pub fn prove() -> bool {
false
// TODO Input Read
pub fn prove<W: Write>(&self, mut result_data: W) -> io::Result<()> {
let mut rng = thread_rng();
// XXX: There's probably a better way to do this
let circom = self.circom.clone();
let params = self.params.clone();
let proof = prove(circom, &params, &mut rng).unwrap();
// XXX: Unclear if this is different from other serialization(s)
let _ = proof.serialize(result_data).unwrap();
Ok(())
}
// TODO Return proof