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

Return ABI to Witness map when compiling a program #684

Closed
kevaundray opened this issue Jan 23, 2023 · 2 comments · Fixed by #851
Closed

Return ABI to Witness map when compiling a program #684

kevaundray opened this issue Jan 23, 2023 · 2 comments · Fixed by #851
Labels
enhancement New feature or request

Comments

@kevaundray
Copy link
Contributor

Problem

When mapping the Abi to witness values, nargo does this by encoding the ABI and assigning each value in order to a witness. This ordering coincidentally matched with the witnesses that the evaluator assigns to Abi parameters.

Solution

The evaluator should specify the mapping of Abi parameters to witness indices, and nargo should just use that mapping.

This removes the witness offset parameter in nargo because it is no longer manually mapping parameters to witness indices.

Alternatives considered

Additional context

@TomAFrench
Copy link
Member

As a follow-on to this issue (can break out this into a separate issue later), we're likely going to want to remove the concept of a circuit's "public ABI" (or at least specialise it).

We should have the invariantabi.decode(abi.encode(inputs)) == inputs however we're currently hiding the fact that we've actually got two kinds of ABI encoding happening. Firstly for proving where we want to get a BTreeMap<Witness, FieldElement> which doesn't include outputs and verification where we want a Vec<FieldElement> which do include outputs.

We've then got the invariant abi.decode(abi.encode(inputs, skip_output), skip_output) but this issue adds an extra complication of the intermediate type being different. At this point we should just lean into these two encodings being different and separate them.

We could then always use the full ABI but have encode_public and decode_public methods or have a separate PublicAbi struct (I'm leaning towards former).

@joss-aztec
Copy link
Contributor

Am I right in think that once this work is complete, it will be possible to construct an initial witness from user input using the noir ABI only? I.e. it will not be necessary to read any information from the corresponding ACIR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants