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

feat: Incorporate dummy backend for bb.js [DO NOT MERGE] #1491

Closed
wants to merge 48 commits into from

Conversation

vezenovm
Copy link
Contributor

@vezenovm vezenovm commented Jun 1, 2023

Description

Problem*

Resolves #1489

Summary*

The relevant ACVM rev that is updated to in this PR:
noir-lang/acvm#291
The updated acvm-backend-barretenberg:
noir-lang/acvm-backend-barretenberg#207

This PR sets out to enable compilation of ACIR circuits and witness generation in a format the bb.js expects. nargo built with the bb_js feature flag should only use the compile and execute commands as the rest are unimplemented. Until bb.js is fully integrated to nargo and/or fully dynamic backends are ready the other commands will not be usable with bb.js. This is an experimental feature and should only be used by advanced users comfortable with downloading from source and escaping from the normal nargo workflow.

Example

Before:

You could call cargo install --path=crates/nargo_cli to use nargo with the native acvm-backend-barretenberg. Addtional flags of --no-default-features --features=plonk_bn254_wasm would enable compilation with a wasm target.

Users can then use nargo commands to not only compile, but prove and verify their circuits such as with nargo prove p --verify.

After:

The previous commands work the same as before. However, adding the flags --no-default-features --features=bb_js will let a user compile a Noir circuit and generate a witness to file in the format that bb.js expects. However, proving and verifying will be done with bb.js. Binaries are being released for bb.js. Once someone has bb.js installed globally they can use it according to its CLI.

To prove and verify w/ bb.js the following command can be run over a compiled circuit and witness:
bb.js prove_and_verify -j ./target/c.json -w ./target/witness.tr

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@vezenovm vezenovm marked this pull request as ready for review June 6, 2023 19:24
@vezenovm vezenovm requested review from kevaundray and kobyhallx June 6, 2023 19:24
where
S: Serializer,
{
println!("CUR WIT IDX: {:?}", circuit.current_witness_index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove println

let cs: ConstraintSystem =
ConstraintSystem::try_from(circuit).expect("should have no malformed bb funcs");
let circuit_bytes = cs.to_bytes();
println!("{:?}", circuit_bytes.capacity());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

where
D: Deserializer<'de>,
{
// panic!("Not supported");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

@@ -36,10 +36,10 @@ hex = "0.4.2"
serde_json = "1.0"
termcolor = "1.1.2"
color-eyre = "0.6.2"
tokio = "1.0"
tokio = { version = "1.0.0", features = ["rt"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the rt feature needed?

@@ -1,19 +1,23 @@
use std::path::{Path, PathBuf};

// use noirc_abi::WitnessMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

@@ -36,6 +36,8 @@ noirc_errors = { path = "crates/noirc_errors" }
noirc_evaluator = { path = "crates/noirc_evaluator" }
noirc_frontend = { path = "crates/noirc_frontend" }
noir_wasm = { path = "crates/wasm" }
base64 = "0.13"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put a comment saying that this is only needed for the bb_js hack

@kevaundray
Copy link
Contributor

Can you merge master into this, so the diff is cleaner?

@TomAFrench TomAFrench closed this Sep 4, 2023
@TomAFrench TomAFrench deleted the mv/dummy-backend branch November 20, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(bb.js): Incorporate dummy backend to nargo that can interop with bb.js
4 participants