Skip to content

Commit

Permalink
Merge branch 'master' into tf/noir-js-testing-ci
Browse files Browse the repository at this point in the history
* master:
  chore: delete unnecessary nix files (#2840)
  chore!: `generateWitness` now returns a serialized witness file (#2842)
  • Loading branch information
TomAFrench committed Sep 26, 2023
2 parents 03cf125 + 7006a83 commit 2a72bb6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 375 deletions.
1 change: 0 additions & 1 deletion acvm-repo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
# Cargo.lock
result
outputs/
.direnv
132 changes: 0 additions & 132 deletions acvm-repo/flake.lock

This file was deleted.

231 changes: 0 additions & 231 deletions acvm-repo/flake.nix

This file was deleted.

6 changes: 4 additions & 2 deletions tooling/noir_js/src/witness_generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { abiEncode } from '@noir-lang/noirc_abi';
import { validateInputs } from './input_validation.js';
import { base64Decode } from './base64_decode.js';
import { WitnessMap, executeCircuit } from '@noir-lang/acvm_js';
import { witnessMapToUint8Array } from './serialize.js';

// Generates the witnesses needed to feed into the chosen proving system
export async function generateWitness(compiledProgram, inputs): Promise<WitnessMap> {
Expand All @@ -12,12 +13,13 @@ export async function generateWitness(compiledProgram, inputs): Promise<WitnessM
}
const witnessMap = abiEncode(compiledProgram.abi, inputs, null);

// Execute the circuit to generate the rest of the witnesses
// Execute the circuit to generate the rest of the witnesses and serialize
// them into a Uint8Array.
try {
const solvedWitness = await executeCircuit(base64Decode(compiledProgram.bytecode), witnessMap, () => {
throw Error('unexpected oracle during execution');
});
return solvedWitness;
return witnessMapToUint8Array(solvedWitness);
} catch (err) {
throw new Error(`Circuit execution failed: ${err}`);
}
Expand Down
Loading

0 comments on commit 2a72bb6

Please sign in to comment.