Skip to content

Commit

Permalink
Merge branch 'xuyang/integrate_cairo_runner' into base
Browse files Browse the repository at this point in the history
  • Loading branch information
mariari committed May 6, 2024
2 parents 8d9be61 + 9093227 commit 32e9adb
Show file tree
Hide file tree
Showing 26 changed files with 154 additions and 2,349 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Cairo

[CairoProver Doc](./native/cairo_prover/README.md)

[CairoVM Doc](./native/cairo_vm/README.md)

**TODO: Add description**

## Installation
Expand Down
12 changes: 10 additions & 2 deletions lib/cairo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@ defmodule Cairo do
:world
end

@spec cairo_vm_runner(list(byte()), list(byte())) ::
{list(byte()), list(byte())}
defdelegate cairo_vm_runner(program_content, program_input),
to: Cairo.CairoVM,
as: :cairo_vm_runner

@spec prove(list(byte()), list(byte())) :: {list(byte()), list(byte())}
defdelegate prove(trace, memory), to: Cairo.Cairo0, as: :cairo_prove
defdelegate prove(trace, memory), to: Cairo.CairoProver, as: :cairo_prove

@spec verify(list(byte()), list(byte())) :: boolean()
defdelegate verify(proof, pub_input), to: Cairo.Cairo0, as: :cairo_verify
defdelegate verify(proof, pub_input),
to: Cairo.CairoProver,
as: :cairo_verify
end
19 changes: 9 additions & 10 deletions lib/cairo/cairo0.ex → lib/cairo/cairo.ex
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
defmodule Cairo.Cairo0 do
defmodule Cairo.CairoProver do
use Rustler,
otp_app: :cairo,
crate: :cairo
crate: :cairo_prover

@moduledoc """
Documentation for `Cairo`.
Documentation for `CairoProver`.
"""

# When loading a NIF module, dummy clauses for all NIF function are required.
# NIF dummies usually just error out when called when the NIF is not loaded, as that should never normally happen.
@spec cairo0_run_and_prove(binary()) :: {list(byte()), list(byte())}
@spec cairo_prove(list(byte()), list(byte())) ::
{list(byte()), list(byte())}
@spec cairo_verify(list(byte()), list(byte())) :: boolean()

def cairo0_run_and_prove(_program), do: :erlang.nif_error(:nif_not_loaded)
def cairo_prove(_trace, _memory), do: :erlang.nif_error(:nif_not_loaded)
def cairo_verify(_proof, _pub_input), do: :erlang.nif_error(:nif_not_loaded)
end

defmodule Cairo.Cairo1 do
defmodule Cairo.CairoVM do
use Rustler,
otp_app: :cairo,
crate: :cairo1
crate: :cairo_vm

@moduledoc """
Documentation for `Cairo1`.
Documentation for `CairoVM`.
"""

# When loading a NIF module, dummy clauses for all NIF function are required.
# NIF dummies usually just error out when called when the NIF is not loaded, as that should never normally happen.
@spec cairo1_vm_runner(binary(), binary()) :: {list(byte()), list(byte())}
@spec cairo_vm_runner(binary(), binary()) :: {list(byte()), list(byte())}

def cairo1_vm_runner(_path, _inputs), do: :erlang.nif_error(:nif_not_loaded)
def cairo_vm_runner(_program_content, _program_inputs),
do: :erlang.nif_error(:nif_not_loaded)
end
Loading

0 comments on commit 32e9adb

Please sign in to comment.