Skip to content

Commit

Permalink
chore(core): Mock public inputs in generate_proof for now
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarth committed Nov 2, 2023
1 parent 84de2da commit de330bd
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions mopro-core/src/middleware/circom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ pub fn witness_calculator() -> &'static Mutex<WitnessCalculator> {
})
}

// TODO: Generate proof using zkey
// (inputs: CircuitInputs) -> Result<(SerializableProof, SerializableInputs), MoproError> {
pub fn generate_proof2(inputs: CircuitInputs) -> Result<SerializableProof, MoproError> {
pub fn generate_proof2(
inputs: CircuitInputs,
) -> Result<(SerializableProof, SerializableInputs), MoproError> {
let mut rng = thread_rng();
let rng = &mut rng;

Expand All @@ -152,6 +152,25 @@ pub fn generate_proof2(inputs: CircuitInputs) -> Result<SerializableProof, Mopro
.calculate_witness_element::<Bn254, _>(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<Vec<E::ScalarField>> {
// 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();
Expand All @@ -174,9 +193,11 @@ pub fn generate_proof2(inputs: CircuitInputs) -> Result<SerializableProof, Mopro
println!("proof generation took: {:.2?}", now.elapsed());

// TODO: Add SerializableInputs(inputs)))
Ok(SerializableProof(proof))
Ok((SerializableProof(proof), SerializableInputs(public_inputs)))
}

// TODO: Write pub fn verify_proof2 function

impl CircomState {
pub fn new() -> Self {
Self {
Expand Down

0 comments on commit de330bd

Please sign in to comment.