Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nargo)!: save program ABI alongside ACIR #922

Merged
merged 5 commits into from
Feb 27, 2023
Merged

Conversation

TomAFrench
Copy link
Member

Related issue(s)

Resolves #897

Description

Summary of changes

Rather than serializing a Circuit into a acir file, we now serialize a CompiledProgram (Circuit + Abi) into a json file.

We still make use of the custom serialisation method for Circuit however JSON doesn't store bytes directly so we end up with an array. We could fix this by just encoding the entire thing into bytes rather than using json atm (and allowing exporting a JSON ABI separately).

An example output (for the simple_shield circuit) is shown below:


{
  "circuit": [0, 0, 0, 0, 21, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 13,  /*snip*/ ],
  "abi": {
    "parameters": [
      {
        "name": "priv_key",
        "type": {
          "kind": "field"
        },
        "visibility": "private"
      },
      {
        "name": "note_root",
        "type": {
          "kind": "field"
        },
        "visibility": "public"
      },
      {
        "name": "index",
        "type": {
          "kind": "field"
        },
        "visibility": "private"
      },
      {
        "name": "note_hash_path",
        "type": {
          "kind": "array",
          "length": 3,
          "type": {
            "kind": "field"
          }
        },
        "visibility": "private"
      },
      {
        "name": "to_pubkey_x",
        "type": {
          "kind": "field"
        },
        "visibility": "private"
      },
      {
        "name": "to_pubkey_y",
        "type": {
          "kind": "field"
        },
        "visibility": "private"
      }
    ],
    "param_witnesses": {
      "index": [
        3
      ],
      "note_hash_path": [
        4,
        5,
        6
      ],
      "note_root": [
        2
      ],
      "priv_key": [
        1
      ],
      "to_pubkey_x": [
        7
      ],
      "to_pubkey_y": [
        8
      ]
    },
    "return_type": {
      "kind": "array",
      "length": 2,
      "type": {
        "kind": "field"
      }
    },
    "return_witnesses": [
      13,
      15
    ]
  }
}

Dependency additions / changes

Test additions / changes

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.
  • This PR requires documentation updates when merged.

Additional context

@TomAFrench TomAFrench changed the title feat!(nargo): save program ABI alongside ACIR feat(nargo)!: save program ABI alongside ACIR Feb 27, 2023
Copy link
Contributor

@kevaundray kevaundray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevaundray kevaundray added this pull request to the merge queue Feb 27, 2023
Merged via the queue into master with commit ddaf305 Feb 27, 2023
@kevaundray kevaundray deleted the save-program branch February 27, 2023 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save Noir ABI to disk
2 participants