Skip to content

Commit

Permalink
add the verifiable encryption bench
Browse files Browse the repository at this point in the history
  • Loading branch information
XuyangSong committed Dec 2, 2024
1 parent a5a2778 commit 3c369d2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ mix run bench/compliance_circuit_bench.exs
```shell
mix run bench/logic_circuit_bench.exs
```

## Verifiable Encryption bench
```shell
mix run bench/verifiable_encryption_bench.exs
```
57 changes: 57 additions & 0 deletions bench/verifiable_encryption_bench.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{:ok, program} = File.read("./juvix/encryption.json")

{:ok, input} =
File.read("./juvix/encryption_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)

sk = :binary.bin_to_list(<<1::256>>)

cipher = Cairo.get_output(public_input)

Benchee.run(
%{
"encryption circuit: run cairo vm" => fn ->
Cairo.cairo_vm_runner(program, input)
end
},
warmup: 1,
time: 10
)

Benchee.run(
%{
"encryption circuit: prover" => fn ->
Cairo.prove(trace, memory, public_inputs)
end
},
warmup: 1,
time: 10
)

Benchee.run(
%{
"encryption circuit: verifier" => fn ->
Cairo.verify(proof, public_input)
end
},
warmup: 1,
time: 10
)

Benchee.run(
%{
"decryption" => fn ->
Cairo.decrypt(cipher, sk)
end
},
warmup: 1,
time: 10
)

0 comments on commit 3c369d2

Please sign in to comment.