Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"workspaces": [
"compiler/wasm",
"compiler/source-resolver",
"tooling/noirc_abi_wasm",
"compiler/integration-tests",
"tooling/noir_js_types",
"tooling/noirc_abi_wasm",
"tooling/noir_js",
"acvm-repo/acvm_js",
"release-tests"
Expand Down
3 changes: 2 additions & 1 deletion tooling/noir_js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dependencies": {
"@noir-lang/acvm_js": "workspace:*",
"@noir-lang/noirc_abi": "workspace:*",
"@noir-lang/types": "workspace:*",
"fflate": "^0.8.0"
},
"files": [
Expand Down Expand Up @@ -51,4 +52,4 @@
"tsc-multi": "^1.1.0",
"typescript": "^5.2.2"
}
}
}
2 changes: 2 additions & 0 deletions tooling/noir_js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export { acvm, abi };

export { generateWitness } from './witness_generation.js';
export { acirToUint8Array, witnessMapToUint8Array } from './serialize.js';

export { Noir } from './program.js';
4 changes: 2 additions & 2 deletions tooling/noir_js/src/program.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Backend } from './backend/backend_interface.js';
import { Backend, CompiledCircuit } from '@noir-lang/types';
import { generateWitness } from './witness_generation.js';

export class Noir {
constructor(
private circuit: { bytecode: string; abi: any },
private circuit: CompiledCircuit,
private backend: Backend,
) {}

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

// Generates the witnesses needed to feed into the chosen proving system
export async function generateWitness(
compiledProgram: { bytecode: string; abi: unknown },
inputs: unknown,
): Promise<Uint8Array> {
export async function generateWitness(compiledProgram: CompiledCircuit, inputs: unknown): Promise<Uint8Array> {
// Throws on ABI encoding error
const witnessMap = abiEncode(compiledProgram.abi, inputs, null);

Expand Down
2 changes: 1 addition & 1 deletion tooling/noir_js/test/backend/barretenberg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @ts-ignore
import { Barretenberg, Crs, RawBuffer } from '@aztec/bb.js';
import { acirToUint8Array } from '../../src/index.js';
import { Backend } from '../../src/backend/backend_interface.js';
import { Backend } from '@noir-lang/types';

export class BarretenbergBackend implements Backend {
// These type assertions are used so that we don't
Expand Down
1 change: 1 addition & 0 deletions tooling/noir_js_types/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions tooling/noir_js_types/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['../../.eslintrc.js'],
};
Empty file.
6 changes: 6 additions & 0 deletions tooling/noir_js_types/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parser": "typescript",
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ export interface Backend {

verifyIntermediateProof(proof: Uint8Array): Promise<boolean>;
}

export type CompiledCircuit = {
bytecode: string;
abi: object;
};
14 changes: 14 additions & 0 deletions tooling/noir_js_types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@noir-lang/types",
"collaborators": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.14.1",
"packageManager": "yarn@3.5.1",
"license": "(MIT OR Apache-2.0)",
"files": [
"lib",
"package.json"
],
"types": "lib/types.ts"
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ __metadata:
"@aztec/bb.js": 0.7.2
"@noir-lang/acvm_js": "workspace:*"
"@noir-lang/noirc_abi": "workspace:*"
"@noir-lang/types": "workspace:*"
"@types/chai": ^4
"@types/mocha": ^10.0.1
"@types/node": ^20.6.2
Expand Down Expand Up @@ -519,6 +520,12 @@ __metadata:
languageName: unknown
linkType: soft

"@noir-lang/types@workspace:*, @noir-lang/types@workspace:tooling/noir_js_types":
version: 0.0.0-use.local
resolution: "@noir-lang/types@workspace:tooling/noir_js_types"
languageName: unknown
linkType: soft

"@npmcli/fs@npm:^3.1.0":
version: 3.1.0
resolution: "@npmcli/fs@npm:3.1.0"
Expand Down