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

fix: Flatten public inputs according to their index in numerial rather than ascii order #3605

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tooling/noir_js_backend_barretenberg/src/public_inputs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Abi, WitnessMap } from '@noir-lang/types';

export function flattenPublicInputs(publicInputs: WitnessMap): string[] {
const publicInputIndices = [...publicInputs.keys()].sort();
const publicInputIndices = [...publicInputs.keys()].sort((a, b) => a - b);
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
const flattenedPublicInputs = publicInputIndices.map((index) => publicInputs.get(index) as string);
return flattenedPublicInputs;
}
Expand Down Expand Up @@ -31,7 +31,9 @@ export function deflattenPublicInputs(flattenedPublicInputs: Uint8Array, abi: Ab

// We now have an array of witness indices which have been deduplicated and sorted in ascending order.
// The elements of this array should correspond to the elements of `flattenedPublicInputs` so that we can build up a `WitnessMap`.
const public_input_witnesses = [...new Set(public_parameter_witnesses.concat(return_value_witnesses))].sort();
const public_input_witnesses = [...new Set(public_parameter_witnesses.concat(return_value_witnesses))].sort(
(a, b) => a - b,
);

const publicInputs: WitnessMap = new Map();
public_input_witnesses.forEach((witness_index, index) => {
Expand Down
Loading