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

chore: standardize witness map serialization format in JS #3104

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion tooling/noir_js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import * as abi from '@noir-lang/noirc_abi';

export { acvm, abi };

export { acirToUint8Array, witnessMapToUint8Array } from './serialize.js';
export { WitnessMap } from '@noir-lang/acvm_js';

export { Noir } from './program.js';
5 changes: 2 additions & 3 deletions tooling/noir_js/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types';
import { generateWitness } from './witness_generation.js';
import initAbi, { abiDecode, InputMap, InputValue } from '@noir-lang/noirc_abi';
import initACVM from '@noir-lang/acvm_js';
import { witnessMapToUint8Array } from './serialize.js';
import initACVM, { compressWitness } from '@noir-lang/acvm_js';

export class Noir {
constructor(
Expand All @@ -30,7 +29,7 @@ export class Noir {
await this.init();
const witness = await generateWitness(this.circuit, inputs);
const { return_value: returnValue } = abiDecode(this.circuit.abi, witness);
return { witness: witnessMapToUint8Array(witness), returnValue };
return { witness: compressWitness(witness), returnValue };
}

// Initial inputs to your program
Expand Down
17 changes: 0 additions & 17 deletions tooling/noir_js/src/serialize.ts

This file was deleted.

5 changes: 3 additions & 2 deletions tooling/noir_js_backend_barretenberg/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { decompressSync as gunzip } from 'fflate';
import { acirToUint8Array } from './serialize.js';
import { Backend, CompiledCircuit, ProofData } from '@noir-lang/types';

Expand Down Expand Up @@ -65,12 +66,12 @@ export class BarretenbergBackend implements Backend {
return this.generateProof(witness, makeEasyToVerifyInCircuit);
}

async generateProof(decompressedWitness: Uint8Array, makeEasyToVerifyInCircuit: boolean): Promise<ProofData> {
async generateProof(compressedWitness: Uint8Array, makeEasyToVerifyInCircuit: boolean): Promise<ProofData> {
await this.instantiate();
const proofWithPublicInputs = await this.api.acirCreateProof(
this.acirComposer,
this.acirUncompressedBytecode,
decompressedWitness,
gunzip(compressedWitness),
makeEasyToVerifyInCircuit,
);

Expand Down