From d06750756e4c33d9ccbc5e85b48f062fa7402660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Thu, 6 Jul 2023 19:57:26 -0400 Subject: [PATCH] chore: Update nova, adapt to upstream changes Updates to version 0.22 See - https://github.com/microsoft/Nova/pull/163 --- Cargo.lock | 66 ++++++++++++++++++++++++++++++----------------- Cargo.toml | 2 +- src/proof/nova.rs | 32 ++++++++++++++--------- 3 files changed, 64 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d41efe3616..012df5b33e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1121,6 +1121,28 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "halo2curves" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b1142bd1059aacde1b477e0c80c142910f1ceae67fc619311d6a17428007ab" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "lazy_static", + "num-bigint 0.4.3", + "num-traits", + "pasta_curves", + "paste", + "rand", + "rand_core", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1379,7 +1401,7 @@ dependencies = [ "log", "lurk-macros", "memmap2", - "neptune 10.0.0", + "neptune", "nom", "nom_locate", "nova-snark", @@ -1471,25 +1493,6 @@ dependencies = [ "adler", ] -[[package]] -name = "neptune" -version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4227e5557caad6d2a910b7770f2479f0c9aeb8ddc1dc537623cb6ffec7f01d31" -dependencies = [ - "bellperson", - "blake2s_simd 0.5.11", - "blstrs", - "byteorder", - "ff", - "generic-array 0.14.7", - "itertools 0.8.2", - "log", - "pasta_curves", - "serde", - "trait-set", -] - [[package]] name = "neptune" version = "10.0.0" @@ -1552,9 +1555,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "nova-snark" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6247c61ab29e5da01c8f80403c25c40956045f0343d79793a2675bf7775dd80" +checksum = "90acdc02f86ed9f5f902b6eaf921774a608b953fc320bf4bba29598e51f67833" dependencies = [ "bellperson", "bincode", @@ -1564,8 +1567,10 @@ dependencies = [ "ff", "flate2", "generic-array 0.14.7", + "getrandom", + "halo2curves", "itertools 0.9.0", - "neptune 9.0.0", + "neptune", "num-bigint 0.4.3", "num-integer", "num-traits", @@ -1759,6 +1764,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "paste" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" + [[package]] name = "peekmore" version = "1.3.0" @@ -2247,6 +2258,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" version = "1.0.163" diff --git a/Cargo.toml b/Cargo.toml index c23eaf92b7..19180dcde7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -100,7 +100,7 @@ blstrs = "0.7.0" ff = "0.13" log = "0.4.17" neptune = { version = "10.0.0" } -nova = { package = "nova-snark", version = "0.21", default-features = false } +nova = { package = "nova-snark", version = "0.22", default-features = false } once_cell = "1.17.1" pairing_lib = { version = "0.23", package = "pairing" } pasta_curves = { version = "0.5.1" } diff --git a/src/proof/nova.rs b/src/proof/nova.rs index 176c00d22d..07c76f3573 100644 --- a/src/proof/nova.rs +++ b/src/proof/nova.rs @@ -292,17 +292,25 @@ impl<'a: 'b, 'b, C: Coprocessor> Proof<'a, C> { assert!(cs.is_satisfied()); } - - let res = RecursiveSNARK::prove_step( - &pp.pp, - recursive_snark, - circuit_primary.clone(), - circuit_secondary.clone(), - z0_primary.clone(), - z0_secondary.clone(), - ); - assert!(res.is_ok()); - recursive_snark = Some(res?); + let mut r_snark = recursive_snark.unwrap_or_else(|| { + RecursiveSNARK::new( + &pp.pp, + circuit_primary, + &circuit_secondary, + z0_primary.clone(), + z0_secondary.clone(), + ) + }); + r_snark + .prove_step( + &pp.pp, + circuit_primary, + &circuit_secondary, + z0_primary.clone(), + z0_secondary.clone(), + ) + .expect("failure to prove Nova step"); + recursive_snark = Some(r_snark); } Ok(Self::Recursive(Box::new(recursive_snark.unwrap()))) @@ -340,7 +348,7 @@ impl<'a: 'b, 'b, C: Coprocessor> Proof<'a, C> { let zi_secondary = z0_secondary.clone(); let (zi_primary_verified, zi_secondary_verified) = match self { - Self::Recursive(p) => p.verify(&pp.pp, num_steps, z0_primary, z0_secondary), + Self::Recursive(p) => p.verify(&pp.pp, num_steps, &z0_primary, &z0_secondary), Self::Compressed(p) => p.verify(&pp.vk, num_steps, z0_primary, z0_secondary), }?;