forked from noir-lang/noir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add bb interface implementation (noir-lang#2902)
Co-authored-by: Koby Hall <[email protected]> Co-authored-by: Tom French <[email protected]> Co-authored-by: Tom French <[email protected]>
- Loading branch information
Showing
13 changed files
with
185 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ["../../.eslintrc.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
crs | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "@noir-lang/backend_barretenberg", | ||
"collaborators": [ | ||
"The Noir Team <[email protected]>" | ||
], | ||
"version": "0.7.10", | ||
"packageManager": "[email protected]", | ||
"license": "(MIT OR Apache-2.0)", | ||
"type": "module", | ||
"source": "src/index.ts", | ||
"main": "lib/cjs/index.cjs", | ||
"module": "lib/esm/index.js", | ||
"exports": { | ||
"require": "./lib/cjs/index.cjs", | ||
"default": "./lib/esm/index.js", | ||
"types": "./lib/esm/index.d.ts" | ||
}, | ||
"types": "lib/esm/index.d.ts", | ||
"scripts": { | ||
"dev": "tsc --watch", | ||
"build": "yarn clean && tsc && tsc -p ./tsconfig.cjs.json && mv ./lib/cjs/index.js ./lib/cjs/index.cjs && mv ./lib/cjs/serialize.js ./lib/cjs/serialize.cjs && mv ./lib/cjs/base64_decode.js ./lib/cjs/base64_decode.cjs", | ||
"clean": "rm -rf ./lib", | ||
"prettier": "prettier 'src/**/*.ts'", | ||
"prettier:fix": "prettier --write 'src/**/*.ts' 'test/**/*.ts'", | ||
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0" | ||
}, | ||
"dependencies": { | ||
"@aztec/bb.js": "0.7.10", | ||
"@noir-lang/types": "workspace:*", | ||
"fflate": "^0.8.0" | ||
}, | ||
"peerDependencies": { | ||
"@noir-lang/backend_barretenberg": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.6.2", | ||
"@types/prettier": "^3", | ||
"eslint": "^8.40.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"prettier": "3.0.3", | ||
"typescript": "5.1.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Since this is a simple function, we can use feature detection to | ||
// see if we are in the nodeJs environment or the browser environment. | ||
export function base64Decode(input: string): Uint8Array { | ||
if (typeof Buffer !== 'undefined') { | ||
// Node.js environment | ||
return Buffer.from(input, 'base64'); | ||
} else if (typeof atob === 'function') { | ||
// Browser environment | ||
return Uint8Array.from(atob(input), (c) => c.charCodeAt(0)); | ||
} else { | ||
throw new Error('No implementation found for base64 decoding.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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 { | ||
const compressedByteCode = base64Decode(base64EncodedBytecode); | ||
return gunzip(compressedByteCode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"outDir": "./lib/cjs" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"declaration": true, | ||
"emitDeclarationOnly": false, | ||
"module": "ESNext", | ||
"moduleResolution": "NodeNext", | ||
"outDir": "./lib/esm", | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"strict": true, | ||
"noImplicitAny": false, | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,20 @@ __metadata: | |
languageName: node | ||
linkType: hard | ||
|
||
"@aztec/bb.js@npm:0.7.10": | ||
version: 0.7.10 | ||
resolution: "@aztec/bb.js@npm:0.7.10" | ||
dependencies: | ||
comlink: ^4.4.1 | ||
commander: ^10.0.1 | ||
debug: ^4.3.4 | ||
tslib: ^2.4.0 | ||
bin: | ||
bb.js: dest/node/main.js | ||
checksum: 0410278e6ec2a6ecdcbaa58633b181ec1d91e1c267c76e7e587fb69c8f2fd394e79f65bd96cfcdb2a2b20fe5abeb86ababd45bd6364ba07555fc0643bf0e4307 | ||
languageName: node | ||
linkType: hard | ||
|
||
"@aztec/bb.js@npm:0.7.2": | ||
version: 0.7.2 | ||
resolution: "@aztec/bb.js@npm:0.7.2" | ||
|
@@ -440,6 +454,24 @@ __metadata: | |
languageName: unknown | ||
linkType: soft | ||
|
||
"@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg": | ||
version: 0.0.0-use.local | ||
resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" | ||
dependencies: | ||
"@aztec/bb.js": 0.7.10 | ||
"@noir-lang/types": "workspace:*" | ||
"@types/node": ^20.6.2 | ||
"@types/prettier": ^3 | ||
eslint: ^8.40.0 | ||
eslint-plugin-prettier: ^5.0.0 | ||
fflate: ^0.8.0 | ||
prettier: 3.0.3 | ||
typescript: 5.1.5 | ||
peerDependencies: | ||
"@noir-lang/backend_barretenberg": "workspace:*" | ||
languageName: unknown | ||
linkType: soft | ||
|
||
"@noir-lang/noir_js@workspace:*, @noir-lang/noir_js@workspace:tooling/noir_js": | ||
version: 0.0.0-use.local | ||
resolution: "@noir-lang/noir_js@workspace:tooling/noir_js" | ||
|
@@ -7549,6 +7581,16 @@ __metadata: | |
languageName: node | ||
linkType: hard | ||
|
||
"typescript@npm:5.1.5": | ||
version: 5.1.5 | ||
resolution: "typescript@npm:5.1.5" | ||
bin: | ||
tsc: bin/tsc | ||
tsserver: bin/tsserver | ||
checksum: 0eef8699e05ae767096924dbed633c340b4d36e953bb8ed87fb12e9dd9dcea5055ceac7182c614a556dbd346a8a82df799d330e1e286ae66e17c84e1710f6a6f | ||
languageName: node | ||
linkType: hard | ||
|
||
"typescript@npm:^5.0.4, typescript@npm:^5.2.2": | ||
version: 5.2.2 | ||
resolution: "typescript@npm:5.2.2" | ||
|
@@ -7569,6 +7611,16 @@ __metadata: | |
languageName: node | ||
linkType: hard | ||
|
||
"typescript@patch:[email protected]#~builtin<compat/typescript>": | ||
version: 5.1.5 | ||
resolution: "typescript@patch:typescript@npm%3A5.1.5#~builtin<compat/typescript>::version=5.1.5&hash=5da071" | ||
bin: | ||
tsc: bin/tsc | ||
tsserver: bin/tsserver | ||
checksum: 12ff5d14888805f24479e54bc8a3f83647107a6345f6c29dffcd429fb345be55f584a37e262cca58a0105203e41d4cb4e31b1b9096c9abeca0e2ace8eb00935e | ||
languageName: node | ||
linkType: hard | ||
|
||
"typescript@patch:typescript@^5.0.4#~builtin<compat/typescript>, typescript@patch:typescript@^5.2.2#~builtin<compat/typescript>": | ||
version: 5.2.2 | ||
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=f3b441" | ||
|