From de330bd50b95ded551df7584d34f53cd854ae245 Mon Sep 17 00:00:00 2001 From: oskarth Date: Wed, 1 Nov 2023 12:47:08 +0800 Subject: [PATCH] chore(core): Mock public inputs in generate_proof for now --- mopro-core/src/middleware/circom/mod.rs | 29 +++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mopro-core/src/middleware/circom/mod.rs b/mopro-core/src/middleware/circom/mod.rs index 19100d15..3f3757e2 100644 --- a/mopro-core/src/middleware/circom/mod.rs +++ b/mopro-core/src/middleware/circom/mod.rs @@ -134,9 +134,9 @@ pub fn witness_calculator() -> &'static Mutex { }) } -// TODO: Generate proof using zkey -// (inputs: CircuitInputs) -> Result<(SerializableProof, SerializableInputs), MoproError> { -pub fn generate_proof2(inputs: CircuitInputs) -> Result { +pub fn generate_proof2( + inputs: CircuitInputs, +) -> Result<(SerializableProof, SerializableInputs), MoproError> { let mut rng = thread_rng(); let rng = &mut rng; @@ -152,6 +152,25 @@ pub fn generate_proof2(inputs: CircuitInputs) -> Result(inputs, false) .map_err(|e| MoproError::CircomError(e.to_string()))?; + // FIXME: Mock inputs + let public_inputs = vec![Fr::from(0)]; + + // TODO: Get public inputs + // NOTE: Here's what we do to get public inputs with ark-circom + // pub fn get_public_inputs(&self) -> Option> { + // match &self.witness { + // None => None, + // Some(w) => match &self.r1cs.wire_mapping { + // None => Some(w[1..self.r1cs.num_inputs].to_vec()), + // Some(m) => Some(m[1..self.r1cs.num_inputs].iter().map(|i| w[*i]).collect()), + // }, + // } + // } + // + // In or case we have: + // zkey.1.num_instance_variables contains number of instance variables + // We need to extract the public inputs from the full assignment + println!("Witness generation took: {:.2?}", now.elapsed()); let now = std::time::Instant::now(); @@ -174,9 +193,11 @@ pub fn generate_proof2(inputs: CircuitInputs) -> Result Self { Self {