Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed May 9, 2024
1 parent 16de04d commit ae52138
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use serde::{Deserialize, Serialize};
use sim_circuit::circuit::{Circuit as SimCircuit, Gate as SimGate, Node as SimNode, Operation};
use std::collections::HashMap;
use thiserror::Error;
use sim_circuit::circuit::CircuitError as SimCircuitError;

/// Types of gates that can be used in an arithmetic circuit.
#[derive(Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -446,14 +447,14 @@ impl ArithmeticCircuit {
{
new_node.set_value(value);
}
sim_circuit.add_node(id, new_node);
sim_circuit.add_node(id, new_node)?;
}

// Add gates
for gate in &self.gates {
let operation = Operation::from(&gate.op);
let sim_gate = SimGate::new(operation, gate.lh_in, gate.rh_in, gate.out);
sim_circuit.add_gate(sim_gate);
sim_circuit.add_gate(sim_gate)?;
}

Ok(sim_circuit)
Expand Down Expand Up @@ -528,6 +529,8 @@ pub enum CircuitError {
MPZCircuitError(MpzCircuitError),
#[error("MPZ arithmetic circuit builder error")]
MPZCircuitBuilderError,
#[error("Circuit simulation error")]
SimCircuitError(SimCircuitError),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error("Signal already declared")]
Expand All @@ -549,3 +552,9 @@ impl From<MpzCircuitError> for CircuitError {
CircuitError::MPZCircuitError(e)
}
}

impl From<SimCircuitError> for CircuitError {
fn from(e: SimCircuitError) -> Self {
CircuitError::SimCircuitError(e)
}
}
2 changes: 1 addition & 1 deletion tests/mat_elem_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const TEST_FILE_PATH: &str = "./tests/circuits/matElemMul.circom";
fn test_matrix_element_multiplication() {
let input = Input::new(TEST_FILE_PATH.into(), "./".into()).unwrap();
let circuit = build_circuit(&input).unwrap();
let mut sim_circuit = circuit.build_sim_circuit().unwrap();
let sim_circuit = circuit.build_sim_circuit().unwrap();

let circuit_input = vec![2, 2, 2, 2, 2, 2, 2, 2];
let res = sim_circuit.execute(&circuit_input).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const TEST_FILE_PATH: &str = "./tests/circuits/sum.circom";
fn test_sum() {
let input = Input::new(TEST_FILE_PATH.into(), "./".into()).unwrap();
let circuit = build_circuit(&input).unwrap();
let mut sim_circuit = circuit.build_sim_circuit().unwrap();
let sim_circuit = circuit.build_sim_circuit().unwrap();

let circuit_input = vec![1, 2];
let res = sim_circuit.execute(&circuit_input).unwrap();
Expand Down

0 comments on commit ae52138

Please sign in to comment.