User workflow for submitting shielded (Cairo) transactions

This post contains a summary of a discussion between @Lukasz, @xuyang and @ArtemG.

To create and submit a shielded Cairo transaction, the user will need to do the following steps.

  1. Compile Juvix circuit(s) to Cairo bytecode. This is already implemented in the Juvix compiler:
juvix compile cairo circuit.juvix

The result is a circuit.json file which contains Cairo bytecode in a format expected by the Cairo VM. We never need to read or interpret it, we can effectively treat it as a blob. Do we need to put it somewhere (in local storage)?

  1. Compile the Juvix app to Nock and execute it to create the Transaction. The compiled app needs access to:
    a. Cairo bytecode of the circuit(s)
    b. circuit(s) (private) inputs
    • the app should manipulate / create them as a Juvix record (a Nock data structure on the compiled Nock level)
    • this record needs to be converted to JSON format appropriate for the Cairo VM. Perhaps it’s best to do this conversion on the Elixir level, so that it’s transparent to the user.
      Caveat: the JSON format used by the Cairo VM is non-standard - the order of fields in the objects is significant, e.g., {"A": 2, "B": 7} and {"B": 7, "A": 2} are not the same.
      To create the Transaction, the app should call the create_from_compliance_units() Elixir function which needs to be exposed in the Nock standard library.

In addition to the logics (compiled circuits Cairo bytecode) and private inputs (logic witnesses), the create_from_compliance_units() function needs the data currently stored in “compliance unit” JSON files, e.g., anoma/apps/anoma_lib/priv/params/compliance1_inputs.json at 4ee43721a41ce41b44842c82d7bb2298f44f50f5 · anoma/anoma · GitHub. It is the responsibility of the app to know how to create this data. The data needs to be manipulated by the Juvix app program, and passed to the exposed create_from_compliance_units() function in Nock format, which may later be converted to JSON on the Elixir side if needed.

Perhaps we need to also expose transaction composition (Transaction.compose) to be able to create transactions with multiple actions? The create_from_compliance_units() function can only create transactions with a single action.

  1. Submit the created Transaction(s).
2 Likes