Skip to content

Add methods for ABI encoding/decoding circuit inputs#546

Merged
kevaundray merged 16 commits intonoir-lang:masterfrom
TomAFrench:abi-refactor
Dec 8, 2022
Merged

Add methods for ABI encoding/decoding circuit inputs#546
kevaundray merged 16 commits intonoir-lang:masterfrom
TomAFrench:abi-refactor

Conversation

@TomAFrench
Copy link
Member

@TomAFrench TomAFrench commented Dec 2, 2022

Related issue(s)

closes #545
closes #453

Description

Summary of changes

This PR defines abi.encode and abi.decode methods which convert between BTreeMap<String, InputValue> and Vec<FieldElement>

abi.encode allows us to replace process_abi_with_input and process_abi_with_verifier_input with a shared implementation. This makes it easier to support new types in future and allows for better testing.

abi.decode allows us to simplify the code for exporting public inputs to Verifier.toml. Instead of having to pass around the witness index which corresponds to the return value and pull it out of the witness map then merge with the rest of the inputs, we can in a single step decode the entirety of the circuits inputs from the witness map.

Dependency additions / changes

(If applicable.)

Test additions / changes

(If applicable.)

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.

Additional context

Moving the handling of inputs to the noirc_abi crate also makes it easier to reuse this implementation through wasm in future.

jfecher
jfecher previously approved these changes Dec 8, 2022
TomAFrench and others added 2 commits December 8, 2022 18:56
* master:
  Update workflow to run on 20.04 to fix CI (noir-lang#565)
  Split `util` module from noirc_frontend into new crate (noir-lang#560)
  update backend ref (noir-lang#561)
  Tell `clap` to use help text when no subcommand (noir-lang#559)
  moving noirup and build files out to separate repositories (noir-lang#557)
  Make `noirup` pull latest nightly build by default (noir-lang#470)
  Handle predicate operator during inlining (noir-lang#544)
  Add gitattributes (noir-lang#541)
@kevaundray kevaundray merged commit 18d3068 into noir-lang:master Dec 8, 2022
@TomAFrench TomAFrench deleted the abi-refactor branch December 8, 2022 20:40
TomAFrench added a commit to TomAFrench/noir that referenced this pull request Dec 8, 2022
* master:
  Add methods for ABI encoding/decoding circuit inputs (noir-lang#546)
TomAFrench added a commit to TomAFrench/noir that referenced this pull request Dec 8, 2022
* master:
  Add methods for ABI encoding/decoding circuit inputs (noir-lang#546)
  Update workflow to run on 20.04 to fix CI (noir-lang#565)
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.

Standardise ABI encoding implementation for proving/verifying. ABI encoding functions should be exposed by noirc_abi crate.

3 participants