Skip to content

Commit

Permalink
fix: infix operation handling (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
brech1 authored Jan 10, 2024
1 parent 25ec383 commit 50a40c1
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 332 deletions.
22 changes: 5 additions & 17 deletions src/assets/circuit.circom
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
pragma circom 2.0.0;

template InnerProd () {

// Declaration of signals
signal input input_A[3];
signal input input_B[3];
signal input input_A;
signal input input_B;
signal output ip;

signal sum[3];

sum[0] <== input_A[0]*input_B[0];

// for (var i = 1; i < 3; i++) {
// sum[i] <== sum[i-1] + input_A[i] * input_B[i];
// }

// var sum = 0;
var variable_A;

// for (var i = 0; i < 3; i++) {
// sum = sum + input_A[i]*input_B[i];
// }
variable_A = 100;

ip <== sum[2];
ip <== input_A + input_B + variable_A;
}

component main = InnerProd();
33 changes: 17 additions & 16 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ pub struct ArithmeticVar {
}

impl ArithmeticVar {
pub fn new(_var_id: u32, _var_name: String) -> ArithmeticVar {
ArithmeticVar {
var_id: _var_id,
var_name: _var_name,
pub fn new(var_id: u32, var_name: String) -> Self {
Self {
var_id,
var_name,
is_const: false,
const_value: 0,
}
Expand All @@ -100,19 +100,20 @@ pub struct ArithmeticNode {
}

impl ArithmeticNode {
/// Creates a new arithmetic node.
pub fn new(
_gate_id: u32,
_gate_type: AGateType,
_input_lhs_id: u32,
_input_rhs_id: u32,
_out_put_id: u32,
) -> ArithmeticNode {
ArithmeticNode {
gate_id: _gate_id,
gate_type: _gate_type,
input_lhs_id: _input_lhs_id,
input_rhs_id: _input_rhs_id,
output_id: _out_put_id,
gate_id: u32,
gate_type: AGateType,
input_lhs_id: u32,
input_rhs_id: u32,
output_id: u32,
) -> Self {
Self {
gate_id,
gate_type,
input_lhs_id,
input_rhs_id,
output_id,
}
}
}
Expand Down
Loading

0 comments on commit 50a40c1

Please sign in to comment.