Skip to content

Commit

Permalink
fix: avoid decoding public inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Jan 9, 2024
1 parent 3c8f83e commit 39d4bfa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions tooling/noir_js_backend_barretenberg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { decompressSync as gunzip } from 'fflate';
import { acirToUint8Array } from './serialize.js';
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types';
import { BackendOptions } from './types.js';
import { deflattenPublicInputs, flattenPublicInputsAsArray } from './public_inputs.js';

export { flattenPublicInputs } from './public_inputs.js';

Expand Down Expand Up @@ -93,9 +92,8 @@ export class BarretenbergBackend implements Backend {

const splitIndex = proofWithPublicInputs.length - numBytesInProofWithoutPublicInputs;

const publicInputsConcatenated = proofWithPublicInputs.slice(0, splitIndex);
const publicInputs = proofWithPublicInputs.slice(0, splitIndex);
const proof = proofWithPublicInputs.slice(splitIndex);
const publicInputs = deflattenPublicInputs(publicInputsConcatenated, this.acirCircuit.abi);

return { proof, publicInputs };
}
Expand Down Expand Up @@ -181,11 +179,8 @@ export class BarretenbergBackend implements Backend {
}

function reconstructProofWithPublicInputs(proofData: ProofData): Uint8Array {
// Flatten publicInputs
const publicInputsConcatenated = flattenPublicInputsAsArray(proofData.publicInputs);

// Concatenate publicInputs and proof
const proofWithPublicInputs = Uint8Array.from([...publicInputsConcatenated, ...proofData.proof]);
const proofWithPublicInputs = Uint8Array.from([...proofData.publicInputs, ...proofData.proof]);

return proofWithPublicInputs;
}
Expand Down
2 changes: 1 addition & 1 deletion tooling/noir_js_types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface Backend {
* */
export type ProofData = {
/** @description Public inputs of a proof */
publicInputs: WitnessMap;
publicInputs: Uint8Array;
/** @description An byte array representing the proof */
proof: Uint8Array;
};
Expand Down

0 comments on commit 39d4bfa

Please sign in to comment.