Skip to content

Commit

Permalink
chore: Add barebones executeCircuit method for init circuit (#2747)
Browse files Browse the repository at this point in the history
Abi to typescript is missing, so its a bit hard to get the inputs in the
correct shape. For now, I've just zeroed out the witness map and passed
it to executeCircuit.


# Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if
the PR is ready to merge.
- [ ] If the pull request requires a cryptography review (e.g.
cryptographic algorithm implementations) I have added the 'crypto' tag.
- [ ] I have reviewed my diff in github, line by line and removed
unexpected formatting changes, testing logs, or commented-out code.
- [ ] Every change is related to the PR description.
- [ ] I have
[linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
this pull request to relevant issues (if any exist).
  • Loading branch information
kevaundray authored Oct 9, 2023
1 parent 6896db8 commit a572645
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 87 deletions.
2 changes: 2 additions & 0 deletions yarn-project/noir-private-kernel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
.yarn
4 changes: 3 additions & 1 deletion yarn-project/noir-private-kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"main": "index.js",
"license": "MIT/APACHE-2.0",
"type": "module",
"devDependencies": {
"@types/node": "^20.8.3",
"typescript": "^5.2.2"
Expand All @@ -12,6 +13,7 @@
"@noir-lang/noir_js": "^0.16.0"
},
"scripts": {
"build": "tsc"
"build": "tsc",
"start" : "yarn build && node dist/index.js"
}
}
25 changes: 25 additions & 0 deletions yarn-project/noir-private-kernel/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fs from 'fs/promises';
import { executeCircuit, WitnessMap } from '@noir-lang/acvm_js';

async function fetchJson() {
const rawData = await fs.readFile('./src/target/private_kernel_init.json', 'utf-8');
return JSON.parse(rawData);
}

const circuit = await fetchJson();
console.log('Initialized Noir instance with private kernel init circuit');

const decodedBytecode = Buffer.from(circuit.bytecode, 'base64');
const numWitnesses = 1811; // The number of input witnesses in the private kernel init circuit
const initialWitness : WitnessMap = new Map();
for (let i = 1; i <= numWitnesses; i++) {
initialWitness.set(i, "0x00");
}

const _witnessMap = await executeCircuit(decodedBytecode, initialWitness,() => {
throw Error('unexpected oracle during execution');
});

console.log("Executed private kernel init circuit with all zeroes");


6 changes: 3 additions & 3 deletions yarn-project/noir-private-kernel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand All @@ -25,9 +25,9 @@
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "commonjs", /* Specify what module code is generated. */
"module": "NodeNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
Expand Down
228 changes: 145 additions & 83 deletions yarn-project/noir-private-kernel/yarn.lock
Original file line number Diff line number Diff line change
@@ -1,89 +1,151 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 6
cacheKey: 8

"@aztec/bb.js@0.7.10":
version "0.7.10"
resolved "https://registry.yarnpkg.com/@aztec/bb.js/-/bb.js-0.7.10.tgz#e6f5963b2ff571f44d270f040657c2df05822b9c"
integrity sha512-tKfv0iGEysBLLQBl01lafd1DlPH01rYjKagGHWuDCxQi/SbKA6+5+5k1jWHLr7TXNkqCEexXwaURAcQv8mbETw==
"@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"

"@noir-lang/acvm_js@0.28.0":
version "0.28.0"
resolved "https://registry.yarnpkg.com/@noir-lang/acvm_js/-/acvm_js-0.28.0.tgz#888ab545120e0d2ca134b6dbac5a5086039bbb51"
integrity sha512-h2SPAFHOeW/BxBfaBJrs1XJUcmj+ItDaHmvwZzZ4qDnzMGPFiwmWRWcp6iWbQIbYQyc1QH0wSE/Z497Ajm0OdA==

"@noir-lang/backend_barretenberg@^0.7.10":
version "0.7.10"
resolved "https://registry.yarnpkg.com/@noir-lang/backend_barretenberg/-/backend_barretenberg-0.7.10.tgz#4548d9b0efd75ccc9b517b07c61dfcf0477aa619"
integrity sha512-ag5X3SvNOj4T8YT6uTssSICdGBxi+aTvtMoyOUg3DeFvWjFhYTj5ZEdsB0X9Geu2nlpN52fDo4RS69MSqP1Wog==
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

"@noir-lang/acvm_js@npm:0.28.0":
version: 0.28.0
resolution: "@noir-lang/acvm_js@npm:0.28.0"
checksum: 2eaeabb2a510702fa437dff7ea3a6c54aa11d2930d11d3a1a1dfda1d27fd5e28b268f96c4db85e1d76ba96cb49c509018d7c897c432de5e8d3d01b04778cf82f
languageName: node
linkType: hard

"@noir-lang/backend_barretenberg@npm:^0.7.10":
version: 0.7.10
resolution: "@noir-lang/backend_barretenberg@npm:0.7.10"
dependencies:
"@aztec/bb.js": 0.7.10
"@noir-lang/types": 0.14.1
fflate: ^0.8.0
peerDependencies:
"@noir-lang/backend_barretenberg": 0.7.10
checksum: d42e2405f70d493bb9251e63d58ca084e00d2c4653acb1ba6be2dd490f592b014a404c975d32f202ae65ed117d551ddc3acfa6dc8b5ecb587d21410b6ff9e8c5
languageName: node
linkType: hard

"@noir-lang/noir_js@npm:^0.16.0":
version: 0.16.0
resolution: "@noir-lang/noir_js@npm:0.16.0"
dependencies:
"@aztec/bb.js" "0.7.10"
"@noir-lang/types" "0.14.1"
fflate "^0.8.0"

"@noir-lang/noir_js@^0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@noir-lang/noir_js/-/noir_js-0.16.0.tgz#cdc2af532f9f272e0b5ec99fbb3281758d5818ea"
integrity sha512-rImnIIO3+C0XtDkncvO3g3vjwaE/tDerDLv4ZNeWWzBUTvKCruIM/dCqJIBlHwGa7A7DWAZEn86oPNLhNCY9bg==
"@noir-lang/acvm_js": 0.28.0
"@noir-lang/noirc_abi": 0.16.0
"@noir-lang/types": 0.14.1
fflate: ^0.8.0
checksum: fcb5cc730795800f8cf5093c99afac494c8ad26fa78a325ddbacd4fabedc08bdcaa9a002adfa746c853c237edd2098812ec8ec10a918e4a4100c19ed2f7fcb60
languageName: node
linkType: hard

"@noir-lang/noirc_abi@npm:0.16.0":
version: 0.16.0
resolution: "@noir-lang/noirc_abi@npm:0.16.0"
checksum: 41308bbf64b8b895bea00a8534eb7a6aad6872f6b4dfab653194e273ae51fed93001e99c1eaf8a6aa6d791c3b1a7d09ea9730db4da1be6a172b37dbf6fa1b077
languageName: node
linkType: hard

"@noir-lang/types@npm:0.14.1":
version: 0.14.1
resolution: "@noir-lang/types@npm:0.14.1"
checksum: 0c2a7967a62ad3348567d72302c4485a5612d4fd514437f25362cafb9fdc0bca47771bd9d97685b6098ebffd500f2d1e5d7104a38a510397cb9258435cb7f037
languageName: node
linkType: hard

"@types/node@npm:^20.8.3":
version: 20.8.3
resolution: "@types/node@npm:20.8.3"
checksum: bfb88b341faeb19f8fd37306a3bf433721b876c6491d10fcb0b13fd26601fa36ee45113dd82b1e1c23e3c957dff5b99f81a16493cefa03abe797e41a2487a4f7
languageName: node
linkType: hard

"comlink@npm:^4.4.1":
version: 4.4.1
resolution: "comlink@npm:4.4.1"
checksum: 16d58a8f590087fc45432e31d6c138308dfd4b75b89aec0b7f7bb97ad33d810381bd2b1e608a1fb2cf05979af9cbfcdcaf1715996d5fcf77aeb013b6da3260af
languageName: node
linkType: hard

"commander@npm:^10.0.1":
version: 10.0.1
resolution: "commander@npm:10.0.1"
checksum: 436901d64a818295803c1996cd856621a74f30b9f9e28a588e726b2b1670665bccd7c1a77007ebf328729f0139838a88a19265858a0fa7a8728c4656796db948
languageName: node
linkType: hard

"debug@npm:^4.3.4":
version: 4.3.4
resolution: "debug@npm:4.3.4"
dependencies:
"@noir-lang/acvm_js" "0.28.0"
"@noir-lang/noirc_abi" "0.16.0"
"@noir-lang/types" "0.14.1"
fflate "^0.8.0"

"@noir-lang/noirc_abi@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@noir-lang/noirc_abi/-/noirc_abi-0.16.0.tgz#e164ce3aea67fa781a70ad1c9caa6568c01f0489"
integrity sha512-ybtgiBqCV1bUhszqpBwfCZ25B07Bpp6jWt645vpdqSRwnWCC3w/KdEKIJVu5dDAX3GH0Br2vItgu2KE+rtL2PQ==

"@noir-lang/types@0.14.1":
version "0.14.1"
resolved "https://registry.yarnpkg.com/@noir-lang/types/-/types-0.14.1.tgz#f0eb715e75e8df879d8bf0759a1f9abc6069d68f"
integrity sha512-8FtL9SsQaEzoyyAjzzs7LJO6ognODGBj+ddlaydCD7mHveGqZlViDJhfHEpWOA8mysLQQ5lrL2Xg5uGWZx/l+Q==

"@types/node@^20.8.3":
version "20.8.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.3.tgz#c4ae2bb1cfab2999ed441a95c122bbbe1567a66d"
integrity sha512-jxiZQFpb+NlH5kjW49vXxvxTjeeqlbsnTAdBTKpzEdPs9itay7MscYXz3Fo9VYFEsfQ6LJFitHad3faerLAjCw==

comlink@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/comlink/-/comlink-4.4.1.tgz#e568b8e86410b809e8600eb2cf40c189371ef981"
integrity sha512-+1dlx0aY5Jo1vHy/tSsIGpSkN4tS9rZSW8FIhG0JH/crs9wwweswIo/POr451r7bZww3hFbPAKnTpimzL/mm4Q==

commander@^10.0.1:
version "10.0.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06"
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==

debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
ms: 2.1.2
peerDependenciesMeta:
supports-color:
optional: true
checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708
languageName: node
linkType: hard

"fflate@npm:^0.8.0":
version: 0.8.1
resolution: "fflate@npm:0.8.1"
checksum: 7207e2d333243724485d2488095256b776184bd4545aa9967b655feaee5dc18e9525ed9b6d75f94cfd71d98fb285336f4902641683472f1d0c19a99137084cec
languageName: node
linkType: hard

"ms@npm:2.1.2":
version: 2.1.2
resolution: "ms@npm:2.1.2"
checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f
languageName: node
linkType: hard

"noir-private-kernel@workspace:.":
version: 0.0.0-use.local
resolution: "noir-private-kernel@workspace:."
dependencies:
ms "2.1.2"

fflate@^0.8.0:
version "0.8.1"
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.1.tgz#1ed92270674d2ad3c73f077cd0acf26486dae6c9"
integrity sha512-/exOvEuc+/iaUm105QIiOt4LpBdMTWsXxqR0HDF35vx3fmaKzw7354gTilCh5rkzEt8WYyG//ku3h3nRmd7CHQ==

ms@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

tslib@^2.4.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==

typescript@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78"
integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==
"@noir-lang/backend_barretenberg": ^0.7.10
"@noir-lang/noir_js": ^0.16.0
"@types/node": ^20.8.3
typescript: ^5.2.2
languageName: unknown
linkType: soft

"tslib@npm:^2.4.0":
version: 2.6.2
resolution: "tslib@npm:2.6.2"
checksum: 329ea56123005922f39642318e3d1f0f8265d1e7fcb92c633e0809521da75eeaca28d2cf96d7248229deb40e5c19adf408259f4b9640afd20d13aecc1430f3ad
languageName: node
linkType: hard

"typescript@npm:^5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
languageName: node
linkType: hard

"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"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 0f4da2f15e6f1245e49db15801dbee52f2bbfb267e1c39225afdab5afee1a72839cd86000e65ee9d7e4dfaff12239d28beaf5ee431357fcced15fb08583d72ca
languageName: node
linkType: hard

0 comments on commit a572645

Please sign in to comment.