Multiplier proof test

This commit is contained in:
Oskar Thoren 2022-01-19 12:19:25 +08:00
parent c96ab25bc6
commit b382046584
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
1 changed files with 23 additions and 2 deletions

View File

@ -2,8 +2,13 @@ use ark_circom::{CircomBuilder, CircomConfig, CircomCircuit};
use ark_std::rand::thread_rng; use ark_std::rand::thread_rng;
use ark_bn254::Bn254; use ark_bn254::Bn254;
use ark_groth16::generate_random_parameters; use ark_groth16::{
use ark_groth16::ProvingKey; ProvingKey,
generate_random_parameters,
create_random_proof as prove,
prepare_verifying_key,
verify_proof
};
pub struct Multiplier { pub struct Multiplier {
@ -48,3 +53,19 @@ impl Multiplier {
false false
} }
} }
#[test]
fn multiplier_proof() {
let mul = Multiplier::new();
let inputs = mul.circom.get_public_inputs().unwrap();
let mut rng = thread_rng();
let proof = prove(mul.circom, &mul.params, &mut rng).unwrap();
let pvk = prepare_verifying_key(&mul.params.vk);
let verified = verify_proof(&pvk, &proof, &inputs).unwrap();
assert!(verified);
}