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

Update to v0.27.0 #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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.

Install dependencies with

Expand Down
51 changes: 39 additions & 12 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,50 @@
import { BarretenbergBackend } from '@noir-lang/backend_barretenberg';
import { Noir } from '@noir-lang/noir_js';
import noirjs_demo from './circuit/target/noirjs_demo.json';
import {
BarretenbergBackend,
BarretenbergVerifier as Verifier,
} 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 setup = async () => {
await Promise.all([
import("@noir-lang/noirc_abi").then((module) =>
module.default(
new URL(
"@noir-lang/noirc_abi/web/noirc_abi_wasm_bg.wasm",
import.meta.url,
).toString(),
),
),
import("@noir-lang/acvm_js").then((module) =>
module.default(
new URL(
"@noir-lang/acvm_js/web/acvm_js_bg.wasm",
import.meta.url,
).toString(),
),
),
]);
};

document.addEventListener("DOMContentLoaded", async () => {
const backend = new BarretenbergBackend(noirjs_demo);
const noir = new Noir(noirjs_demo, backend);
await setup();
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... ✅');
display("logs", "Generating proof... ⌛");
const proof = await noir.generateProof(input);
display("logs", "Generating proof... ✅");
display("results", proof.proof);
display("logs", "Verifying proof... ⌛");
const verificationKey = await backend.getVerificationKey();
const verifier = new Verifier();
const isValid = await verifier.verifyProof(proof, verificationKey);
if (isValid) display("logs", "Verifying proof... ✅");
});

function display(container, msg) {
const c = document.getElementById(container);
const p = document.createElement('p');
const p = document.createElement("p");
p.textContent = msg;
c.appendChild(p);
}
4 changes: 2 additions & 2 deletions circuit/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
name = "noirjs_demo"
type = "bin"
authors = [""]
compiler_version = "0.17.0"
compiler_version = ">=0.27.0"

[dependencies]
[dependencies]
1 change: 0 additions & 1 deletion circuit/target/debug_noirjs_demo.json

This file was deleted.

2 changes: 1 addition & 1 deletion circuit/target/noirjs_demo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"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="}
{"noir_version":"0.27.0+4dfd7f03bc1b9cf57f5829c435a560bed53b7f46","hash":8689446815384908516,"abi":{"parameters":[{"name":"x","type":{"kind":"field"},"visibility":"private"},{"name":"y","type":{"kind":"field"},"visibility":"public"}],"param_witnesses":{"x":[{"start":0,"end":1}],"y":[{"start":1,"end":2}]},"return_type":null,"return_witnesses":[]},"bytecode":"H4sIAAAAAAAA/7WUUQ6DIAyGqTK3192kFdDy5lVmhvc/wTKNuBHkzfIlBBIT/PhbALWj13FTZ9o4T3E2OFgbxj6QoRf2fmaH1s0DE5Nj9+7ZmMCWRz/7ET1ZE2hx3iy4k+6F1yAQ9GrkvHDLDApZQpYlXoMknSGr+T2uu4L/wWMdTVx/BF0Oh420J49/6eR7l7iAvAupLJc8g2chn1PtJ0GZGk3UVthXK9lHo8a5tXyNUBUaokameBFQ/0sEBefSA/bjC3WKrBw2BgAA","debug_symbols":"lZBBCoMwFETvMussaqtd5CqlyFejBMKPmChI8O7+KB4gyzfzNjMJg+nWqbU8+gD9S3C+p2g9CyW8rijMxJlCpCVC142C4QG6qQ6F0Toj2ff4K1Rl+rtM/5TpdYkusNFiqXMmD8/dyv3zg2Dc57sR9wQ=","file_map":{"46":{"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":"/media/john/EXTRA/shak58/tiny-noirjs-app/circuit/src/main.nr"}},"names":["main"]}
Loading