Skip to content

Commit

Permalink
Add more props to the zkSaaS circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
shekohex committed Dec 18, 2023
1 parent b37a913 commit ec77b4f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pallets/zksaas/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use crate::{mock::*, types::FeeInfo, FeeInfo as FeeInfoStorage};
use ark_crypto_primitives::snark::{CircuitSpecificSetupSNARK, SNARK};
use ark_groth16::Groth16;
use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystem};
use ark_serialize::CanonicalSerialize;
use ark_std::{
rand::{Rng, RngCore, SeedableRng},
Expand Down Expand Up @@ -84,6 +85,10 @@ fn proof_verification_works() {
// Create an instance of our circuit (with the
// witness)
let c = mimc::MiMCDemo { xl: Some(xl), xr: Some(xr), constants: &constants };
let cs = ConstraintSystem::<F>::new_ref();
c.clone().generate_constraints(cs.clone()).unwrap();
let num_inputs = cs.num_instance_variables();
let num_constraints = cs.num_constraints();

// Create a groth16 proof with our parameters.
let proof = Groth16::<E>::prove(&pk, c, &mut rng).unwrap();
Expand All @@ -98,6 +103,8 @@ fn proof_verification_works() {
participants: vec![1, 2, 3, 4, 5, 6, 7, 8],
system: ZkSaaSSystem::Groth16(Groth16System {
circuit: HyperData::Raw(vec![]),
num_inputs: num_inputs as _,
num_constraints: num_constraints as _,
proving_key: HyperData::Raw(pk_bytes),
verifying_key: vk_bytes,
wasm: HyperData::Raw(vec![]),
Expand All @@ -110,7 +117,7 @@ fn proof_verification_works() {
request: ZkSaaSPhaseTwoRequest::Groth16(Groth16ProveRequest {
public_input: from_field_elements(&[image]).unwrap(),
a_shares: Default::default(),
ax: Default::default(),
ax_shares: Default::default(),
qap_shares: Default::default(),
}),
});
Expand Down Expand Up @@ -189,6 +196,7 @@ mod mimc {

/// This is our demo circuit for proving knowledge of the
/// preimage of a MiMC hash invocation.
#[derive(Clone)]
pub struct MiMCDemo<'a, F: Field> {
pub xl: Option<F>,
pub xr: Option<F>,
Expand Down
6 changes: 5 additions & 1 deletion primitives/src/types/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ pub enum ZkSaaSSystem {
pub struct Groth16System {
/// R1CS circuit file.
pub circuit: HyperData,
/// Number of inputs
pub num_inputs: u64,
/// Number of constraints
pub num_constraints: u64,
/// Proving key file.
pub proving_key: HyperData,
/// Verifying key bytes
Expand Down Expand Up @@ -134,7 +138,7 @@ pub struct Groth16ProveRequest {
/// `ax` is the auxiliary input
/// ax = full_assginment[num_inputs..]
/// Each element contains a PSS of the auxiliary input
pub ax: Vec<HyperData>,
pub ax_shares: Vec<HyperData>,
/// PSS of the QAP polynomials
pub qap_shares: Vec<QAPShare>,
}
Expand Down

0 comments on commit ec77b4f

Please sign in to comment.