-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
477 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use core::circuit::{ | ||
RangeCheck96, AddMod, MulMod, u96, CircuitElement, CircuitInput, circuit_add, | ||
circuit_sub, circuit_mul, circuit_inverse, EvalCircuitTrait, u384, | ||
CircuitOutputsTrait, CircuitModulus, AddInputResultTrait, CircuitInputs, | ||
}; | ||
|
||
fn main() -> u384 { | ||
let in1 = CircuitElement::<CircuitInput<0>> {}; | ||
let in2 = CircuitElement::<CircuitInput<1>> {}; | ||
let add1 = circuit_add(in1, in2); | ||
let mul1 = circuit_mul(add1, in1); | ||
let mul2 = circuit_mul(mul1, add1); | ||
let inv1 = circuit_inverse(mul2); | ||
let sub1 = circuit_sub(inv1, in2); | ||
let sub2 = circuit_sub(sub1, mul2); | ||
let inv2 = circuit_inverse(sub2); | ||
let add2 = circuit_add(inv2, inv2); | ||
|
||
let modulus = TryInto::<_, CircuitModulus>::try_into([17, 14, 14, 14]).unwrap(); | ||
|
||
let outputs = (add2,) | ||
.new_inputs() | ||
.next([9, 2, 9, 3]) | ||
.next([5, 7, 0, 8]) | ||
.done() | ||
.eval(modulus) | ||
.unwrap(); | ||
|
||
outputs.get_output(add2) | ||
} |
40 changes: 40 additions & 0 deletions
40
cairo_programs/cairo-1-programs/serialized_output/circuit.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use core::circuit::{ | ||
RangeCheck96, AddMod, MulMod, u96, CircuitElement, CircuitInput, circuit_add, | ||
circuit_sub, circuit_mul, circuit_inverse, EvalCircuitTrait, u384, | ||
CircuitOutputsTrait, CircuitModulus, AddInputResultTrait, CircuitInputs, | ||
}; | ||
use array::ArrayTrait; | ||
|
||
fn main() -> Array<felt252> { | ||
let in1 = CircuitElement::<CircuitInput<0>> {}; | ||
let in2 = CircuitElement::<CircuitInput<1>> {}; | ||
let add1 = circuit_add(in1, in2); | ||
let mul1 = circuit_mul(add1, in1); | ||
let mul2 = circuit_mul(mul1, add1); | ||
let inv1 = circuit_inverse(mul2); | ||
let sub1 = circuit_sub(inv1, in2); | ||
let sub2 = circuit_sub(sub1, mul2); | ||
let inv2 = circuit_inverse(sub2); | ||
let add2 = circuit_add(inv2, inv2); | ||
|
||
let modulus = TryInto::<_, CircuitModulus>::try_into([17, 14, 14, 14]).unwrap(); | ||
|
||
let outputs = (add2,) | ||
.new_inputs() | ||
.next([9, 2, 9, 3]) | ||
.next([5, 7, 0, 8]) | ||
.done() | ||
.eval(modulus) | ||
.unwrap(); | ||
|
||
let circuit_output = outputs.get_output(add2); | ||
|
||
let mut output: Array<felt252> = ArrayTrait::new(); | ||
|
||
circuit_output.limb0.serialize(ref output); | ||
circuit_output.limb1.serialize(ref output); | ||
circuit_output.limb2.serialize(ref output); | ||
circuit_output.limb3.serialize(ref output); | ||
|
||
output | ||
} |
Oops, something went wrong.