-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from anoma/xuyang/circuit_bench
circuit benchmark
- Loading branch information
Showing
6 changed files
with
103 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Used by "mix format" | ||
[ | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"], | ||
inputs: ["{mix,.formatter}.exs", "{config,lib,test,bench}/**/*.{ex,exs}"], | ||
line_length: 78 | ||
] |
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 |
---|---|---|
@@ -1,24 +1,19 @@ | ||
# Cairo | ||
**TODO: Add description** | ||
|
||
# Cairo API Doc | ||
|
||
[CairoProver Doc](./native/cairo_prover/README.md) | ||
|
||
[CairoVM Doc](./native/cairo_vm/README.md) | ||
|
||
**TODO: Add description** | ||
|
||
## Installation | ||
|
||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed | ||
by adding `cairo` to your list of dependencies in `mix.exs`: | ||
# Benchmark | ||
|
||
```elixir | ||
def deps do | ||
[ | ||
{:cairo, "~> 0.1.0"} | ||
] | ||
end | ||
## Complaince circuit | ||
```bash | ||
mix run bench/compliance_circuit_bench.exs | ||
``` | ||
|
||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) | ||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can | ||
be found at <https://hexdocs.pm/cairo>. | ||
## Logic circuit | ||
```shell | ||
mix run bench/logic_circuit_bench.exs | ||
``` |
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,42 @@ | ||
{:ok, program} = File.read("./native/cairo_vm/compliance.json") | ||
{:ok, input} = File.read("./native/cairo_vm/compliance_input.json") | ||
|
||
{_output, trace, memory, public_inputs} = | ||
Cairo.cairo_vm_runner( | ||
program, | ||
input | ||
) | ||
|
||
# Prove and verify | ||
{proof, public_input} = Cairo.prove(trace, memory, public_inputs) | ||
# Cairo.verify(proof, public_input) | ||
|
||
Benchee.run( | ||
%{ | ||
"compliance circuit: run cairo vm" => fn -> | ||
Cairo.cairo_vm_runner(program, input) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) | ||
|
||
Benchee.run( | ||
%{ | ||
"compliance circuit: prover" => fn -> | ||
Cairo.prove(trace, memory, public_inputs) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) | ||
|
||
Benchee.run( | ||
%{ | ||
"compliance circuit: verifier" => fn -> | ||
Cairo.verify(proof, public_input) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) |
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,44 @@ | ||
{:ok, program} = File.read("./native/cairo_vm/trivial_resource_logic.json") | ||
|
||
{:ok, input} = | ||
File.read("./native/cairo_vm/trivial_resource_logic_input.json") | ||
|
||
{_output, trace, memory, public_inputs} = | ||
Cairo.cairo_vm_runner( | ||
program, | ||
input | ||
) | ||
|
||
# Prove and verify | ||
{proof, public_input} = Cairo.prove(trace, memory, public_inputs) | ||
# Cairo.verify(proof, public_input) | ||
|
||
Benchee.run( | ||
%{ | ||
"logic circuit: run cairo vm" => fn -> | ||
Cairo.cairo_vm_runner(program, input) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) | ||
|
||
Benchee.run( | ||
%{ | ||
"logic circuit: prover" => fn -> | ||
Cairo.prove(trace, memory, public_inputs) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) | ||
|
||
Benchee.run( | ||
%{ | ||
"logic circuit: verifier" => fn -> | ||
Cairo.verify(proof, public_input) | ||
end | ||
}, | ||
warmup: 1, | ||
time: 10 | ||
) |
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