From a963a1ee3ae1adc77ab74b08b6538f86a2c4e5d3 Mon Sep 17 00:00:00 2001 From: lopeetall Date: Mon, 16 Dec 2024 12:04:15 -0500 Subject: [PATCH] upgrade to latest Kimchi --- Cargo.lock | 174 ++++++++++++++++------------------ Cargo.toml | 3 +- src/backends/kimchi/prover.rs | 14 +-- 3 files changed, 91 insertions(+), 100 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b82d70a67..713cf705c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,7 +271,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -353,7 +353,7 @@ checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -610,7 +610,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -639,15 +639,6 @@ dependencies = [ "json", ] -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -719,7 +710,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -730,7 +721,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -815,7 +806,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -850,7 +841,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -989,7 +980,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1094,7 +1085,7 @@ dependencies = [ [[package]] name = "groupmap" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ec", "ark-ff", @@ -1116,12 +1107,6 @@ dependencies = [ "ahash", ] -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - [[package]] name = "hashbrown" version = "0.15.0" @@ -1297,19 +1282,19 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "serde", ] [[package]] name = "internal-tracing" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" [[package]] name = "is-terminal" @@ -1376,7 +1361,7 @@ checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" [[package]] name = "kimchi" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ec", "ark-ff", @@ -1403,7 +1388,6 @@ dependencies = [ "rmp-serde", "serde", "serde_with", - "snarky-deriver", "strum", "strum_macros", "thiserror", @@ -1530,7 +1514,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1552,7 +1536,7 @@ dependencies = [ [[package]] name = "mina-curves" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ec", "ark-ff", @@ -1562,7 +1546,7 @@ dependencies = [ [[package]] name = "mina-poseidon" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ec", "ark-ff", @@ -1628,6 +1612,7 @@ dependencies = [ "num-bigint-dig", "num-traits", "once_cell", + "rand 0.8.5", "regex", "rmp-serde", "rstest", @@ -1708,7 +1693,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -1743,8 +1728,9 @@ dependencies = [ [[package]] name = "o1-utils" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ + "ark-ec", "ark-ff", "ark-poly", "ark-serialize", @@ -1756,6 +1742,8 @@ dependencies = [ "rand 0.8.5", "rand_core 0.6.4", "rayon", + "rmp-serde", + "secp256k1", "serde", "serde_with", "sha2", @@ -1839,7 +1827,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "poly-commitment" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ec", "ark-ff", @@ -1875,18 +1863,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -2019,25 +2007,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -2048,9 +2036,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "relative-path" @@ -2105,7 +2093,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.66", + "syn 2.0.90", "unicode-ident", ] @@ -2130,9 +2118,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] @@ -2155,6 +2143,24 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "secp256k1" +version = "0.28.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + [[package]] name = "semver" version = "1.0.23" @@ -2178,7 +2184,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2204,9 +2210,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -2233,7 +2239,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.7.0", "serde", "serde_derive", "serde_json", @@ -2250,7 +2256,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2313,18 +2319,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" -[[package]] -name = "snarky-deriver" -version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" -dependencies = [ - "convert_case", - "itertools 0.12.1", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "socket2" version = "0.5.7" @@ -2363,7 +2357,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2413,9 +2407,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -2478,7 +2472,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2548,7 +2542,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2578,20 +2572,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.7.0", "serde", "serde_spanned", "toml_datetime", @@ -2700,7 +2694,7 @@ dependencies = [ [[package]] name = "turshi" version = "0.1.0" -source = "git+https://github.com/o1-labs/proof-systems?rev=483bd5bd918ebbc1d5e008ce892d7a0023b50ed1#483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" +source = "git+https://github.com/o1-labs/proof-systems#6c674bdda34ab6db2b74984b0eb12f7fa1733e8c" dependencies = [ "ark-ff", "hex", @@ -2721,9 +2715,9 @@ checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-linebreak" @@ -2731,12 +2725,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - [[package]] name = "unicode-width" version = "0.1.13" @@ -2794,7 +2782,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", "wasm-bindgen-shared", ] @@ -2816,7 +2804,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2933,9 +2921,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -2966,7 +2954,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] [[package]] @@ -2986,5 +2974,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.90", ] diff --git a/Cargo.toml b/Cargo.toml index 3f0c4d456..bdf43b0e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ camino = "1.1.1" # to replace Path and PathBuf clap = { version = "4.0.5", features = ["derive"] } # CLI library dirs = "4.0.0" # helper functions (e.g. getting the home directory) itertools = "0.10.3" # useful iter traits -kimchi = { git = "https://github.com/o1-labs/proof-systems", rev = "483bd5bd918ebbc1d5e008ce892d7a0023b50ed1" } # ZKP +kimchi = { git = "https://github.com/o1-labs/proof-systems"} # ZKP miette = { version = "5.0.0", features = ["fancy"] } # nice errors num-traits = "0.2.15" # useful traits on big ints once_cell = "1.15.0" # for lazy statics @@ -45,6 +45,7 @@ thiserror = "1.0.31" toml = "0.8.8" # to parse manifest files constraint_writers = { git = "https://github.com/iden3/circom.git", tag = "v2.1.8" } # to generate r1cs file num-bigint-dig = "0.6.0" # to adapt for circom lib +rand = "0.8.5" rstest = "0.19.0" # for testing different backend cases rug = "1.26.1" # circ uses this for integer type circ = { git = "https://github.com/circify/circ", rev = "8140b1369edd5992ede038d2e9e5721510ae7065" } # for compiling to circ IR diff --git a/src/backends/kimchi/prover.rs b/src/backends/kimchi/prover.rs index 038363c80..51eb6f5fb 100644 --- a/src/backends/kimchi/prover.rs +++ b/src/backends/kimchi/prover.rs @@ -11,15 +11,15 @@ use crate::{ }; use itertools::chain; -use kimchi::mina_curves::pasta::{Vesta, VestaParameters}; +use kimchi::{mina_curves::pasta::{Vesta, VestaParameters}, poly_commitment::SRS as _}; use kimchi::mina_poseidon::constants::PlonkSpongeConstantsKimchi; use kimchi::mina_poseidon::sponge::{DefaultFqSponge, DefaultFrSponge}; use kimchi::poly_commitment::commitment::CommitmentCurve; -use kimchi::poly_commitment::evaluation_proof::OpeningProof; +use kimchi::poly_commitment::ipa::OpeningProof; use kimchi::proof::ProverProof; use kimchi::{ circuits::constraints::ConstraintSystem, groupmap::GroupMap, mina_curves::pasta::Pallas, - poly_commitment::srs::SRS, + poly_commitment::ipa::SRS, }; use miette::{Context, IntoDiagnostic}; @@ -108,13 +108,13 @@ impl KimchiVesta { // create SRS (for vesta, as the circuit is in Fp) let mut srs = SRS::::create(cs.domain.d1.size as usize); - srs.add_lagrange_basis(cs.domain.d1); + srs.get_lagrange_basis(cs.domain.d1); let srs = std::sync::Arc::new(srs); println!("using an SRS of size {}", srs.g.len()); // create indexes - let (endo_q, _endo_r) = kimchi::poly_commitment::srs::endos::(); + let (endo_q, _endo_r) = kimchi::poly_commitment::ipa::endos::(); let prover_index = kimchi::prover_index::ProverIndex::>::create( cs, endo_q, srs, @@ -199,10 +199,12 @@ impl ProverIndex { // create proof let proof = - ProverProof::create::(&GROUP_MAP, witness, &[], &self.index) + ProverProof::create::(&GROUP_MAP, witness, &[], &self.index, &mut rand::rngs::OsRng) + //.map_err(|e| miette!(e)) .into_diagnostic() .wrap_err("kimchi: could not create a proof with the given inputs")?; + // return proof + public output Ok(( proof,