From b317ad6fdcfbb20e9ccc30db5d8f426fa99b9ce9 Mon Sep 17 00:00:00 2001 From: narodnik Date: Sun, 11 Oct 2020 14:35:04 +0200 Subject: [PATCH] comments for jj.rs --- src/bin/jubjub.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bin/jubjub.rs b/src/bin/jubjub.rs index c62d499e7..5e3214dc5 100644 --- a/src/bin/jubjub.rs +++ b/src/bin/jubjub.rs @@ -10,6 +10,8 @@ use rand::rngs::OsRng; type Result = std::result::Result; fn main() -> Result<()> { + // Load the contract from file + let start = Instant::now(); let file = File::open("jubjub.zcd")?; let mut visor = ZKSupervisor::decode(file)?; @@ -26,8 +28,12 @@ fn main() -> Result<()> { visor.vm.constraints.len() ); + // Do the trusted setup + visor.setup(); + // Put in our input parameters + visor.set_param( "x1", Scalar::from_string("15a36d1f0f390d8852a35a8c1908dd87a361ee3fd48fdf77b9819dc82d90607e"), @@ -45,8 +51,12 @@ fn main() -> Result<()> { Scalar::from_string("015d8c7f5b43fe33f7891142c001d9251f3abeeb98fad3e87b0dc53c4ebf1891"), )?; + // Generate the ZK proof + let proof = visor.prove()?; + // Test and show our output values + assert_eq!(proof.public.len(), 2); // 0x66ced46f14e5616d12b993f60a6e66558d6b6afe4c321ed212e0b9cfbd81061a assert_eq!( @@ -61,6 +71,8 @@ fn main() -> Result<()> { println!("u = {:?}", proof.public.get("x3").unwrap()); println!("v = {:?}", proof.public.get("y3").unwrap()); + // Verify the proof + assert!(visor.verify(&proof)); Ok(())