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: add init method to Noir class for web #2920

Merged
merged 37 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5ca20f7
Copy from Kobys Branch
kevaundray Sep 29, 2023
e120e24
revert to previous definition
kevaundray Sep 29, 2023
15ebc21
remove unused ignore file
kevaundray Sep 29, 2023
29d7f94
revert: group tooling workspace packages
kevaundray Sep 29, 2023
190f011
format
kevaundray Sep 29, 2023
c053aac
update yarn.lock
kevaundray Sep 29, 2023
9dcbbca
Import types into noir_js
kevaundray Sep 29, 2023
bbcf611
replace anonymous object with CompiledCircuit type
kevaundray Sep 29, 2023
7959844
export Noir
kevaundray Sep 29, 2023
ebaa551
lint fix
kevaundray Sep 29, 2023
894162d
update lockfile
kevaundray Sep 29, 2023
ef6ad1c
remove prettier
kevaundray Sep 29, 2023
01aee47
lint fix
kevaundray Sep 29, 2023
17b8956
copy barretenberg backend from ts
kevaundray Sep 29, 2023
e84e060
remove prettier
kevaundray Sep 29, 2023
1372c0d
remove compiled_examples from gitignore
kevaundray Sep 29, 2023
f4f0a79
remove lib folder
kevaundray Sep 29, 2023
0368617
add redundant methods
kevaundray Sep 29, 2023
9312121
extend mv syntax so that we convert all files to cjs in cjs folder
kevaundray Sep 29, 2023
8468b07
import backend
kevaundray Sep 29, 2023
8672a11
delete backend file
kevaundray Sep 29, 2023
7c72e68
add bb backend to workspace
kevaundray Sep 29, 2023
ab0c694
update index.ts in bb backend interface file
kevaundray Sep 29, 2023
331f157
update yarn.lock
kevaundray Sep 29, 2023
4f9a363
Merge remote-tracking branch 'origin/master' into kw/add-bb-backend-i…
kevaundray Sep 29, 2023
a0e327c
lint --fix
kevaundray Sep 29, 2023
5be1151
build bb.js wrapper
kevaundray Sep 29, 2023
26eeabf
Update tooling/noir_js_backend_barretenberg/src/serialize.ts
kevaundray Sep 29, 2023
3710d73
silence error if lib does not exist
kevaundray Sep 29, 2023
d8ddde0
chore: add gitignore
TomAFrench Sep 29, 2023
69b47e2
Merge remote-tracking branch 'origin/master' into kw/add-bb-backend-i…
kevaundray Oct 1, 2023
c2d850b
add init method to noir class
kevaundray Oct 1, 2023
619029e
chore: compile types package (#2921)
kevaundray Oct 2, 2023
59751cb
Update tooling/noir_js/src/program.ts
TomAFrench Oct 2, 2023
c662120
Update tooling/noir_js_backend_barretenberg/src/serialize.ts
TomAFrench Oct 2, 2023
55aadff
Merge branch 'master' into kw/add-init-to-noir
TomAFrench Oct 2, 2023
3b62219
fix merge resolution: extra build step
kevaundray Oct 2, 2023
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
5 changes: 4 additions & 1 deletion .github/workflows/test-noir-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ jobs:

- name: Build noirc_abi
run: yarn workspace @noir-lang/noirc_abi build


- name: Build noir_js_types
run: yarn workspace @noir-lang/types build

- name: Build barretenberg wrapper
run: yarn workspace @noir-lang/backend_barretenberg build

Expand Down
11 changes: 11 additions & 0 deletions tooling/noir_js/src/program.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Backend, CompiledCircuit } from '@noir-lang/types';
import { generateWitness } from './witness_generation.js';
import initAbi from '@noir-lang/noirc_abi';
import initACVM from '@noir-lang/acvm_js';

export class Noir {
constructor(
private circuit: CompiledCircuit,
private backend: Backend,
) {}

async init(): Promise<void> {
kevaundray marked this conversation as resolved.
Show resolved Hide resolved
// If these are available, then we are in the
// web environment. For the node environment, this
// is a no-op.
if (typeof initAbi === 'function') {
await Promise.all([initAbi(), initACVM()]);
}
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
}

// Initial inputs to your program
async generateFinalProof(inputs: any): Promise<Uint8Array> {
const serializedWitness = await generateWitness(this.circuit, inputs);
Expand Down
2 changes: 1 addition & 1 deletion tooling/noir_js_backend_barretenberg/src/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { decompressSync as gunzip } from 'fflate';
import { base64Decode } from './base64_decode.js';

// Converts bytecode from a base64 string to a Uint8Array
export function acirToUint8Array(base64EncodedBytecode): Uint8Array {
export function acirToUint8Array(base64EncodedBytecode: string): Uint8Array {
const compressedByteCode = base64Decode(base64EncodedBytecode);
return gunzip(compressedByteCode);
}
1 change: 1 addition & 0 deletions tooling/noir_js_types/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
21 changes: 19 additions & 2 deletions tooling/noir_js_types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@
"collaborators": [
"The Noir Team <team@noir-lang.org>"
],
"version": "0.14.1",
"packageManager": "yarn@3.5.1",
"version": "0.14.1",
"license": "(MIT OR Apache-2.0)",
"files": [
"lib",
"package.json"
],
"types": "lib/types.ts"
"main": "lib/cjs/types.js",
"module": "lib/esm/types.js",
"types": "lib/esm/types.d.ts",
"scripts": {
"build:esm": "tsc",
"build:cjs": "tsc --module CommonJS --outDir lib/cjs",
"build": "yarn run build:cjs && yarn run build:esm"
},
"exports": {
".": {
"import": "./lib/esm/types.js",
"require": "./lib/cjs/types.js",
"types": "./lib/esm/types.d.ts"
}
},
"devDependencies": {
"typescript": "^5.2.2"
}
}
File renamed without changes.
12 changes: 12 additions & 0 deletions tooling/noir_js_types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"declaration": true,
"module": "ESNext",
"moduleResolution": "node",
"outDir": "lib/esm",
"target": "ES2020",
"rootDir": "./src"
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules"]
}
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ __metadata:
"@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"
dependencies:
typescript: ^5.2.2
languageName: unknown
linkType: soft

Expand Down
Loading