diff --git a/noir/Cargo.lock b/noir/Cargo.lock index 09f607de2ae..1ac88d8d6e3 100644 --- a/noir/Cargo.lock +++ b/noir/Cargo.lock @@ -24,12 +24,12 @@ dependencies = [ [[package]] name = "acir" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir_field 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir_field 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "base64", "bincode", - "brillig 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "brillig 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "flate2", "serde", "thiserror", @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "acir_field" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ "ark-bn254", "ark-ff", @@ -83,12 +83,12 @@ dependencies = [ [[package]] name = "acvm" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "acvm_blackbox_solver 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "acvm_stdlib 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "brillig_vm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "acvm_blackbox_solver 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "acvm_stdlib 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "brillig_vm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "indexmap 1.9.3", "num-bigint", "num-traits", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "blake2", "k256", "p256", @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "acvm_stdlib" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", ] [[package]] @@ -679,9 +679,9 @@ dependencies = [ [[package]] name = "brillig" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir_field 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir_field 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "serde", ] @@ -698,10 +698,10 @@ dependencies = [ [[package]] name = "brillig_vm" version = "0.35.0" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "acvm_blackbox_solver 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "acvm_blackbox_solver 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "num-bigint", "num-traits", ] @@ -2458,6 +2458,15 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "line_check_circuit" +version = "0.1.0" +dependencies = [ + "noir_rs 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "serde", + "serde_json", +] + [[package]] name = "linux-raw-sys" version = "0.4.12" @@ -2820,18 +2829,18 @@ dependencies = [ [[package]] name = "noir_rs" version = "0.19.4" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "base64", "bincode", "flate2", "hex", - "noir_rs_acir_composer 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_acvm_runtime 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_blackbox_solver 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "noir_rs_acir_composer 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_acvm_runtime 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_blackbox_solver 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "serde", "thiserror", ] @@ -2847,9 +2856,9 @@ dependencies = [ [[package]] name = "noir_rs_acir_composer" version = "0.19.4" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "thiserror", ] @@ -2867,12 +2876,12 @@ dependencies = [ [[package]] name = "noir_rs_acvm_runtime" version = "0.19.4" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_acir_composer 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "noir_rs_blackbox_solver 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_acir_composer 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "noir_rs_blackbox_solver 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "thiserror", ] @@ -2892,7 +2901,7 @@ dependencies = [ [[package]] name = "noir_rs_barretenberg" version = "0.19.4" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ "base64", "bindgen", @@ -2918,12 +2927,12 @@ dependencies = [ [[package]] name = "noir_rs_blackbox_solver" version = "0.19.4" -source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update#bad3f7517b7c8208937a3030da357b1e12db8731" +source = "git+https://github.com/visoftsolutions/noir_rs.git?branch=latest#ff8f63daf9af87580c231b682517606cf8aaad4a" dependencies = [ - "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", - "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "acir 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", + "acvm 0.35.0 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "hex", - "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "noir_rs_barretenberg 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "num-bigint", "thiserror", ] @@ -3358,7 +3367,7 @@ dependencies = [ name = "poly_check_circuit" version = "0.1.0" dependencies = [ - "noir_rs 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest-update)", + "noir_rs 0.19.4 (git+https://github.com/visoftsolutions/noir_rs.git?branch=latest)", "serde", "serde_json", ] diff --git a/noir/Cargo.toml b/noir/Cargo.toml index fc25ec513c3..6a2492fd90e 100644 --- a/noir/Cargo.toml +++ b/noir/Cargo.toml @@ -28,6 +28,7 @@ members = [ "tooling/noir_rs/blackbox_solver", "tooling/noir_rs/acvm_runtime", "tooling/noir_rs/examples/poly_check_circuit", + "tooling/noir_rs/examples/line_check_circuit", "tooling/noir_rs", # ACVM "acvm-repo/acir_field", diff --git a/noir/tooling/noir_rs/examples/line_check_circuit/Cargo.toml b/noir/tooling/noir_rs/examples/line_check_circuit/Cargo.toml new file mode 100644 index 00000000000..fef012a102c --- /dev/null +++ b/noir/tooling/noir_rs/examples/line_check_circuit/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "line_check_circuit" +version = "0.1.0" +edition = "2021" +authors = ["Bartosz Nowak https://github.com/Okm165"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +noir_rs = { git = "https://github.com/visoftsolutions/noir_rs.git", branch = "latest", package = "noir_rs" } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" \ No newline at end of file diff --git a/noir/tooling/noir_rs/examples/line_check_circuit/Nargo.toml b/noir/tooling/noir_rs/examples/line_check_circuit/Nargo.toml new file mode 100644 index 00000000000..2c632391e30 --- /dev/null +++ b/noir/tooling/noir_rs/examples/line_check_circuit/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "line_check_circuit" +type = "bin" +authors = ["Bartosz Nowak https://github.com/Okm165"] +compiler_version = ">=0.19.4" + +[dependencies] \ No newline at end of file diff --git a/noir/tooling/noir_rs/examples/line_check_circuit/src/main.nr b/noir/tooling/noir_rs/examples/line_check_circuit/src/main.nr new file mode 100644 index 00000000000..d64248523d0 --- /dev/null +++ b/noir/tooling/noir_rs/examples/line_check_circuit/src/main.nr @@ -0,0 +1,15 @@ +mod structs; +use structs::{Point, Line}; + +fn main(point: Point, line: pub Line) { + assert(line.a * point.x + line.b - point.y == 0); +} + +#[test] +fn test_main() { + let line = Line { a: 5, b: 7 }; + let point = Point { x: 1, y: 12 }; + main(point, line); + // Uncomment to make test fail + // main(1, 1); +} diff --git a/noir/tooling/noir_rs/examples/line_check_circuit/src/main.rs b/noir/tooling/noir_rs/examples/line_check_circuit/src/main.rs new file mode 100644 index 00000000000..3f9c087ba41 --- /dev/null +++ b/noir/tooling/noir_rs/examples/line_check_circuit/src/main.rs @@ -0,0 +1,28 @@ +use noir_rs::{ + native_types::{Witness, WitnessMap}, + FieldElement, +}; +use serde_json::Value; +use std::fs; + +static PACKAGE_NAME: &str = env!("CARGO_PKG_NAME"); + +fn main() { + let data = + fs::read_to_string(format!("target/{}.json", PACKAGE_NAME)).expect("Unable to read file"); + let json: Value = serde_json::from_str(&data).expect("Unable to parse JSON"); + let bytecode: &str = json["bytecode"].as_str().expect("Unable to extract bytecode"); + + println!("Initializing witness..."); + let mut initial_witness = WitnessMap::new(); + initial_witness.insert(Witness(1), FieldElement::from(1_i128)); + initial_witness.insert(Witness(2), FieldElement::from(12_i128)); + initial_witness.insert(Witness(3), FieldElement::from(5_i128)); + initial_witness.insert(Witness(4), FieldElement::from(7_i128)); + println!("Generating proof..."); + let (proof, vk) = noir_rs::prove(String::from(bytecode), initial_witness).unwrap(); + println!("Verifying proof..."); + let verdict = noir_rs::verify(String::from(bytecode), proof, vk).unwrap(); + assert!(verdict); + println!("Proof correct"); +} diff --git a/noir/tooling/noir_rs/examples/line_check_circuit/src/structs.nr b/noir/tooling/noir_rs/examples/line_check_circuit/src/structs.nr new file mode 100644 index 00000000000..523235113fa --- /dev/null +++ b/noir/tooling/noir_rs/examples/line_check_circuit/src/structs.nr @@ -0,0 +1,9 @@ +struct Line { + a: u64, + b: u64, +} + +struct Point { + x: u64, + y: u64, +} diff --git a/noir/tooling/noir_rs/examples/poly_check_circuit/Nargo.toml b/noir/tooling/noir_rs/examples/poly_check_circuit/Nargo.toml index a5af39687e2..c9a03a7427b 100644 --- a/noir/tooling/noir_rs/examples/poly_check_circuit/Nargo.toml +++ b/noir/tooling/noir_rs/examples/poly_check_circuit/Nargo.toml @@ -2,6 +2,6 @@ name = "poly_check_circuit" type = "bin" authors = ["Bartosz Nowak https://github.com/Okm165"] -compiler_version = "0.19.4" +compiler_version = ">=0.19.4" [dependencies] \ No newline at end of file