diff --git a/.gitignore b/.gitignore index 3c3629e..76efb07 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.vscode diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 563c37e..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 noir-lang - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index c02a170..db3e41e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,22 @@ # Tiny NoirJS app -This repo contains the full code from [this](https://noir-lang.org/noir_js/getting_started/tiny_noir_app) Noir docs page. +This repo contains the full code from [this](https://noir-lang.org/docs/tutorials/noirjs_app) Noir docs page. + +## Noir project + +Uses `nargo` version 0.31.0. + +Recompile with + +```bash +nargo compile +``` + +## Vite project + +```bash +cd vite-project +``` Install dependencies with @@ -11,5 +27,5 @@ npm install Run app with: ```bash -npm run start +npm run dev ``` diff --git a/app.js b/app.js deleted file mode 100644 index f7fa5d9..0000000 --- a/app.js +++ /dev/null @@ -1,23 +0,0 @@ -import { BarretenbergBackend } from '@noir-lang/backend_barretenberg'; -import { Noir } from '@noir-lang/noir_js'; -import noirjs_demo from './circuit/target/noirjs_demo.json'; - -document.addEventListener('DOMContentLoaded', async () => { - const backend = new BarretenbergBackend(noirjs_demo); - const noir = new Noir(noirjs_demo, backend); - const input = { x: 1, y: 2 }; - display('logs', 'Generating proof... ⌛'); - const proof = await noir.generateFinalProof(input); - display('logs', 'Generating proof... ✅'); - display('results', proof.proof); - display('logs', 'Verifying proof... ⌛'); - const verification = await noir.verifyFinalProof(proof); - if (verification) display('logs', 'Verifying proof... ✅'); -}); - -function display(container, msg) { - const c = document.getElementById(container); - const p = document.createElement('p'); - p.textContent = msg; - c.appendChild(p); -} diff --git a/circuit/Nargo.toml b/circuit/Nargo.toml index 11e6d10..2dea451 100644 --- a/circuit/Nargo.toml +++ b/circuit/Nargo.toml @@ -1,7 +1,7 @@ [package] -name = "noirjs_demo" +name = "circuit" type = "bin" authors = [""] -compiler_version = "0.17.0" +compiler_version = ">=0.31.0" [dependencies] \ No newline at end of file diff --git a/circuit/target/circuit.json b/circuit/target/circuit.json new file mode 100644 index 0000000..2edb65e --- /dev/null +++ b/circuit/target/circuit.json @@ -0,0 +1 @@ +{"noir_version":"0.31.0+540bef3597bd3e5775c83ec2ee3c0d4463084b4c","hash":4220416898248580058,"abi":{"parameters":[{"name":"x","type":{"kind":"field"},"visibility":"private"},{"name":"y","type":{"kind":"field"},"visibility":"public"}],"return_type":null,"error_types":{}},"bytecode":"H4sIAAAAAAAA/7VUSQ7DIAyEhKa99ic2SzC3fqWo5P8vqBopUCHCLWYkZIQlMx4vUhxQ+7mJM+ZsX9kaWK1NXic0+AYdIjmwLq6EhI7cR5MxiSz5EIOHgNYk3FwwGxyoY8E1oGTkNfHxgqKj7OgpGz3hGpCTt2zqfuLPRXqUEPOAuIq5+UfkrfhrBGJg0yrB27Sq4Vnfe0P4f7xnu3R8BY/9TPn+ZRa4bNd685a/VOVfKi6SnwvW+fYm/9nR5wcPIDK6OgYAAA==","debug_symbols":"lZBBCoMwFETvMussaqsUcpVS5KtRAuFHTBQkeHd/FA+Q5Zt5m5mEwXTr1FoefYD+JTjfU7SehRJeVxRm4kwh0hKh60bB8ADdVIfCaJ2R7Hv8Faoy/V2mf8r0ukQX2Gix1DmTh+du5f75QTDu892IewI=","file_map":{"47":{"source":"fn main(x: Field, y: pub Field) {\n assert(x != y);\n}\n\n#[test]\nfn test_main() {\n main(1, 2);\n\n // Uncomment to make test fail\n // main(1, 1);\n}\n","path":"/home/josh/Documents/tiny-noirjs-app/circuit/src/main.nr"}},"names":["main"]} \ No newline at end of file diff --git a/circuit/target/debug_noirjs_demo.json b/circuit/target/debug_noirjs_demo.json deleted file mode 100644 index d5bce17..0000000 --- a/circuit/target/debug_noirjs_demo.json +++ /dev/null @@ -1 +0,0 @@ -{"debug_symbols":[{"locations":{"0":[{"span":{"start":45,"end":51},"file":1}],"1":[{"span":{"start":45,"end":51},"file":1}],"2":[{"span":{"start":45,"end":51},"file":1}],"3":[{"span":{"start":45,"end":51},"file":1}],"4":[{"span":{"start":45,"end":51},"file":1}]}}],"file_map":{"1":{"source":"fn main(x: Field, y: pub Field) {\n assert(x != y);\n}\n\n#[test]\nfn test_main() {\n main(1, 2);\n\n // Uncomment to make test fail\n // main(1, 1);\n}\n","path":"/home/ritik/hello_aztec/noirjs_demo/src/main.nr"}}} \ No newline at end of file diff --git a/circuit/target/noirjs_demo.json b/circuit/target/noirjs_demo.json deleted file mode 100644 index 6410cd6..0000000 --- a/circuit/target/noirjs_demo.json +++ /dev/null @@ -1 +0,0 @@ -{"noir_version":"0.17.0+b6819f6261e63cea3e653a1b874727a2b5919f5e","hash":911280705436390268,"backend":"acvm-backend-barretenberg","abi":{"parameters":[{"name":"x","type":{"kind":"field"},"visibility":"private"},{"name":"y","type":{"kind":"field"},"visibility":"public"}],"param_witnesses":{"x":[1],"y":[2]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/7VTQQ4DIQjE3bXHvgUWXfHWr9TU/f8TmrY2Ma43cRJCwmEYBrAAYOGKteRHyYyHcznsmZieuMckHp1Ph5CQF//ahTmLkxBTDBjJcabTRz7xB1Nx4RhoUdS16un6cpmOl6bxEsdAmpprvVuJD5bOLdwmzAJNn9a/e6em2nzGcrYJvBb0jn7W3FZ/R1hRXjSP+mBB/5FMpbN+oj/eG6c6pXEFAAA="} \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index f2eb25e..0000000 --- a/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "noirjs_demo", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "vite --open", - "build": "vite build", - "preview": "vite preview" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@noir-lang/backend_barretenberg": "^0.17.0", - "@noir-lang/noir_js": "^0.17.0" - }, - "devDependencies": { - "rollup-plugin-copy": "^3.5.0", - "vite": "^4.5.0" - } -} diff --git a/vite-project/.gitignore b/vite-project/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/vite-project/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/index.html b/vite-project/index.html similarity index 64% rename from index.html rename to vite-project/index.html index 992e77e..03747ae 100644 --- a/index.html +++ b/vite-project/index.html @@ -15,11 +15,15 @@
- -