diff --git a/Cargo.lock b/Cargo.lock index d8936f5b7e6..de278df1015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -277,31 +277,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "aztec_backend" +name = "barretenberg_static_lib" version = "0.1.0" -source = "git+https://github.com/noir-lang/aztec_backend?rev=2d601a7d55faf601f4b183a43923c8fe04eabb7b#2d601a7d55faf601f4b183a43923c8fe04eabb7b" +source = "git+https://github.com/noir-lang/aztec_backend?rev=e1f206f6739d3782d3a241298089a0292de33742#e1f206f6739d3782d3a241298089a0292de33742" dependencies = [ - "acvm", "barretenberg_wrapper", "blake2", + "common", + "console_error_panic_hook", "dirs 3.0.2", "downloader", + "hex", "indicatif", "num-bigint", "num-traits", - "once_cell", "regex", "sha2", "sled", + "tempfile", ] [[package]] name = "barretenberg_wrapper" version = "0.1.0" -source = "git+https://github.com/AztecProtocol/aztec-2.0?rev=804c7dcf21111acd1302a768a8fa2f453dcec50f#804c7dcf21111acd1302a768a8fa2f453dcec50f" +source = "git+https://github.com/noir-lang/aztec-connect?rev=d79bbda6ec1fae6650256479a5f044843912ae2c#d79bbda6ec1fae6650256479a5f044843912ae2c" dependencies = [ + "bindgen", "cmake", "hex", + "num_cpus 0.2.13", ] [[package]] @@ -310,6 +314,29 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "bindgen" +version = "0.60.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "clap 3.2.23", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -371,6 +398,15 @@ version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + [[package]] name = "cfg-if" version = "0.1.10" @@ -392,6 +428,17 @@ dependencies = [ "stacker", ] +[[package]] +name = "clang-sys" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "2.34.0" @@ -401,12 +448,36 @@ dependencies = [ "ansi_term", "atty", "bitflags", - "strsim", - "textwrap", + "strsim 0.8.0", + "textwrap 0.11.0", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "atty", + "bitflags", + "clap_lex", + "indexmap", + "strsim 0.10.0", + "termcolor", + "textwrap 0.16.0", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "cmake" version = "0.1.49" @@ -435,6 +506,20 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/noir-lang/aztec_backend?rev=e1f206f6739d3782d3a241298089a0292de33742#e1f206f6739d3782d3a241298089a0292de33742" +dependencies = [ + "acvm", + "blake2", + "dirs 3.0.2", + "downloader", + "indicatif", + "regex", + "sled", +] + [[package]] name = "console" version = "0.15.2" @@ -623,6 +708,12 @@ dependencies = [ "signature", ] +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + [[package]] name = "elliptic-curve" version = "0.8.5" @@ -656,6 +747,19 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -690,7 +794,7 @@ dependencies = [ name = "fm" version = "0.1.0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 0.1.10", "codespan-reporting", "tempfile", "wasm-bindgen", @@ -878,6 +982,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + [[package]] name = "group" version = "0.8.0" @@ -982,6 +1092,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.23" @@ -1103,12 +1219,28 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if 1.0.0", + "winapi", +] + [[package]] name = "lock_api" version = "0.4.9" @@ -1168,6 +1300,12 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.6.2" @@ -1194,9 +1332,9 @@ name = "nargo" version = "0.1.0" dependencies = [ "acvm", - "aztec_backend", + "barretenberg_static_lib", "cfg-if 1.0.0", - "clap", + "clap 2.34.0", "dirs 3.0.2", "dirs 4.0.0", "fm", @@ -1330,6 +1468,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -1360,6 +1508,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee7e88156f3f9e19bdd598f8d6c9db7bf4078f99f8381f43a55b09648d1a6e3" +dependencies = [ + "libc", +] + [[package]] name = "num_cpus" version = "1.14.0" @@ -1433,6 +1590,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "parking_lot" version = "0.11.2" @@ -1470,6 +1633,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.2.0" @@ -1870,6 +2039,12 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + [[package]] name = "signature" version = "1.2.2" @@ -1949,6 +2124,12 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "subtle" version = "2.4.1" @@ -2030,6 +2211,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + [[package]] name = "thiserror" version = "1.0.37" @@ -2076,7 +2263,7 @@ dependencies = [ "libc", "memchr", "mio", - "num_cpus", + "num_cpus 1.14.0", "pin-project-lite", "socket2", "windows-sys 0.42.0", @@ -2351,6 +2538,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/crates/acvm/src/lib.rs b/crates/acvm/src/lib.rs index 3bc19261fc0..ab4381d9979 100644 --- a/crates/acvm/src/lib.rs +++ b/crates/acvm/src/lib.rs @@ -289,6 +289,8 @@ pub trait ProofSystemCompiler { public_input: Vec, circuit: Circuit, ) -> bool; + + fn get_exact_circuit_size(&self, circuit: Circuit) -> u32; } /// Supported NP complete languages diff --git a/crates/nargo/Cargo.toml b/crates/nargo/Cargo.toml index 1a8c15b52cc..b9a01ed6f98 100644 --- a/crates/nargo/Cargo.toml +++ b/crates/nargo/Cargo.toml @@ -29,7 +29,7 @@ hex = "0.4.2" tempdir = "0.3.7" # Backends -aztec_backend = { optional = true, git = "https://github.com/noir-lang/aztec_backend", rev = "2d601a7d55faf601f4b183a43923c8fe04eabb7b" } +aztec_backend = { optional = true, package = "barretenberg_static_lib", git = "https://github.com/noir-lang/aztec_backend", rev = "e1f206f6739d3782d3a241298089a0292de33742" } marlin_arkworks_backend = { optional = true, git = "https://github.com/noir-lang/marlin_arkworks_backend", rev = "601e24dcb5dcbe72e3de7a33879aaf84e171d541" } [features] diff --git a/crates/nargo/src/cli/gates_cmd.rs b/crates/nargo/src/cli/gates_cmd.rs index 41422182bd9..858875dc50d 100644 --- a/crates/nargo/src/cli/gates_cmd.rs +++ b/crates/nargo/src/cli/gates_cmd.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use acvm::ProofSystemCompiler; use clap::ArgMatches; use std::path::Path; @@ -24,7 +25,7 @@ pub fn count_gates_with_path>( allow_warnings: bool, ) -> Result<(), CliError> { let compiled_program = compile_circuit(program_dir.as_ref(), show_ssa, allow_warnings)?; - let gates = compiled_program.circuit.gates; + let gates = compiled_program.circuit.gates.clone(); // Store counts of each gate type into hashmap. let mut gate_counts: HashMap<&str, u32> = HashMap::new(); @@ -46,5 +47,9 @@ pub fn count_gates_with_path>( println!("{}: {}", gate_type, count); } + let backend = crate::backends::ConcreteBackend; + let exact_circuit_size = backend.get_exact_circuit_size(compiled_program.circuit); + println!("\nExact constraint size: {}\n", exact_circuit_size); + Ok(()) } diff --git a/crates/nargo/tests/test_data/merkle_insert/Prover.toml b/crates/nargo/tests/test_data/merkle_insert/Prover.toml index 700d4f5a95e..44d00763d78 100644 --- a/crates/nargo/tests/test_data/merkle_insert/Prover.toml +++ b/crates/nargo/tests/test_data/merkle_insert/Prover.toml @@ -1,11 +1,11 @@ -old_root = "0x0620374242254671503abf57d13969d41bbae97e59fa97cd7777cd683beb9eb8" -old_leaf = "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0" +old_root = "0x083b35b32ba24436c1614e4262cb4ad8f98f99cdb5fb0da8932ab2a290034867" +old_leaf = "0x0b81829b478114d28b964bd382ebff8be0216741aa72ff2896909110aef1704a" old_hash_path = [ - "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0", - "0x262e1ae3710241581182198b69a10601148ee1dd20ae638f99cde7b3ede59754", - "0x0f88aa985f23258a12a78b35eab5d3d8d41d091a71113f2d4b2731d96ab78cfd" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", + "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40" ] -new_root = "0x0a89e40480370e6c2f0e9e8cb0ac06a979092d55fc9210be9c2211c6a97f5991" -leaf = "0x1aab12b2f330c2fb811d6042f10ce65c0678803354529dc7f9bb5b1d9ff6987b" +new_root = "0x256c13d7694e2f900f55756246aa1104169efd9fb9e7c6be54c15794795d476f" +leaf = "0x2e5ba44f3c5329aeb915c703e39b33c5872f1542500cbb22f12b71640aba502f" index = "0" mimc_input = [12,45,78,41] \ No newline at end of file diff --git a/crates/nargo/tests/test_data/merkle_insert/src/main.nr b/crates/nargo/tests/test_data/merkle_insert/src/main.nr index b3cbb078fe1..6078bef79d6 100644 --- a/crates/nargo/tests/test_data/merkle_insert/src/main.nr +++ b/crates/nargo/tests/test_data/merkle_insert/src/main.nr @@ -11,7 +11,7 @@ fn main( ) { let old_leaf_exists = std::merkle::check_membership(old_root, old_leaf, index, old_hash_path); constrain old_leaf_exists == 1; - constrain old_root == std::merkle::compute_root_from_leaf( old_leaf, index, old_hash_path); + constrain old_root == std::merkle::compute_root_from_leaf(old_leaf, index, old_hash_path); let new_leaf_exists = std::merkle::check_membership(new_root, leaf, index, old_hash_path); constrain new_leaf_exists == 1; diff --git a/crates/nargo/tests/test_data/pedersen_check/Prover.toml b/crates/nargo/tests/test_data/pedersen_check/Prover.toml index 5ffb2b0291c..c5eaec281c9 100644 --- a/crates/nargo/tests/test_data/pedersen_check/Prover.toml +++ b/crates/nargo/tests/test_data/pedersen_check/Prover.toml @@ -2,5 +2,5 @@ x = "0" y = "1" salt = "42" -out_x = "0x108800e84e0f1dafb9fdf2e4b5b311fd59b8b08eaf899634c59cc985b490234b" -out_y = "0x2d43ef68df82e0adf74fed92b1bc950670b9806afcfbcda08bb5baa6497bdf14" +out_x = "0x229fb88be21cec523e9223a21324f2e305aea8bff9cdbcb3d0c6bba384666ea1" +out_y = "0x296b4b4605e586a91caa3202baad557628a8c56d0a1d6dff1a7ca35aed3029d5" diff --git a/crates/nargo/tests/test_data/schnorr/Prover.toml b/crates/nargo/tests/test_data/schnorr/Prover.toml index 55e1089e1a5..c5c3ab5101a 100644 --- a/crates/nargo/tests/test_data/schnorr/Prover.toml +++ b/crates/nargo/tests/test_data/schnorr/Prover.toml @@ -2,8 +2,8 @@ message = [0,1,2,3,4,5,6,7,8,9] pub_key_x = "0x17cbd3ed3151ccfd170efe1d54280a6a4822640bf5c369908ad74ea21518a9c5" pub_key_y = "0x0e0456e3795c1a31f20035b741cd6158929eeccd320d299cfcac962865a6bc74" signature = [ - 7, 131, 147, 205, 145, 77, 60, 169, 159, 86, 91, 209, 140, 210, 4, 21, 186, 39, 221, 195, - 62, 35, 220, 144, 135, 28, 201, 97, 145, 125, 146, 211, 92, 16, 67, 59, 162, 133, 144, 52, - 184, 137, 241, 102, 176, 152, 138, 220, 21, 40, 211, 178, 191, 67, 71, 11, 209, 191, 86, - 91, 196, 68, 98, 214, -] + 5, 202, 31, 146, 81, 242, 246, 69, 43, 107, 249, 153, 198, 44, 14, 111, 191, 121, 137, 166, + 160, 103, 18, 181, 243, 233, 226, 95, 67, 16, 37, 128, 85, 76, 19, 253, 30, 77, 192, 53, 138, + 205, 69, 33, 236, 163, 83, 194, 84, 137, 184, 221, 176, 121, 179, 27, 63, 70, 54, 16, 176, + 250, 39, 239, +] \ No newline at end of file diff --git a/crates/nargo/tests/test_data/simple_shield/Prover.toml b/crates/nargo/tests/test_data/simple_shield/Prover.toml index 50d7fec8874..4c03ef25a18 100644 --- a/crates/nargo/tests/test_data/simple_shield/Prover.toml +++ b/crates/nargo/tests/test_data/simple_shield/Prover.toml @@ -1,15 +1,15 @@ # Random test key priv_key = "0x000000000000000000000000000000000000000000000000000000616c696365" -note_root = "0x1221a375f6b4305e493497805102054f2847790244f92d09f6e859c083be2627" +note_root = "0x165cdc3cbcf4a6bf7b69514807409a3ed2e701556821f396ca04781a6434d96a" index = "0" note_hash_path = [ - "0x1cdcf02431ba623767fe389337d011df1048dcc24b98ed81cec97627bab454a0", - "0x262e1ae3710241581182198b69a10601148ee1dd20ae638f99cde7b3ede59754", - "0x0f88aa985f23258a12a78b35eab5d3d8d41d091a71113f2d4b2731d96ab78cfd" + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0e4223f3925f98934393c74975142bd73079ab0621f4ee133cee050a3c194f1a", + "0x2fd7bb412155bf8693a3bd2a3e7581a679c95c68a052f835dddca85fa1569a40" ] to_pubkey_x = "0x0000000000000000000000000000000000000000000000000000000000000001" to_pubkey_y = "0x0000000000000002cf135e7506a45d632d270d45f1181294833fc48d823f272c" return = [ - "0x0c9d3bdae689f66e3bc77823326726d140a48e989a1047ab25a9b6398b107118", - "0x2f581370029b47a215f0379b936c089542d5d20767f1fa2dce0e59bbc4c4bd62" + "0x1fa077bf4c787f858e0f3a7fa031ff11f200a0ccc6e549c6af98ec96800af340", + "0x0c25956c07e2277e75f1ca10bae32c29f24b27f25625fe9258cec29dc90651dd" ] \ No newline at end of file