Skip to content

Commit

Permalink
Fix typos, fmt, and clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
winderica committed Nov 30, 2024
1 parent 6e5cd33 commit 0e02a2a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
3 changes: 2 additions & 1 deletion examples/noir_full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ fn main() {
Path::new("./frontends/src/noir/test_folder/test_mimc/target/test_mimc.json").into(),
1,
0,
)).unwrap();
))
.unwrap();

pub type N = Nova<G1, GVar, G2, GVar2, NoirFCircuit<Fr>, KZG<'static, Bn254>, Pedersen<G2>>;
pub type D = DeciderEth<
Expand Down
10 changes: 4 additions & 6 deletions frontends/src/noir/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::convert::TryInto;
use acvm::acir::{
acir_field::GenericFieldElement,
circuit::{Circuit, Opcode, PublicInputs},
native_types::{Witness, WitnessMap, Expression},
native_types::{Expression, Witness, WitnessMap},
};
use ark_ff::{Field, PrimeField};
use ark_r1cs_std::alloc::AllocVar;
Expand Down Expand Up @@ -58,12 +58,10 @@ impl<'a, ConstraintF: Field + PrimeField> ConstraintSynthesizer<ConstraintF>
} else {
return Err(SynthesisError::Unsatisfiable);
}
} else if self.public_inputs.contains(i.0.try_into().unwrap()) {
cs.new_witness_variable(|| Ok(*val))?
} else {
if self.public_inputs.contains(i.0.try_into().unwrap()) {
cs.new_witness_variable(|| Ok(*val))?
} else {
cs.new_witness_variable(|| Ok(*val))?
}
cs.new_witness_variable(|| Ok(*val))?
};
variables.push(var);
}
Expand Down
45 changes: 20 additions & 25 deletions frontends/src/noname/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ark_relations::r1cs::{
ConstraintSynthesizer, ConstraintSystemRef, LinearCombination, SynthesisError, Variable,
};
use noname::backends::{
r1cs::{GeneratedWitness, R1CS, LinearCombination as NoNameLinearCombination},
r1cs::{GeneratedWitness, LinearCombination as NoNameLinearCombination, R1CS},
BackendField,
};
use noname::witness::CompiledCircuit;
Expand Down Expand Up @@ -62,41 +62,36 @@ impl<'a, 'b, 'c, F: PrimeField, BF: BackendField> ConstraintSynthesizer<F>
idx_to_var.insert(idx, var);
z_i_pointer += 1;
}
} else if idx <= public_io_length + external_inputs_len {
// we are in the case of external inputs
// those have already been assigned at specific indexes
let var = match &self.assigned_external_inputs[external_inputs_pointer] {
FpVar::Var(allocated_fp) => allocated_fp.variable,
_ => return Err(SynthesisError::Unsatisfiable),
};
idx_to_var.insert(idx, var);
external_inputs_pointer += 1;
} else {
if idx <= public_io_length + external_inputs_len {
// we are in the case of external inputs
// those have already been assigned at specific indexes
let var = match &self.assigned_external_inputs[external_inputs_pointer] {
FpVar::Var(allocated_fp) => allocated_fp.variable,
_ => return Err(SynthesisError::Unsatisfiable),
};
idx_to_var.insert(idx, var);
external_inputs_pointer += 1;
} else {
// we are in the case of auxilary private inputs
// we need to assign those
let value: BigUint = Into::into(self.witness.witness[idx]);
let field_element = F::from(value);
let var = cs.new_witness_variable(|| Ok(field_element))?;
idx_to_var.insert(idx, var);
}
// we are in the case of auxiliary private inputs
// we need to assign those
let value: BigUint = Into::into(self.witness.witness[idx]);
let field_element = F::from(value);
let var = cs.new_witness_variable(|| Ok(field_element))?;
idx_to_var.insert(idx, var);
}
}

match (z_i_pointer == self.assigned_z_i.len())
&& (external_inputs_pointer == self.assigned_external_inputs.len())
if (z_i_pointer != self.assigned_z_i.len())
|| (external_inputs_pointer != self.assigned_external_inputs.len())
{
false => {
return Err(SynthesisError::AssignmentMissing);
}
true => {}
return Err(SynthesisError::AssignmentMissing);
}
let make_index = |index: usize| match index == 0 {
true => Ok(Variable::One),
false => {
let var = idx_to_var
.get(&index)
.ok_or_else(|| SynthesisError::AssignmentMissing)?;
.ok_or(SynthesisError::AssignmentMissing)?;
Ok(var.to_owned())
}
};
Expand Down
6 changes: 3 additions & 3 deletions frontends/src/noname/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ pub fn compile_source_code<BF: BackendField>(
let mut sources = Sources::new();

// parse the transitive dependency
let mut tast = TypeChecker::<R1CS<BF>>::new();
let mut checker = TypeChecker::<R1CS<BF>>::new();
let _ = typecheck_next_file(
&mut tast,
&mut checker,
None,
&mut sources,
"main.no".to_string(),
Expand All @@ -84,5 +84,5 @@ pub fn compile_source_code<BF: BackendField>(
.unwrap();
let r1cs = R1CS::<BF>::new();
// compile
CircuitWriter::generate_circuit(tast, r1cs)
CircuitWriter::generate_circuit(checker, r1cs)
}

0 comments on commit 0e02a2a

Please sign in to comment.