diff --git a/Cargo.lock b/Cargo.lock index 8b6ec2d4..3ceb3712 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,222 +3,47 @@ version = 3 [[package]] -name = "actix-codec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" -dependencies = [ - "bitflags 2.6.0", - "bytes", - "futures-core", - "futures-sink", - "memchr", - "pin-project-lite", - "tokio", - "tokio-util 0.7.11", - "tracing", -] - -[[package]] -name = "actix-cors" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e772b3bcafe335042b5db010ab7c09013dad6eac4915c91d8d50902769f331" -dependencies = [ - "actix-utils", - "actix-web", - "derive_more", - "futures-util", - "log", - "once_cell", - "smallvec", -] - -[[package]] -name = "actix-http" -version = "3.8.0" +name = "abomonation" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae682f693a9cd7b058f2b0b5d9a6d7728a8555779bedbbc35dd88528611d020" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "ahash", - "base64 0.22.1", - "bitflags 2.6.0", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http", - "httparse", - "httpdate", - "itoa 1.0.11", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand 0.8.5", - "sha1 0.10.6", - "smallvec", - "tokio", - "tokio-util 0.7.11", - "tracing", - "zstd", -] +checksum = "56e72913c99b1f927aa7bd59a41518fdd9995f63ffc8760f211609e0241c4fb2" [[package]] -name = "actix-macros" -version = "0.2.4" +name = "abomonation_derive_ng" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" +checksum = "c34056136e0910411c88e9af0bca6e23fcdba258da239684014cd45ca900c9f0" dependencies = [ + "proc-macro2", "quote", - "syn 2.0.72", -] - -[[package]] -name = "actix-router" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" -dependencies = [ - "bytestring", - "cfg-if 1.0.0", - "http", - "regex", - "regex-lite", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eda4e2a6e042aa4e55ac438a2ae052d3b5da0ecf83d7411e1a368946925208" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b02303ce8d4e8be5b855af6cf3c3a08f3eff26880faad82bab679c22d3650cb5" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "socket2 0.5.7", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" -dependencies = [ - "futures-core", - "paste", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] - -[[package]] -name = "actix-web" -version = "4.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1988c02af8d2b718c05bc4aeb6a66395b7cdf32858c2c71131e5637a8c05a9ff" -dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "actix-web-codegen", - "ahash", - "bytes", - "bytestring", - "cfg-if 1.0.0", - "cookie", - "derive_more", - "encoding_rs", - "futures-core", - "futures-util", - "itoa 1.0.11", - "language-tags", - "log", - "mime", - "once_cell", - "pin-project-lite", - "regex", - "regex-lite", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2 0.5.7", - "time", - "url", + "syn 2.0.77", ] [[package]] -name = "actix-web-codegen" -version = "4.3.0" +name = "addchain" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f591380e2e68490b5dfaf1dd1aa0ebe78d84ba7067078512b4ea6e4492d622b8" +checksum = "3b2e69442aa5628ea6951fa33e24efe8313f4321a91bd729fc2f75bdfc858570" dependencies = [ - "actix-router", - "proc-macro2", - "quote", - "syn 2.0.72", + "num-bigint 0.3.3", + "num-integer", + "num-traits", ] [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "adler32" -version = "1.2.0" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aead" @@ -227,7 +52,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array", + "generic-array 0.14.7", ] [[package]] @@ -236,7 +61,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cipher", "cpufeatures", ] @@ -261,8 +86,7 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ - "cfg-if 1.0.0", - "getrandom 0.2.15", + "cfg-if", "once_cell", "version_check", "zerocopy", @@ -277,46 +101,16 @@ dependencies = [ "memchr", ] -[[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", -] - [[package]] name = "alloy-rlp" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" +checksum = "26154390b1d205a4a7ac7352aa2eb4f81f391399d4e2f546fb81a2f8bb383f62" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "bytes", ] -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - [[package]] name = "anes" version = "0.1.6" @@ -325,9 +119,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -340,33 +134,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -374,9 +168,54 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" + +[[package]] +name = "arecibo" +version = "0.2.0" +source = "git+https://github.com/deltadevsde/arecibo#1b6b7a772893bb6f0ce54556a0d52cd13bd1175c" +dependencies = [ + "abomonation", + "abomonation_derive_ng", + "bellpepper 0.4.1 (git+https://github.com/lurk-lab/bellpepper?branch=dev)", + "bellpepper-core", + "bincode", + "bitvec", + "byteorder", + "cfg-if", + "derive_more", + "digest 0.10.7", + "ff", + "generic-array 1.1.0", + "getrandom", + "group", + "grumpkin-msm", + "halo2curves", + "itertools 0.13.0", + "neptune", + "num-bigint 0.4.6", + "num-integer", + "num-traits", + "once_cell", + "pairing", + "pasta_curves", + "proptest", + "rand", + "rand_chacha", + "rand_core", + "rayon", + "rayon-scan", + "ref-cast", + "serde", + "sha3", + "static_assertions", + "subtle", + "thiserror", + "tracing", + "vergen", +] [[package]] name = "ark-ff" @@ -389,7 +228,7 @@ dependencies = [ "ark-serialize 0.3.0", "ark-std 0.3.0", "derivative", - "num-bigint", + "num-bigint 0.4.6", "num-traits", "paste", "rustc_version 0.3.3", @@ -409,10 +248,10 @@ dependencies = [ "derivative", "digest 0.10.7", "itertools 0.10.5", - "num-bigint", + "num-bigint 0.4.6", "num-traits", "paste", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "zeroize", ] @@ -442,7 +281,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" dependencies = [ - "num-bigint", + "num-bigint 0.4.6", "num-traits", "quote", "syn 1.0.109", @@ -454,7 +293,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ - "num-bigint", + "num-bigint 0.4.6", "num-traits", "proc-macro2", "quote", @@ -479,7 +318,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-std 0.4.0", "digest 0.10.7", - "num-bigint", + "num-bigint 0.4.6", ] [[package]] @@ -489,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -499,7 +338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -510,105 +349,9 @@ checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - -[[package]] -name = "async-channel" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" -dependencies = [ - "concurrent-queue", - "event-listener-strategy", - "futures-core", - "pin-project-lite", -] - -[[package]] -name = "async-executor" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand 2.1.0", - "futures-lite 2.3.0", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" -dependencies = [ - "async-channel 2.3.1", - "async-executor", - "async-io 2.3.3", - "async-lock 3.4.0", - "blocking", - "futures-lite 2.3.0", - "once_cell", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock 2.8.0", - "autocfg", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-lite 1.13.0", - "log", - "parking", - "polling 2.8.0", - "rustix 0.37.27", - "slab", - "socket2 0.4.10", - "waker-fn", -] - -[[package]] -name = "async-io" -version = "2.3.3" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" -dependencies = [ - "async-lock 3.4.0", - "cfg-if 1.0.0", - "concurrent-queue", - "futures-io", - "futures-lite 2.3.0", - "parking", - "polling 3.7.2", - "rustix 0.38.34", - "slab", - "tracing", - "windows-sys 0.52.0", -] +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-lock" @@ -616,109 +359,18 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener 2.5.3", -] - -[[package]] -name = "async-lock" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" -dependencies = [ - "event-listener 5.3.1", - "event-listener-strategy", - "pin-project-lite", -] - -[[package]] -name = "async-redis-session" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba82ce101e6cde598074604ef4a882bdd6b3a283baff446ae73ae2727c242452" -dependencies = [ - "async-session", - "redis 0.20.2", + "event-listener", ] -[[package]] -name = "async-session" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07da4ce523b4e2ebaaf330746761df23a465b951a83d84bbce4233dabedae630" -dependencies = [ - "anyhow", - "async-lock 2.8.0", - "async-trait", - "base64 0.13.1", - "bincode", - "blake3", - "chrono", - "hmac 0.11.0", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "sha2 0.9.9", -] - -[[package]] -name = "async-std" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" -dependencies = [ - "async-channel 1.9.0", - "async-global-executor", - "async-io 1.13.0", - "async-lock 2.8.0", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite 1.13.0", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-task" -version = "4.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" - [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", -] - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", + "syn 2.0.77", ] [[package]] @@ -729,7 +381,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -752,7 +404,7 @@ dependencies = [ "http", "http-body", "hyper", - "itoa 1.0.11", + "itoa", "matchit", "memchr", "mime", @@ -789,17 +441,17 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -844,28 +496,63 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" dependencies = [ - "serde", + "serde", +] + +[[package]] +name = "bellman" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171" +dependencies = [ + "bitvec", + "blake2s_simd", + "byteorder", + "crossbeam-channel", + "ff", + "group", + "lazy_static", + "log", + "num_cpus", + "pairing", + "rand_core", + "rayon", + "subtle", +] + +[[package]] +name = "bellpepper" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae286c2cb403324ab644c7cc68dceb25fe52ca9429908a726d7ed272c1edf7b" +dependencies = [ + "bellpepper-core", + "byteorder", + "ff", +] + +[[package]] +name = "bellpepper" +version = "0.4.1" +source = "git+https://github.com/lurk-lab/bellpepper?branch=dev#d0225bf6cb2bb9abaff28ea96a3497f9829815f8" +dependencies = [ + "bellpepper-core", + "byteorder", + "ff", + "itertools 0.12.1", ] [[package]] -name = "bellman" -version = "0.14.0" +name = "bellpepper-core" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171" +checksum = "1d8abb418570756396d722841b19edfec21d4e89e1cf8990610663040ecb1aea" dependencies = [ - "bitvec", "blake2s_simd", "byteorder", - "crossbeam-channel", "ff", - "group", - "lazy_static", - "log", - "num_cpus", - "pairing", - "rand_core 0.6.4", - "rayon", - "subtle", + "serde", + "thiserror", ] [[package]] @@ -877,6 +564,21 @@ dependencies = [ "serde", ] +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + [[package]] name = "bitflags" version = "1.3.2" @@ -904,6 +606,26 @@ dependencies = [ "wyz", ] +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + [[package]] name = "blake2s_simd" version = "1.0.2" @@ -911,23 +633,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", - "arrayvec 0.7.4", - "constant_time_eq 0.3.0", + "arrayvec", + "constant_time_eq", ] [[package]] name = "blake3" -version = "0.3.8" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", - "arrayvec 0.5.2", + "arrayvec", "cc", - "cfg-if 0.1.10", - "constant_time_eq 0.1.5", - "crypto-mac 0.8.0", - "digest 0.9.0", + "cfg-if", + "constant_time_eq", ] [[package]] @@ -936,7 +656,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array", + "generic-array 0.14.7", ] [[package]] @@ -945,20 +665,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array", -] - -[[package]] -name = "blocking" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" -dependencies = [ - "async-channel 2.3.1", - "async-task", - "futures-io", - "futures-lite 2.3.0", - "piper", + "generic-array 0.14.7", ] [[package]] @@ -982,7 +689,35 @@ dependencies = [ "ff", "group", "pairing", - "rand_core 0.6.4", + "rand_core", + "subtle", +] + +[[package]] +name = "blst" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + +[[package]] +name = "blstrs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" +dependencies = [ + "blst", + "byte-slice-cast", + "ff", + "group", + "pairing", + "rand_core", + "serde", "subtle", ] @@ -993,7 +728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" dependencies = [ "borsh-derive", - "cfg_aliases 0.2.1", + "cfg_aliases", ] [[package]] @@ -1003,34 +738,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" dependencies = [ "once_cell", - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "syn_derive", ] -[[package]] -name = "brotli" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - [[package]] name = "bs58" version = "0.5.1" @@ -1060,22 +774,13 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] -[[package]] -name = "bytestring" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d80203ea6b29df88012294f62733de21cfeab47f17b41af3a38bc30a03ee72" -dependencies = [ - "bytes", -] - [[package]] name = "cast" version = "0.3.0" @@ -1084,12 +789,11 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.6" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ - "jobserver", - "libc", + "shlex", ] [[package]] @@ -1100,7 +804,7 @@ checksum = "7f22a6baf972f7277acfd5c4ff9b894df7db5b0aaecdb57b9b77b5679fff323e" dependencies = [ "anyhow", "celestia-tendermint-proto", - "prost 0.12.6", + "prost", "prost-build", "prost-types", "serde", @@ -1115,7 +819,7 @@ dependencies = [ "async-trait", "celestia-types", "http", - "jsonrpsee 0.20.3", + "jsonrpsee", "serde", "thiserror", "tracing", @@ -1136,7 +840,7 @@ dependencies = [ "futures", "num-traits", "once_cell", - "prost 0.12.6", + "prost", "prost-types", "serde", "serde_bytes", @@ -1160,7 +864,7 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.12.6", + "prost", "prost-types", "serde", "serde_bytes", @@ -1196,43 +900,18 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "num-traits", - "serde", - "windows-targets 0.52.6", -] - [[package]] name = "ciborium" version = "0.2.2" @@ -1284,98 +963,49 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" -dependencies = [ - "atty", - "bitflags 1.3.2", - "clap_derive 3.2.25", - "clap_lex 0.2.4", - "indexmap 1.9.3", - "once_cell", - "strsim 0.10.0", - "termcolor", - "textwrap", -] - -[[package]] -name = "clap" -version = "4.5.9" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", - "clap_derive 4.5.8", + "clap_derive", ] [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", - "clap_lex 0.7.1", - "strsim 0.11.1", -] - -[[package]] -name = "clap_derive" -version = "3.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" -dependencies = [ - "heck 0.4.1", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", + "clap_lex", + "strsim", ] [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", -] - -[[package]] -name = "clap_lex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", + "syn 2.0.77", ] [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - -[[package]] -name = "colored" -version = "2.1.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" -dependencies = [ - "lazy_static", - "windows-sys 0.48.0", -] +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -1384,38 +1014,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", - "futures-core", "memchr", - "pin-project-lite", - "tokio", - "tokio-util 0.7.11", -] - -[[package]] -name = "commoncrypto" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" -dependencies = [ - "commoncrypto-sys", -] - -[[package]] -name = "commoncrypto-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -dependencies = [ - "libc", -] - -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", ] [[package]] @@ -1459,25 +1058,25 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.15", + "getrandom", "once_cell", "tiny-keccak", ] [[package]] name = "const_format" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +checksum = "50c655d81ff1114fb0dcdea9225ea9f0cc712a6f8d189378e82bdf62a473a64b" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.32" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +checksum = "eff1a44b93f47b1bac19a27932f5c591e43d1ba357ee4f61526c8a25603f0eb1" dependencies = [ "proc-macro2", "quote", @@ -1486,15 +1085,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "convert_case" @@ -1511,17 +1104,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "cookie" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" -dependencies = [ - "percent-encoding", - "time", - "version_check", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -1534,9 +1116,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core2" @@ -1547,20 +1129,11 @@ dependencies = [ "memchr", ] -[[package]] -name = "cpp_demangle" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1571,7 +1144,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1583,7 +1156,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.9", + "clap", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1656,43 +1229,11 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array", - "rand_core 0.6.4", + "generic-array 0.14.7", + "rand_core", "typenum", ] -[[package]] -name = "crypto-hash" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a77162240fd97248d19a564a565eb563a3f592b386e4136fb300909e67dddca" -dependencies = [ - "commoncrypto", - "hex 0.3.2", - "openssl", - "winapi", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1702,28 +1243,18 @@ dependencies = [ "cipher", ] -[[package]] -name = "ctrlc" -version = "3.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" -dependencies = [ - "nix 0.28.0", - "windows-sys 0.52.0", -] - [[package]] name = "curve25519-dalek" version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", "fiat-crypto", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "subtle", "zeroize", ] @@ -1736,7 +1267,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -1747,7 +1278,7 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core 0.6.4", + "rand_core", "subtle-ng", "zeroize", ] @@ -1758,7 +1289,7 @@ version = "5.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "hashbrown 0.14.5", "lock_api", "once_cell", @@ -1791,15 +1322,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "debugid" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" -dependencies = [ - "uuid", -] - [[package]] name = "der" version = "0.7.9" @@ -1839,8 +1361,8 @@ dependencies = [ "convert_case 0.4.0", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.72", + "rustc_version 0.4.1", + "syn 2.0.77", ] [[package]] @@ -1849,7 +1371,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array", + "generic-array 0.14.7", ] [[package]] @@ -1925,12 +1447,6 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" -[[package]] -name = "dtoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" - [[package]] name = "ed25519" version = "2.2.3" @@ -1948,8 +1464,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" dependencies = [ "curve25519-dalek-ng", - "hex 0.4.3", - "rand_core 0.6.4", + "hex", + "rand_core", "sha2 0.9.9", "zeroize", ] @@ -1962,7 +1478,7 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core 0.6.4", + "rand_core", "serde", "sha2 0.10.8", "subtle", @@ -1975,15 +1491,6 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "enum_dispatch" version = "0.3.13" @@ -1993,7 +1500,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -2031,51 +1538,21 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "event-listener" -version = "5.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" -dependencies = [ - "event-listener 5.3.1", - "pin-project-lite", -] - [[package]] name = "eyre" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" -dependencies = [ - "indenter", - "once_cell", -] - -[[package]] -name = "fastrand" -version = "1.9.0" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ - "instant", + "indenter", + "once_cell", ] [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fastrlp" @@ -2083,7 +1560,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "auto_impl", "bytes", ] @@ -2095,27 +1572,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "bitvec", - "rand_core 0.6.4", + "byteorder", + "ff_derive", + "rand_core", "subtle", ] [[package]] -name = "fiat-crypto" -version = "0.2.9" +name = "ff_derive" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +checksum = "e9f54704be45ed286151c5e11531316eaef5b8f5af7d597b806fdb8af108d84a" +dependencies = [ + "addchain", + "cfg-if", + "num-bigint 0.3.3", + "num-integer", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] -name = "findshlibs" -version = "0.10.2" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64" -dependencies = [ - "cc", - "lazy_static", - "libc", - "winapi", -] +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "fixed-hash" @@ -2124,7 +1607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -2137,9 +1620,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "miniz_oxide", @@ -2161,21 +1644,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -2191,16 +1659,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "funty" version = "2.0.0" @@ -2255,45 +1713,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - -[[package]] -name = "futures-lite" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" -dependencies = [ - "fastrand 2.1.0", - "futures-core", - "futures-io", - "parking", - "pin-project-lite", -] - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", -] - [[package]] name = "futures-sink" version = "0.3.30" @@ -2321,7 +1740,6 @@ dependencies = [ "futures-channel", "futures-core", "futures-io", - "futures-macro", "futures-sink", "futures-task", "memchr", @@ -2341,14 +1759,12 @@ dependencies = [ ] [[package]] -name = "getrandom" -version = "0.1.16" +name = "generic-array" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", + "typenum", ] [[package]] @@ -2357,9 +1773,11 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", + "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", + "wasm-bindgen", ] [[package]] @@ -2374,21 +1792,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.1" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] -name = "gloo-timers" -version = "0.2.6" +name = "glob" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "group" @@ -2397,10 +1809,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", - "rand_core 0.6.4", + "rand", + "rand_core", + "rand_xorshift", "subtle", ] +[[package]] +name = "grumpkin-msm" +version = "0.1.0" +source = "git+https://github.com/lurk-lab/grumpkin-msm?branch=dev#414da3bca6135a15fa58466b8831f5161ab1c51e" +dependencies = [ + "blst", + "cc", + "getrandom", + "halo2curves", + "pasta_curves", + "rand", + "rand_chacha", + "rayon", + "semolina", + "sppark", + "which", +] + [[package]] name = "h2" version = "0.3.26" @@ -2413,10 +1845,10 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.6", + "indexmap", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util", "tracing", ] @@ -2426,21 +1858,43 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crunchy", ] [[package]] -name = "hashbrown" -version = "0.12.3" +name = "halo2curves" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "num-bigint 0.4.6", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] [[package]] name = "hashbrown" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] [[package]] name = "hashbrown" @@ -2460,15 +1914,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -2481,17 +1926,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hkdf" @@ -2499,26 +1941,25 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "hmac 0.12.1", + "hmac", ] [[package]] name = "hmac" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "crypto-mac 0.11.0", - "digest 0.9.0", + "digest 0.10.7", ] [[package]] -name = "hmac" -version = "0.12.1" +name = "home" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "digest 0.10.7", + "windows-sys 0.52.0", ] [[package]] @@ -2529,7 +1970,7 @@ checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", - "itoa 1.0.11", + "itoa", ] [[package]] @@ -2582,7 +2023,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.11", + "itoa", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -2601,46 +2042,29 @@ dependencies = [ "http", "hyper", "log", - "rustls 0.21.12", - "rustls-native-certs 0.6.3", + "rustls", + "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "ics23" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "18798160736c1e368938ba6967dbcb3c7afb3256b442a5506ba5222eebb68a5a" dependencies = [ + "anyhow", + "blake2", + "blake3", "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", + "hex", + "informalsystems-pbjson", + "prost", + "ripemd", + "serde", + "sha2 0.10.8", + "sha3", ] [[package]] @@ -2688,9 +2112,9 @@ dependencies = [ "anyhow", "bls12_381", "borsh", - "hex 0.4.3", + "hex", "num", - "num-bigint", + "num-bigint 0.4.6", "num-traits", "serde", "sha2 0.10.8", @@ -2698,22 +2122,22 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.5", + "serde", ] [[package]] -name = "indexmap" -version = "2.2.6" +name = "informalsystems-pbjson" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "9aa4a0980c8379295100d70854354e78df2ee1c6ca0f96ffe89afeb3140e3a3d" dependencies = [ - "equivalent", - "hashbrown 0.14.5", + "base64 0.21.7", "serde", ] @@ -2723,51 +2147,25 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array", -] - -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.9", - "libc", - "windows-sys 0.48.0", + "generic-array 0.14.7", ] -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2788,10 +2186,13 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "0.4.8" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] [[package]] name = "itoa" @@ -2800,29 +2201,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] -name = "jobserver" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +name = "jmt" +version = "0.10.0" +source = "git+https://github.com/deltadevsde/jmt?branch=rehashing-circuit#1cb83bc02171dc1e9b8710f9efc7faaa9fe49f09" dependencies = [ - "libc", + "anyhow", + "auto_impl", + "borsh", + "digest 0.10.7", + "hashbrown 0.13.2", + "hex", + "ics23", + "itertools 0.10.5", + "mirai-annotations", + "num-derive", + "num-traits", + "parking_lot", + "serde", + "sha2 0.10.8", + "thiserror", + "tracing", ] [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] -[[package]] -name = "json" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" - [[package]] name = "json5" version = "0.4.1" @@ -2836,125 +2245,71 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" +checksum = "138572befc78a9793240645926f30161f8b4143d2be18d09e44ed9814bd7ee2c" dependencies = [ - "jsonrpsee-core 0.20.3", + "jsonrpsee-core", "jsonrpsee-http-client", "jsonrpsee-proc-macros", - "jsonrpsee-types 0.20.3", - "jsonrpsee-ws-client 0.20.3", - "tracing", -] - -[[package]] -name = "jsonrpsee" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" -dependencies = [ - "jsonrpsee-core 0.22.5", - "jsonrpsee-types 0.22.5", - "jsonrpsee-ws-client 0.22.5", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" -dependencies = [ - "futures-util", - "http", - "jsonrpsee-core 0.20.3", - "pin-project", - "rustls-native-certs 0.6.3", - "soketto", - "thiserror", - "tokio", - "tokio-rustls 0.24.1", - "tokio-util 0.7.11", + "jsonrpsee-types", + "jsonrpsee-ws-client", "tracing", - "url", ] [[package]] name = "jsonrpsee-client-transport" -version = "0.22.5" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" +checksum = "5c671353e4adf926799107bd7f5724a06b6bc0a333db442a0843c58640bdd0c1" dependencies = [ "futures-util", "http", - "jsonrpsee-core 0.22.5", + "jsonrpsee-core", "pin-project", - "rustls-native-certs 0.7.1", - "rustls-pki-types", + "rustls-native-certs", "soketto", "thiserror", "tokio", - "tokio-rustls 0.25.0", - "tokio-util 0.7.11", - "tracing", - "url", -] - -[[package]] -name = "jsonrpsee-core" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" -dependencies = [ - "anyhow", - "async-lock 2.8.0", - "async-trait", - "beef", - "futures-timer", - "futures-util", - "hyper", - "jsonrpsee-types 0.20.3", - "rustc-hash", - "serde", - "serde_json", - "thiserror", - "tokio", + "tokio-rustls", + "tokio-util", "tracing", + "url", ] [[package]] name = "jsonrpsee-core" -version = "0.22.5" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" +checksum = "f24ea59b037b6b9b0e2ebe2c30a3e782b56bd7c76dcc5d6d70ba55d442af56e3" dependencies = [ "anyhow", + "async-lock", "async-trait", "beef", "futures-timer", "futures-util", - "jsonrpsee-types 0.22.5", - "pin-project", + "hyper", + "jsonrpsee-types", "rustc-hash", "serde", "serde_json", "thiserror", "tokio", - "tokio-stream", "tracing", ] [[package]] name = "jsonrpsee-http-client" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f80c17f62c7653ce767e3d7288b793dfec920f97067ceb189ebdd3570f2bc20" +checksum = "57c7b9f95208927653e7965a98525e7fc641781cab89f0e27c43fa2974405683" dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core 0.20.3", - "jsonrpsee-types 0.20.3", + "jsonrpsee-core", + "jsonrpsee-types", "serde", "serde_json", "thiserror", @@ -2966,9 +2321,9 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" +checksum = "dcc0eba68ba205452bcb4c7b80a79ddcb3bf36c261a841b239433142db632d24" dependencies = [ "heck 0.4.1", "proc-macro-crate 1.3.1", @@ -2979,9 +2334,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" +checksum = "3264e339143fe37ed081953842ee67bfafa99e3b91559bdded6e4abd8fc8535e" dependencies = [ "anyhow", "beef", @@ -2991,50 +2346,33 @@ dependencies = [ "tracing", ] -[[package]] -name = "jsonrpsee-types" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "jsonrpsee-ws-client" -version = "0.20.3" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" +checksum = "6d06eeabbb55f0af8405288390a358ebcceb6e79e1390741e6f152309c4d6076" dependencies = [ "http", - "jsonrpsee-client-transport 0.20.3", - "jsonrpsee-core 0.20.3", - "jsonrpsee-types 0.20.3", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", "url", ] [[package]] -name = "jsonrpsee-ws-client" -version = "0.22.5" +name = "keccak" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58b9db2dfd5bb1194b0ce921504df9ceae210a345bc2f6c5a61432089bbab070" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ - "http", - "jsonrpsee-client-transport 0.22.5", - "jsonrpsee-core 0.22.5", - "jsonrpsee-types 0.22.5", - "url", + "cpufeatures", ] [[package]] name = "keyring" -version = "3.0.3" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9961b98f55dc0b2737000132505bdafa249abab147ee9de43c50ae04a054aa6c" +checksum = "030a9b84bb2a2f3673d4c8b8236091ed5d8f6b66a56d8085471d8abd5f3c6a80" [[package]] name = "keystore-rs" @@ -3046,33 +2384,21 @@ dependencies = [ "base64 0.22.1", "dotenvy", "ed25519-dalek", - "hex 0.4.3", + "hex", "keyring", "mockall", - "rand 0.8.5", + "rand", "security-framework", ] -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "leopard-codec" @@ -3087,29 +2413,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "libflate" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18" -dependencies = [ - "adler32", - "crc32fast", - "libflate_lz77", -] - -[[package]] -name = "libflate_lz77" -version = "1.2.0" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf" -dependencies = [ - "rle-decode-fast", -] +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libm" @@ -3148,35 +2454,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "local-channel" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cbc85e69b8df4b8bb8b89ec634e7189099cea8927a276b7384ce5488e53ec8" -dependencies = [ - "futures-core", - "futures-sink", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d873d7c67ce09b42110d801813efbc9364414e356be9935700d368351657487" - [[package]] name = "lock_api" version = "0.4.12" @@ -3192,9 +2475,6 @@ name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -dependencies = [ - "value-bag", -] [[package]] name = "matchit" @@ -3208,15 +2488,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "memmap2" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" -dependencies = [ - "libc", -] - [[package]] name = "mime" version = "0.3.17" @@ -3241,32 +2512,38 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "0.8.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi 0.3.9", "libc", - "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "wasi", + "windows-sys 0.52.0", ] +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + [[package]] name = "mockall" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "downcast", "fragile", "lazy_static", @@ -3281,10 +2558,10 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -3334,53 +2611,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03" [[package]] -name = "names" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc" -dependencies = [ - "clap 3.2.25", - "rand 0.8.5", -] - -[[package]] -name = "native-tls" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", -] - -[[package]] -name = "nix" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +name = "neptune" +version = "13.0.0" +source = "git+https://github.com/lurk-lab/neptune?branch=dev#b6fb1f9372be2a50c5686c1dfa27bb0d8c4253e7" dependencies = [ - "bitflags 2.6.0", - "cfg-if 1.0.0", - "cfg_aliases 0.1.1", - "libc", + "abomonation", + "abomonation_derive_ng", + "bellpepper 0.4.1 (git+https://github.com/lurk-lab/bellpepper?branch=dev)", + "bellpepper-core", + "blake2s_simd", + "blstrs", + "byteorder", + "ff", + "generic-array 0.14.7", + "pasta_curves", + "serde", + "trait-set", ] [[package]] @@ -3409,7 +2655,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "num-bigint", + "num-bigint 0.4.6", "num-complex", "num-integer", "num-iter", @@ -3417,6 +2663,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.6" @@ -3425,6 +2682,8 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "rand", + "serde", ] [[package]] @@ -3479,7 +2738,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "num-bigint", + "num-bigint 0.4.6", "num-integer", "num-traits", ] @@ -3504,11 +2763,20 @@ dependencies = [ "libc", ] +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ + "libc", +] + [[package]] name = "object" -version = "0.32.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -3531,50 +2799,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" -[[package]] -name = "openssl" -version = "0.10.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" -dependencies = [ - "bitflags 2.6.0", - "cfg-if 1.0.0", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", -] - [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" -[[package]] -name = "openssl-sys" -version = "0.9.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "option-ext" version = "0.2.0" @@ -3591,12 +2821,6 @@ dependencies = [ "hashbrown 0.13.2", ] -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - [[package]] name = "pairing" version = "0.23.0" @@ -3612,7 +2836,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", @@ -3626,18 +2850,12 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 3.1.0", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 1.0.109", ] -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - [[package]] name = "parking_lot" version = "0.12.3" @@ -3654,13 +2872,30 @@ version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets 0.52.6", ] +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "rand", + "serde", + "static_assertions", + "subtle", +] + [[package]] name = "paste" version = "1.0.15" @@ -3681,9 +2916,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd53dff83f26735fdc1ca837098ccf133605d794cdae66acfc2bfac3ec809d95" +checksum = "9c73c26c01b8c87956cea613c907c9d6ecffd8d18a2a5908e5de0adfaa185cea" dependencies = [ "memchr", "thiserror", @@ -3692,9 +2927,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a548d2beca6773b1c244554d36fcf8548a8a58e74156968211567250e48e49a" +checksum = "664d22978e2815783adbdd2c588b455b1bd625299ce36b2a99881ac9627e6d8d" dependencies = [ "pest", "pest_generator", @@ -3702,22 +2937,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c93a82e8d145725dcbaf44e5ea887c8a869efdcc28706df2d08c69e17077183" +checksum = "a2d5487022d5d33f4c30d91c22afa240ce2a644e87fe08caad974d4eab6badbe" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "pest_meta" -version = "2.7.11" +version = "2.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a941429fea7e08bedec25e4f6785b6ffaacc6b755da98df5ef3e7dcf4a124c4f" +checksum = "0091754bbd0ea592c4deb3a122ce8ecbb0753b738aa82bc055fcc2eccc8d8174" dependencies = [ "once_cell", "pest", @@ -3731,7 +2966,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap", ] [[package]] @@ -3751,7 +2986,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -3766,17 +3001,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "piper" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" -dependencies = [ - "atomic-waker", - "fastrand 2.1.0", - "futures-io", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -3787,17 +3011,11 @@ dependencies = [ "spki", ] -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -3808,57 +3026,26 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if 1.0.0", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - -[[package]] -name = "polling" -version = "3.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" -dependencies = [ - "cfg-if 1.0.0", - "concurrent-queue", - "hermit-abi 0.4.0", - "pin-project-lite", - "rustix 0.38.34", - "tracing", - "windows-sys 0.52.0", -] - [[package]] name = "polyval" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "opaque-debug", "universal-hash", @@ -3871,36 +3058,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] -name = "pprof" -version = "0.12.1" +name = "ppv-lite86" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978385d59daf9269189d052ca8a84c1acfd0715c0599a5d5188d4acc078ca46a" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "backtrace", - "cfg-if 1.0.0", - "findshlibs", - "libc", - "log", - "nix 0.26.4", - "once_cell", - "parking_lot", - "smallvec", - "symbolic-demangle", - "tempfile", - "thiserror", + "zerocopy", ] -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - [[package]] name = "predicates" -version = "3.1.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "predicates-core", @@ -3908,15 +3078,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" [[package]] name = "predicates-tree" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" dependencies = [ "predicates-core", "termtree", @@ -3934,12 +3104,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -3954,15 +3124,63 @@ dependencies = [ ] [[package]] -name = "prism" +name = "prism-common" +version = "0.1.0" +dependencies = [ + "anyhow", + "blake2", + "bls12_381", + "borsh", + "celestia-types", + "hex", + "jmt", + "serde", + "sha2 0.10.8", +] + +[[package]] +name = "prism-errors" +version = "0.1.0" +dependencies = [ + "anyhow", + "ed25519", + "ed25519-dalek", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "prism-groth16" +version = "0.1.0" +dependencies = [ + "anyhow", + "bellman", + "bls12_381", + "borsh", + "celestia-types", + "ed25519", + "ed25519-dalek", + "ff", + "hex", + "indexed-merkle-tree", + "jmt", + "log", + "prism-common", + "prism-errors", + "rand", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "prism-main" version = "0.1.0" dependencies = [ - "actix-cors", - "actix-web", - "ahash", "anyhow", - "async-redis-session", "async-trait", + "auto_impl", "axum", "base64 0.22.1", "bellman", @@ -3970,39 +3188,30 @@ dependencies = [ "borsh", "celestia-rpc", "celestia-types", - "clap 4.5.9", - "colored", + "clap", "config", "criterion", - "crypto-hash", - "ctrlc", "dirs 5.0.1", "dotenvy", "ed25519", "ed25519-dalek", "ff", - "fs2", - "futures", - "hex 0.4.3", + "hex", "indexed-merkle-tree", - "jsonrpsee 0.22.5", + "jmt", "keystore-rs", - "lazy_static", "log", "mockall", - "num", - "openssl", - "pairing", "pretty_env_logger", - "pyroscope", - "pyroscope_pprofrs", - "rand 0.7.3", - "rand 0.8.5", - "redis 0.24.0", - "reqwest", + "prism-common", + "prism-errors", + "prism-groth16", + "rand", + "redis", "serde", "serde_json", "serial_test", + "sha2 0.10.8", "thiserror", "tokio", "toml", @@ -4011,6 +3220,42 @@ dependencies = [ "utoipa-swagger-ui", ] +[[package]] +name = "prism-nova" +version = "0.1.0" +dependencies = [ + "anyhow", + "arecibo", + "base64 0.22.1", + "bellpepper 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bellpepper-core", + "bincode", + "bls12_381", + "borsh", + "celestia-types", + "ed25519", + "ff", + "hex", + "indexed-merkle-tree", + "itertools 0.13.0", + "jmt", + "num", + "prism-common", + "rand", + "serde", + "serde_json", + "sha2 0.10.8", + "thiserror", +] + +[[package]] +name = "prism-sp1" +version = "0.1.0" +dependencies = [ + "prism-common", + "sp1-zkvm", +] + [[package]] name = "proc-macro-crate" version = "1.3.1" @@ -4023,11 +3268,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit 0.22.20", ] [[package]] @@ -4069,26 +3314,20 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ + "bit-set", + "bit-vec", "bitflags 2.6.0", "lazy_static", "num-traits", - "rand 0.8.5", - "rand_chacha 0.3.1", + "rand", + "rand_chacha", "rand_xorshift", "regex-syntax", + "rusty-fork", + "tempfile", "unarray", ] -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "prost-derive 0.11.9", -] - [[package]] name = "prost" version = "0.12.6" @@ -4096,7 +3335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive 0.12.6", + "prost-derive", ] [[package]] @@ -4113,26 +3352,13 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost 0.12.6", + "prost", "prost-types", "regex", - "syn 2.0.72", + "syn 2.0.77", "tempfile", ] -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "prost-derive" version = "0.12.6" @@ -4143,7 +3369,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -4152,38 +3378,14 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.6", -] - -[[package]] -name = "pyroscope" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac8a53ce01af1087eaeee6ce7c4fbf50ea4040ab1825c0115c4bafa039644ba9" -dependencies = [ - "json", - "libc", - "libflate", - "log", - "names", - "prost 0.11.9", - "reqwest", - "thiserror", - "url", - "winapi", + "prost", ] [[package]] -name = "pyroscope_pprofrs" -version = "0.2.7" +name = "quick-error" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f010b2a981a7f8449a650f25f309e520b5206ea2d89512dcb146aaa5518ff4" -dependencies = [ - "log", - "pprof", - "pyroscope", - "thiserror", -] +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-protobuf" @@ -4196,9 +3398,9 @@ dependencies = [ [[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", ] @@ -4209,19 +3411,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -4229,18 +3418,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -4250,16 +3429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -4268,16 +3438,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -4286,7 +3447,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -4310,24 +3471,12 @@ dependencies = [ ] [[package]] -name = "redis" -version = "0.20.2" +name = "rayon-scan" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f0ceb2ec0dd769483ecd283f6615aa83dcd0be556d5294c6e659caefe7cc54" +checksum = "3f87cc11a0140b4b0da0ffc889885760c61b13672d80a908920b2c0df078fa14" dependencies = [ - "async-std", - "async-trait", - "bytes", - "combine", - "dtoa", - "futures-util", - "itoa 0.4.8", - "percent-encoding", - "pin-project-lite", - "sha1 0.6.1", - "tokio", - "tokio-util 0.6.10", - "url", + "rayon", ] [[package]] @@ -4337,7 +3486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c580d9cbbe1d1b479e8d67cf9daf6a62c957e6846048408b80b43ac3f6af84cd" dependencies = [ "combine", - "itoa 1.0.11", + "itoa", "percent-encoding", "ryu", "sha1_smol", @@ -4356,20 +3505,40 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", "thiserror", ] +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -4388,62 +3557,12 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-lite" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" - [[package]] name = "regex-syntax" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "hyper-rustls", - "hyper-tls", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - [[package]] name = "ring" version = "0.17.8" @@ -4451,8 +3570,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", - "cfg-if 1.0.0", - "getrandom 0.2.15", + "cfg-if", + "getrandom", "libc", "spin", "untrusted", @@ -4460,10 +3579,13 @@ dependencies = [ ] [[package]] -name = "rle-decode-fast" -version = "1.0.3" +name = "ripemd" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3582f63211428f83597b51b2ddb88e2a91a9d52d12831f9d08f5e624e8977422" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] [[package]] name = "rlp" @@ -4498,12 +3620,12 @@ dependencies = [ "ark-ff 0.4.2", "bytes", "fastrlp", - "num-bigint", + "num-bigint 0.4.6", "num-traits", "parity-scale-codec", "primitive-types", "proptest", - "rand 0.8.5", + "rand", "rlp", "ruint-macro", "serde", @@ -4538,7 +3660,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.72", + "syn 2.0.77", "walkdir", ] @@ -4558,7 +3680,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "ordered-multimap", ] @@ -4591,37 +3713,23 @@ dependencies = [ [[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 1.0.23", ] [[package]] name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.34" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.14", + "linux-raw-sys", "windows-sys 0.52.0", ] @@ -4633,24 +3741,10 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", - "rustls-webpki 0.101.7", + "rustls-webpki", "sct", ] -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" -dependencies = [ - "log", - "ring", - "rustls-pki-types", - "rustls-webpki 0.102.5", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -4658,20 +3752,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.4", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-native-certs" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" -dependencies = [ - "openssl-probe", - "rustls-pemfile 2.1.2", - "rustls-pki-types", + "rustls-pemfile", "schannel", "security-framework", ] @@ -4685,22 +3766,6 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64 0.22.1", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" - [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4711,23 +3776,24 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.102.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + [[package]] name = "ryu" version = "1.0.18" @@ -4743,22 +3809,46 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scale-info" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +dependencies = [ + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "scc" -version = "2.1.4" +version = "2.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4465c22496331e20eb047ff46e7366455bc01c0c02015c4a376de0b2cd3a1af" +checksum = "0c947adb109a8afce5fc9c7bf951f87f146e9147b3a6a58413105628fb1d1e66" dependencies = [ "sdd", ] [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4779,9 +3869,9 @@ dependencies = [ [[package]] name = "sdd" -version = "1.7.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85f05a494052771fc5bd0619742363b5e24e5ad72ab3111ec2e27925b8edc5f3" +checksum = "60a7b59a5d9b0099720b417b6325d91a52cbf5b3dcb5041d864be53eefa58abc" [[package]] name = "security-framework" @@ -4800,10 +3890,20 @@ dependencies = [ name = "security-framework-sys" version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semolina" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0111fd4fa831becb0606b9a2285ef3bee3c6a70d690209b8ae9514e9befe23" dependencies = [ - "core-foundation-sys", - "libc", + "cc", + "glob", ] [[package]] @@ -4832,13 +3932,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" 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_bytes" version = "0.11.15" @@ -4850,22 +3959,23 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ - "itoa 1.0.11", + "itoa", + "memchr", "ryu", "serde", ] @@ -4876,7 +3986,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ - "itoa 1.0.11", + "itoa", "serde", ] @@ -4888,14 +3998,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -4907,7 +4017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.11", + "itoa", "ryu", "serde", ] @@ -4934,7 +4044,7 @@ checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -4944,32 +4054,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.9.0", "opaque-debug", ] -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha1_smol" version = "1.0.1" @@ -4983,7 +4073,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.9.0", "opaque-debug", @@ -4992,14 +4082,23 @@ dependencies = [ [[package]] name = "sha2" version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +source = "git+https://github.com/sp1-patches/RustCrypto-hashes?branch=patch-sha2-v0.10.8#1f224388fdede7cef649bce0d63876d1a9e3f515" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest 0.10.7", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + [[package]] name = "shellexpand" version = "2.1.2" @@ -5009,6 +4108,12 @@ dependencies = [ "dirs 4.0.0", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -5024,7 +4129,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -5042,6 +4147,16 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "snowbridge-amcl" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460a9ed63cdf03c1b9847e8a12a5f5ba19c4efd5869e4a737e05be25d7c427e5" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + [[package]] name = "socket2" version = "0.4.10" @@ -5073,10 +4188,42 @@ dependencies = [ "futures", "httparse", "log", - "rand 0.8.5", + "rand", "sha-1", ] +[[package]] +name = "sp1-lib" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bea7811abd2d3a991007fcb284f41152840b8388c171288d0c52c6793956609c" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "hex", + "serde", + "snowbridge-amcl", +] + +[[package]] +name = "sp1-zkvm" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a777787c41fffb1ce1e74229f480223ce8d0ae66763aaac689cec737a19663e" +dependencies = [ + "bincode", + "cfg-if", + "getrandom", + "lazy_static", + "libm", + "once_cell", + "rand", + "serde", + "sha2 0.10.8", + "sp1-lib", +] + [[package]] name = "spin" version = "0.9.8" @@ -5094,10 +4241,14 @@ dependencies = [ ] [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "sppark" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "c55f3833d30846a26110dccb1d5366314c2c52516a9173b74238c16b24b1a9f9" +dependencies = [ + "cc", + "which", +] [[package]] name = "static_assertions" @@ -5105,12 +4256,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -5138,29 +4283,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "symbolic-common" -version = "12.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71297dc3e250f7dbdf8adb99e235da783d690f5819fdeb4cce39d9cfb0aca9f1" -dependencies = [ - "debugid", - "memmap2", - "stable_deref_trait", - "uuid", -] - -[[package]] -name = "symbolic-demangle" -version = "12.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424fa2c9bf2c862891b9cfd354a752751a6730fd838a4691e7f6c2c7957b9daf" -dependencies = [ - "cpp_demangle", - "rustc-demangle", - "symbolic-common", -] - [[package]] name = "syn" version = "1.0.109" @@ -5174,9 +4296,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -5192,7 +4314,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -5201,27 +4323,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -5230,14 +4331,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ - "cfg-if 1.0.0", - "fastrand 2.1.0", - "rustix 0.38.34", - "windows-sys 0.52.0", + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", ] [[package]] @@ -5255,12 +4357,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - [[package]] name = "thiserror" version = "1.0.63" @@ -5278,7 +4374,16 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", ] [[package]] @@ -5288,8 +4393,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", - "itoa 1.0.11", + "itoa", + "libc", "num-conv", + "num_threads", "powerfmt", "serde", "time-core", @@ -5348,42 +4455,31 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2 0.5.7", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", + "syn 2.0.77", ] [[package]] @@ -5392,51 +4488,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.12", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" -dependencies = [ - "rustls 0.22.4", - "rustls-pki-types", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", + "rustls", "tokio", ] [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -5448,21 +4508,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.16", + "toml_edit 0.22.20", ] [[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", ] @@ -5473,33 +4533,22 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.2.6", - "toml_datetime", - "winnow 0.5.40", -] - -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.2.6", + "indexmap", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.14", + "winnow 0.6.18", ] [[package]] @@ -5538,15 +4587,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -5568,7 +4617,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -5580,6 +4629,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "trait-set" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b79e2e9c9ab44c6d7c20d5976961b47e8f49ac199154daa514b77cd1ab536625" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "try-lock" version = "0.2.5" @@ -5606,7 +4666,7 @@ checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", - "hex 0.4.3", + "hex", "static_assertions", ] @@ -5633,9 +4693,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -5654,9 +4714,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-xid" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" [[package]] name = "universal-hash" @@ -5709,7 +4769,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82b1bc5417102a73e8464c686eef947bdfb99fcdfc0a4f228e81afa9526470a" dependencies = [ - "indexmap 2.2.6", + "indexmap", "serde", "serde_json", "utoipa-gen", @@ -5725,7 +4785,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -5744,12 +4804,6 @@ dependencies = [ "zip", ] -[[package]] -name = "uuid" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" - [[package]] name = "valuable" version = "0.1.0" @@ -5757,28 +4811,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] -name = "value-bag" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" - -[[package]] -name = "vcpkg" -version = "0.2.15" +name = "vergen" +version = "8.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +checksum = "2990d9ea5967266ea0ccf413a4aa5c42a93dbcfda9cb49a97de6931726b12566" +dependencies = [ + "anyhow", + "cfg-if", + "rustversion", + "time", +] [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] -name = "waker-fn" -version = "1.2.0" +name = "wait-timeout" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] [[package]] name = "walkdir" @@ -5799,12 +4856,6 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -5813,46 +4864,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5860,38 +4900,44 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "webpki-roots" -version = "0.25.4" +name = "which" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] [[package]] name = "winapi" @@ -5911,11 +4957,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -5924,15 +4970,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -5951,6 +4988,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -6083,23 +5129,13 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.14" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - [[package]] name = "wyz" version = "0.5.1" @@ -6124,6 +5160,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -6135,7 +5172,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -6155,7 +5192,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.77", ] [[package]] @@ -6169,31 +5206,3 @@ dependencies = [ "crossbeam-utils", "flate2", ] - -[[package]] -name = "zstd" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" -dependencies = [ - "zstd-safe", -] - -[[package]] -name = "zstd-safe" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" -dependencies = [ - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/Cargo.toml b/Cargo.toml index 25fb21e1..0eeb2a34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,4 @@ -[package] +[workspace.package] name = "prism" version = "0.1.0" authors = [ @@ -13,66 +13,86 @@ license = "MIT" keywords = ["crypto", "key-transparency"] readme = "README.md" -[features] -default = [] -key_transparency = [] +[workspace] +members = [ + "crates/prism", + "crates/common", + "crates/nova", + "crates/groth16", + "crates/errors", + "crates/sp1", +] +default-members = [ + "crates/prism", + "crates/common", + "crates/nova", + "crates/groth16", + "crates/errors", +] +resolver = "2" -[dependencies] +[workspace.dependencies] axum = "0.6" borsh = { version = "1.5.1", features = ["derive"] } tower-http = { version = "0.4", features = ["cors"] } utoipa = { version = "3.3", features = ["axum_extras"] } utoipa-swagger-ui = { version = "3.1", features = ["axum"] } -crypto-hash = "0.3.4" async-trait = "0.1.68" serde = { version = "1.0.151", features = ["derive"] } serde_json = "1.0.79" redis = "0.24.0" -actix-web = { version = "4.4.1" } -actix-cors = "0.7.0" -async-redis-session = "0.2.2" ed25519-dalek = "2.1.0" ed25519 = "2.2.0" base64 = "0.22.0" tokio = { version = "1.16.1", features = ["full"] } -reqwest = { version = "0.11.23", features = ["json"] } -ctrlc = "3.1.5" num = "0.4.0" bellman = "0.14.0" -pairing = "0.23.0" -jsonrpsee = { version = "0.22.2", features = ["ws-client"] } bls12_381 = "0.8.0" rand = "0.8.5" -rand07 = { package = "rand", version = "0.7.0" } hex = "0.4.3" ff = "0.13.0" -openssl = "0.10.66" -futures = "0.3" -lazy_static = "1.4" -colored = "2.0.0" log = "0.4" pretty_env_logger = "0.5.0" clap = { version = "4.3.2", features = ["derive"] } config = "0.14.0" -fs2 = "0.4.3" thiserror = "1.0.62" indexed-merkle-tree = "0.6.2" dotenvy = "0.15.7" -ahash = "0.8.7" celestia-rpc = "0.2.0" celestia-types = "0.2.0" mockall = "0.12.1" keystore-rs = "0.1.0" -pyroscope = "0.5.7" -pyroscope_pprofrs = "0.2.7" toml = "0.8.14" dirs = "5.0.1" anyhow = "1.0.44" +jmt = { version = "0.10.0", features = ["mocks"] } +bellpepper-core = { version = "0.4.0", default-features = false } +bellpepper = "0.4.1" +itertools = "0.13.0" # zip_eq +arecibo = "0.2.0" +sha2 = "0.10.8" +auto_impl = "1.2.0" +bincode = "1.3.3" +blake2 = "0.10.6" +sp1-zkvm = { version = "1.2.0" } +prism-common = { path = "crates/common" } +prism-nova = { path = "crates/nova" } +prism-errors = { path = "crates/errors" } +prism-main = { path = "crates/prism" } +prism-groth16 = { path = "crates/groth16" } +sp1-helper = "1.2.0" + +[patch.crates-io] +sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" } +arecibo = { git = "https://github.com/deltadevsde/arecibo" } +jmt = { git = "https://github.com/deltadevsde/jmt", branch = "rehashing-circuit", features = [ + "mocks", +] } -[dev-dependencies] -serial_test = "3.1.1" -criterion = "0.5.1" +# [workspace.dev-dependencies] +# serial_test = "3.1.1" +# criterion = "0.5.1" -[[bench]] -name = "zk_benchmarks" -harness = false +# [[bench]] +# name = "zk_benchmarks" +# harness = false diff --git a/README.md b/README.md index 110f966b..810a209f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## What is Prism? -Prism is a decentralized key transparency protocol, strongly inspired by the paper [Tzialla et. al](https://eprint.iacr.org/2021/1263.pdf), leveraging zkSNARKs to enable trust-minimized verification of E2EE services via WASM light clients. This eliminates the possibility for hidden backdoors in E2EE services through a user-verifiable key management system. It uses transparency dictionaries under the hood, offering a generalized solution for managing a label-value map in environments where the service maintaining the map is not completely trusted. +Prism is a decentralized key transparency protocol, first inspired by the paper [Tzialla et. al](https://eprint.iacr.org/2021/1263.pdf), leveraging zkSNARKs to enable trust-minimized verification of E2EE services via WASM light clients. This eliminates the possibility for hidden backdoors in E2EE services through a user-verifiable key management system. It uses transparency dictionaries under the hood, offering a generalized solution for managing a label-value map in environments where the service maintaining the map is not completely trusted. Prism provides the first key-transparency solution to enable automatic verification of the service provider. This is achieved by providing constant size succinct proofs to WASM light clients over a data availbility layer. The system is designed to be efficient, scalable and secure, making it suitable for a wide range of applications. @@ -30,6 +30,9 @@ The project is still in the early development phase, has not been audited, and i Due to this ongoing development work, changes are still being made that may affect existing functionalities. +## Circuits +We are currently experimenting with various proof systems and have handwritten groth16 and supernova circuits to handle the epoch proofs. We are also experimenting with SP1 as an alternative, which you can find in the `prism-sp1` crate. + ## Installation ### Prerequisites diff --git a/benches/zk_benchmarks.rs b/benches/zk_benchmarks.rs index b998df9d..f1f7c7f8 100644 --- a/benches/zk_benchmarks.rs +++ b/benches/zk_benchmarks.rs @@ -5,7 +5,6 @@ use indexed_merkle_tree::{ tree::{IndexedMerkleTree, Proof}, Hash, }; -use prism::{circuits::BatchMerkleProofCircuit, utils::validate_epoch}; use rand::Rng; use std::time::Duration; @@ -56,13 +55,13 @@ fn bench_proof_generation(c: &mut Criterion) { let (_, proofs, prev_commitment, current_commitment) = setup_tree_and_proofs(*tree_size, *batch_size); b.iter(|| { - let circuit = BatchMerkleProofCircuit::new( - black_box(&prev_commitment), - black_box(¤t_commitment), - black_box(proofs.clone()), - ) - .unwrap(); - let _ = circuit.create_and_verify_snark(); + // let circuit = BatchMerkleProofCircuit::new( + // black_box(&prev_commitment), + // black_box(¤t_commitment), + // black_box(proofs.clone()), + // ) + // .unwrap(); + // let _ = circuit.create_and_verify_snark(); }); }, ); @@ -85,17 +84,17 @@ fn bench_proof_verification(c: &mut Criterion) { |b, &(tree_size, batch_size)| { let (_, proofs, prev_commitment, current_commitment) = setup_tree_and_proofs(*tree_size, *batch_size); - let circuit = - BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs) - .unwrap(); - let (proof, verifying_key) = circuit.create_and_verify_snark().unwrap(); + // let circuit = + // BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs) + // .unwrap(); + // let (proof, verifying_key) = circuit.create_and_verify_snark().unwrap(); b.iter(|| { - let _ = validate_epoch( + /* let _ = validate_epoch( black_box(&prev_commitment), black_box(¤t_commitment), black_box(proof.clone()), black_box(verifying_key.clone()), - ); + ); */ }); }, ); diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml new file mode 100644 index 00000000..b1d85b90 --- /dev/null +++ b/crates/common/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "prism-common" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +anyhow.workspace = true +bls12_381.workspace = true +borsh.workspace = true +jmt.workspace = true +serde.workspace = true +hex.workspace = true +sha2.workspace = true +blake2.workspace = true +celestia-types.workspace = true diff --git a/crates/common/src/hashchain.rs b/crates/common/src/hashchain.rs new file mode 100644 index 00000000..9b96c6bb --- /dev/null +++ b/crates/common/src/hashchain.rs @@ -0,0 +1,158 @@ +use anyhow::{bail, Result}; +use borsh::{BorshDeserialize, BorshSerialize}; +use jmt::KeyHash; +use serde::{Deserialize, Serialize}; +use std::ops::{Deref, DerefMut}; + +use crate::{ + operation::{AccountSource, Operation}, + tree::{hash, Digest, Hasher}, +}; + +#[derive(Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq)] +pub struct Hashchain { + pub id: String, + pub entries: Vec, +} + +impl IntoIterator for Hashchain { + type Item = HashchainEntry; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.entries.into_iter() + } +} + +impl<'a> IntoIterator for &'a Hashchain { + type Item = &'a HashchainEntry; + type IntoIter = std::slice::Iter<'a, HashchainEntry>; + + fn into_iter(self) -> Self::IntoIter { + self.entries.iter() + } +} + +impl<'a> IntoIterator for &'a mut Hashchain { + type Item = &'a mut HashchainEntry; + type IntoIter = std::slice::IterMut<'a, HashchainEntry>; + + fn into_iter(self) -> Self::IntoIter { + self.entries.iter_mut() + } +} + +impl Deref for Hashchain { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.entries + } +} + +impl DerefMut for Hashchain { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.entries + } +} + +impl Hashchain { + pub fn new(id: String) -> Self { + Self { + id, + entries: Vec::new(), + } + } + + pub fn iter(&self) -> std::slice::Iter<'_, HashchainEntry> { + self.entries.iter() + } + + pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, HashchainEntry> { + self.entries.iter_mut() + } + + pub fn create_account(&mut self, value: String, source: AccountSource) -> Result { + let operation = Operation::CreateAccount { + id: self.id.clone(), + value, + source, + }; + self.push(operation) + } + + pub fn get(&self, idx: usize) -> &HashchainEntry { + &self.entries[idx] + } + + pub fn push(&mut self, operation: Operation) -> Result { + if operation.id() != self.id { + bail!("Operation ID does not match Hashchain ID"); + } + + let previous_hash = self + .entries + .last() + .map_or(Digest::new([0u8; 32]), |entry| entry.hash); + + let entry = HashchainEntry::new(operation, previous_hash); + self.entries.push(entry.clone()); + + Ok(entry.hash) + } + + // TODO: Obviously, this needs to be authenticated by an existing key. + pub fn add(&mut self, value: String) -> Result { + let operation = Operation::Add { + id: self.id.clone(), + value, + }; + self.push(operation) + } + + pub fn revoke(&mut self, value: String) -> Result { + let operation = Operation::Revoke { + id: self.id.clone(), + value, + }; + self.push(operation) + } + + pub fn get_keyhash(&self) -> KeyHash { + KeyHash::with::(self.id.clone()) + } + + pub fn is_empty(&self) -> bool { + self.entries.is_empty() + } + + pub fn len(&self) -> usize { + self.entries.len() + } +} + +#[derive(Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq)] +// A [`HashchainEntry`] represents a single entry in an account's hashchain. +// The value in the leaf of the corresponding account's node in the IMT is the hash of the last node in the hashchain. +pub struct HashchainEntry { + pub hash: Digest, + pub previous_hash: Digest, + pub operation: Operation, +} + +impl HashchainEntry { + pub fn new(operation: Operation, previous_hash: Digest) -> Self { + let hash = { + let mut data = Vec::new(); + data.extend_from_slice(operation.to_string().as_bytes()); + data.extend_from_slice(previous_hash.as_ref()); + // TODO: replace with sha256 after JMT complete + hash(&data) + }; + Self { + hash, + previous_hash, + operation, + } + } +} diff --git a/crates/common/src/lib.rs b/crates/common/src/lib.rs new file mode 100644 index 00000000..46e99a98 --- /dev/null +++ b/crates/common/src/lib.rs @@ -0,0 +1,3 @@ +pub mod hashchain; +pub mod operation; +pub mod tree; diff --git a/src/common.rs b/crates/common/src/operation.rs similarity index 67% rename from src/common.rs rename to crates/common/src/operation.rs index 8869da49..f0ecad5c 100644 --- a/src/common.rs +++ b/crates/common/src/operation.rs @@ -1,5 +1,6 @@ +use anyhow::{Context, Result}; use borsh::{BorshDeserialize, BorshSerialize}; -use indexed_merkle_tree::{sha256_mod, Hash}; +use celestia_types::Blob; use serde::{Deserialize, Serialize}; use std::fmt::Display; @@ -56,27 +57,11 @@ impl Display for Operation { } } -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] -// A [`HashchainEntry`] represents a single entry in an account's hashchain. -// The value in the leaf of the corresponding account's node in the IMT is the hash of the last node in the hashchain. -pub struct HashchainEntry { - pub hash: Hash, - pub previous_hash: Hash, - pub operation: Operation, -} +impl TryFrom<&Blob> for Operation { + type Error = anyhow::Error; -impl HashchainEntry { - pub fn new(operation: Operation, previous_hash: Hash) -> Self { - let hash = { - let mut data = Vec::new(); - data.extend_from_slice(operation.to_string().as_bytes()); - data.extend_from_slice(previous_hash.as_ref()); - sha256_mod(&data) - }; - Self { - hash, - previous_hash, - operation, - } + fn try_from(value: &Blob) -> Result { + borsh::from_slice::(&value.data) + .context(format!("Failed to decode blob into Operation: {value:?}")) } } diff --git a/crates/common/src/tree.rs b/crates/common/src/tree.rs new file mode 100644 index 00000000..f38588e3 --- /dev/null +++ b/crates/common/src/tree.rs @@ -0,0 +1,566 @@ +use anyhow::{anyhow, bail, Context, Result}; +use bls12_381::Scalar; +use borsh::{from_slice, to_vec, BorshDeserialize, BorshSerialize}; +use jmt::{ + proof::{SparseMerkleProof, UpdateMerkleProof}, + storage::{NodeBatch, TreeReader, TreeUpdateBatch, TreeWriter}, + JellyfishMerkleTree, KeyHash, RootHash, SimpleHasher, +}; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +use crate::hashchain::Hashchain; + +pub const SPARSE_MERKLE_PLACEHOLDER_HASH: Digest = + Digest::new(*b"SPARSE_MERKLE_PLACEHOLDER_HASH__"); + +pub type Hasher = blake2::Blake2s256; + +#[derive( + Debug, Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Copy, +)] +pub struct Digest([u8; 32]); + +impl Digest { + pub fn to_bytes(&self) -> [u8; 32] { + self.0 + } +} + +// implementing it for now to get things to compile, curve choice will be made later +impl TryFrom for Scalar { + type Error = anyhow::Error; + + fn try_from(value: Digest) -> Result { + let mut byte_array = [0u8; 32]; + byte_array.copy_from_slice(value.as_ref()); + byte_array.reverse(); + + let val = + [ + u64::from_le_bytes(byte_array[0..8].try_into().map_err(|_| { + anyhow!(format!("slice to array: [0..8] for digest: {value:?}")) + })?), + u64::from_le_bytes(byte_array[8..16].try_into().map_err(|_| { + anyhow!(format!("slice to array: [8..16] for digest: {value:?}")) + })?), + u64::from_le_bytes(byte_array[16..24].try_into().map_err(|_| { + anyhow!(format!("slice to array: [16..24] for digest: {value:?}")) + })?), + u64::from_le_bytes(byte_array[24..32].try_into().map_err(|_| { + anyhow!(format!("slice to array: [24..32] for digest: {value:?}")) + })?), + ]; + + Ok(Scalar::from_raw(val)) + } +} + +impl From for RootHash { + fn from(val: Digest) -> RootHash { + RootHash::from(val.0) + } +} + +impl From for Digest { + fn from(val: RootHash) -> Digest { + Digest(val.0) + } +} + +impl AsRef<[u8]> for Digest { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +impl std::fmt::Display for Digest { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.to_hex()) + } +} + +impl Digest { + pub const fn new(bytes: [u8; 32]) -> Self { + Digest(bytes) + } + + pub fn from_hex(hex_str: &str) -> Result { + let mut bytes = [0u8; 32]; + hex::decode_to_slice(hex_str, &mut bytes) + .map_err(|e| anyhow!(format!("Invalid Format: {e}")))?; + Ok(Digest(bytes)) + } + + pub fn to_hex(&self) -> String { + hex::encode(self.0) + } +} + +pub fn hash(data: &[u8]) -> Digest { + let mut hasher = blake2::Blake2s256::new(); + hasher.update(data); + Digest(hasher.finalize()) +} + +#[derive(Serialize, Deserialize)] +pub struct Batch { + pub prev_root: Digest, + pub new_root: Digest, + + pub proofs: Vec, +} + +impl Serialize for Proof { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let bytes = borsh::to_vec(self).map_err(serde::ser::Error::custom)?; + serializer.serialize_bytes(&bytes) + } +} + +impl<'de> Deserialize<'de> for Proof { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + struct ProofVisitor; + + impl<'de> serde::de::Visitor<'de> for ProofVisitor { + type Value = Proof; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("a byte array containing Borsh-serialized Proof") + } + + fn visit_bytes(self, v: &[u8]) -> Result + where + E: serde::de::Error, + { + Proof::try_from_slice(v).map_err(serde::de::Error::custom) + } + } + + deserializer.deserialize_bytes(ProofVisitor) + } +} + +#[derive(BorshSerialize, BorshDeserialize, Debug, Clone)] +pub enum Proof { + Update(UpdateProof), + Insert(InsertProof), +} + +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] +pub struct NonMembershipProof { + pub root: Digest, + pub proof: SparseMerkleProof, + pub key: KeyHash, +} + +impl NonMembershipProof { + pub fn verify(&self) -> Result<()> { + self.proof.verify_nonexistence(self.root.into(), self.key) + } +} + +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] +pub struct InsertProof { + pub non_membership_proof: NonMembershipProof, + + pub new_root: Digest, + pub membership_proof: SparseMerkleProof, + pub value: Hashchain, +} + +impl InsertProof { + pub fn verify(&self) -> Result<()> { + self.non_membership_proof + .verify() + .context("Invalid NonMembershipProof")?; + + let value = to_vec(&self.value).unwrap(); + + self.membership_proof.clone().verify_existence( + self.new_root.into(), + self.non_membership_proof.key, + value, + )?; + + Ok(()) + } +} + +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] +pub struct UpdateProof { + pub old_root: RootHash, + pub new_root: RootHash, + + pub key: KeyHash, + pub new_value: Hashchain, + + pub proof: UpdateMerkleProof, +} + +impl UpdateProof { + pub fn verify(&self) -> Result<()> { + let new_value = to_vec(&self.new_value).unwrap(); + + self.proof.clone().verify_update( + self.old_root, + self.new_root, + vec![(self.key, Some(new_value))], + ) + } +} + +pub trait SnarkableTree { + fn insert(&mut self, key: KeyHash, value: Hashchain) -> Result; + fn update(&mut self, key: KeyHash, value: Hashchain) -> Result; + fn get(&self, key: KeyHash) -> Result>; +} + +pub struct KeyDirectoryTree +where + S: TreeReader + TreeWriter, +{ + jmt: JellyfishMerkleTree, Hasher>, + pending_batch: Option, + epoch: u64, + db: Arc, +} + +impl KeyDirectoryTree +where + S: TreeReader + TreeWriter, +{ + pub fn new(store: Arc) -> Self { + let tree = Self { + db: store.clone(), + jmt: JellyfishMerkleTree::, Hasher>::new(store), + pending_batch: None, + epoch: 0, + }; + let (_, batch) = tree + .jmt + .put_value_set(vec![(KeyHash(SPARSE_MERKLE_PLACEHOLDER_HASH.0), None)], 0) + .unwrap(); + tree.db.write_node_batch(&batch.node_batch).unwrap(); + tree + } + + pub fn get_commitment(&self) -> Result { + let root = self.get_current_root()?; + Ok(Digest(root.0)) + } + + fn queue_batch(&mut self, batch: TreeUpdateBatch) { + match self.pending_batch { + Some(ref mut pending_batch) => pending_batch.merge(batch.node_batch), + None => self.pending_batch = Some(batch.node_batch), + } + } + + fn write_batch(&mut self) -> Result<()> { + if let Some(batch) = self.pending_batch.take() { + self.db.write_node_batch(&batch)?; + self.epoch += 1; + } + Ok(()) + } + + pub fn get_current_root(&self) -> Result { + self.jmt + .get_root_hash(self.epoch) + .map_err(|e| anyhow!("Failed to get root hash: {}", e)) + } + + fn serialize_value(value: &Hashchain) -> Result> { + to_vec(value).map_err(|e| anyhow!("Failed to serialize value: {}", e)) + } + + fn deserialize_value(bytes: &[u8]) -> Result { + from_slice::(bytes).map_err(|e| anyhow!("Failed to deserialize value: {}", e)) + } +} + +impl SnarkableTree for KeyDirectoryTree +where + S: TreeReader + TreeWriter, +{ + fn insert(&mut self, key: KeyHash, value: Hashchain) -> Result { + let serialized_value = Self::serialize_value(&value)?; + + let old_root = self.get_current_root()?; + println!("key: {:?}", key); + let (old_value, non_membership_merkle_proof) = self.jmt.get_with_proof(key, self.epoch)?; + + let non_membership_proof = NonMembershipProof { + root: old_root.into(), + proof: non_membership_merkle_proof, + key, + }; + + if old_value.is_some() { + bail!("Key already exists"); + } + + // the update proof just contains another nm proof + let (new_root, _, tree_update_batch) = self + .jmt + .put_value_set_with_proof(vec![(key, Some(serialized_value))], self.epoch + 1)?; + self.queue_batch(tree_update_batch); + self.write_batch()?; + + let (_, membership_proof) = self.jmt.get_with_proof(key, self.epoch)?; + + Ok(InsertProof { + new_root: new_root.into(), + value, + non_membership_proof, + membership_proof, + }) + } + + fn update(&mut self, key: KeyHash, value: Hashchain) -> Result { + let serialized_value = Self::serialize_value(&value)?; + + let old_root = self.get_current_root()?; + let (old_value, _) = self.jmt.get_with_proof(key, self.epoch)?; + + if old_value.is_none() { + bail!("Key does not exist"); + } + + let (new_root, proof, tree_update_batch) = self.jmt.put_value_set_with_proof( + vec![(key, Some(serialized_value.clone()))], + self.epoch + 1, + )?; + self.queue_batch(tree_update_batch); + self.write_batch()?; + + Ok(UpdateProof { + old_root, + new_root, + key, + new_value: value, + proof, + }) + } + + fn get(&self, key: KeyHash) -> Result> { + let (value, proof) = self.jmt.get_with_proof(key, self.epoch)?; + + match value { + Some(serialized_value) => { + let deserialized_value = Self::deserialize_value(&serialized_value)?; + Ok(Ok(deserialized_value)) + } + None => Ok(Err(NonMembershipProof { + root: self.get_current_root()?.into(), + proof, + key, + })), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use jmt::mock::MockTreeStore; + + #[test] + fn test_insert_and_get() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store.clone()); + + let hc1 = Hashchain::new("key_1".into()); + let key = hc1.get_keyhash(); + + println!("hc1: {:?}", hc1); + println!("key: {:?}", key); + + println!("Initial tree state: {:?}", tree.get_commitment()); + + let insert_proof = tree.insert(key, hc1.clone()); + assert!(insert_proof.is_ok()); + + println!("After first insert: {:?}", tree.get_commitment()); + + let get_result = tree.get(key).unwrap().unwrap(); + + assert_eq!(get_result, hc1); + } + + #[test] + fn test_insert_duplicate_key() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store); + + let hc1 = Hashchain::new("key_1".into()); + let key = hc1.get_keyhash(); + + tree.insert(key, hc1.clone()).unwrap(); + + let hc2 = Hashchain::new("key_1".into()); + let result = tree.insert(key, hc2); + assert!(result.is_err()); + } + + #[test] + fn test_update_existing_key() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store); + + let mut hc1 = Hashchain::new("key_1".into()); + let key = hc1.get_keyhash(); + + tree.insert(key, hc1.clone()).unwrap(); + + hc1.add("new_value".into()).unwrap(); + let update_proof = tree.update(key, hc1.clone()).unwrap(); + assert!(update_proof.verify().is_ok()); + + let get_result = tree.get(key).unwrap().unwrap(); + assert_eq!(get_result, hc1); + } + + #[test] + fn test_update_non_existing_key() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store); + + let hc1 = Hashchain::new("key_1".into()); + let key = hc1.get_keyhash(); + + let result = tree.update(key, hc1); + assert!(result.is_err()); + } + + #[test] + fn test_get_non_existing_key() { + let store = MockTreeStore::default(); + let tree = KeyDirectoryTree::new(Arc::new(store)); + + let key = KeyHash::with::(b"non_existing_key"); + let result = tree.get(key).unwrap(); + assert!(result.is_err()); + + if let Err(non_membership_proof) = result { + assert!(non_membership_proof.verify().is_ok()); + } + } + + #[test] + fn test_multiple_inserts_and_updates() { + let store = MockTreeStore::default(); + let mut tree = KeyDirectoryTree::new(Arc::new(store)); + + let mut hc1 = Hashchain::new("key_1".into()); + let mut hc2 = Hashchain::new("key_2".into()); + let key1 = hc1.get_keyhash(); + let key2 = hc2.get_keyhash(); + + tree.insert(key1, hc1.clone()).unwrap(); + tree.insert(key2, hc2.clone()).unwrap(); + + hc1.add("value1".into()).unwrap(); + hc2.add("value2".into()).unwrap(); + + tree.update(key1, hc1.clone()).unwrap(); + tree.update(key2, hc2.clone()).unwrap(); + + assert_eq!(tree.get(key1).unwrap().unwrap(), hc1); + assert_eq!(tree.get(key2).unwrap().unwrap(), hc2); + } + + #[test] + fn test_interleaved_inserts_and_updates() { + let store = MockTreeStore::default(); + let mut tree = KeyDirectoryTree::new(Arc::new(store)); + + let mut hc1 = Hashchain::new("key_1".into()); + let mut hc2 = Hashchain::new("key_2".into()); + let key1 = hc1.get_keyhash(); + let key2 = hc2.get_keyhash(); + + tree.insert(key1, hc1.clone()).unwrap(); + + hc1.add("value1".into()).unwrap(); + tree.update(key1, hc1.clone()).unwrap(); + + tree.insert(key2, hc2.clone()).unwrap(); + + hc2.add("value2".into()).unwrap(); + let last_proof = tree.update(key2, hc2.clone()).unwrap(); + + assert_eq!(tree.get(key1).unwrap().unwrap(), hc1); + assert_eq!(tree.get(key2).unwrap().unwrap(), hc2); + assert_eq!(last_proof.new_root, tree.get_current_root().unwrap()); + } + + #[test] + fn test_root_hash_changes() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store); + + let hc1 = Hashchain::new("key_1".into()); + let key1 = hc1.get_keyhash(); + + let root_before = tree.get_current_root().unwrap(); + tree.insert(key1, hc1).unwrap(); + let root_after = tree.get_current_root().unwrap(); + + assert_ne!(root_before, root_after); + } + + #[test] + fn test_batch_writing() { + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store.clone()); + + let hc1 = Hashchain::new("key_1".into()); + let key1 = hc1.get_keyhash(); + + println!("Inserting key1: {:?}", key1); + tree.insert(key1, hc1.clone()).unwrap(); + + println!("Tree state after first insert: {:?}", tree.get_commitment()); + println!( + "Tree state after first write_batch: {:?}", + tree.get_commitment() + ); + + // Try to get the first value immediately + let get_result1 = tree.get(key1); + println!("Get result for key1 after first write: {:?}", get_result1); + + let hc2 = Hashchain::new("key_2".into()); + let key2 = hc2.get_keyhash(); + + println!("Inserting key2: {:?}", key2); + tree.insert(key2, hc2.clone()).unwrap(); + + println!( + "Tree state after second insert: {:?}", + tree.get_commitment() + ); + println!( + "Tree state after second write_batch: {:?}", + tree.get_commitment() + ); + + // Try to get both values + let get_result1 = tree.get(key1); + let get_result2 = tree.get(key2); + + println!("Final get result for key1: {:?}", get_result1); + println!("Final get result for key2: {:?}", get_result2); + + assert_eq!(get_result1.unwrap().unwrap(), hc1); + assert_eq!(get_result2.unwrap().unwrap(), hc2); + } +} diff --git a/crates/errors/Cargo.toml b/crates/errors/Cargo.toml new file mode 100644 index 00000000..cdd976a5 --- /dev/null +++ b/crates/errors/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "prism-errors" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +ed25519-dalek = { workspace = true } +ed25519 = { workspace = true } +thiserror = { workspace = true } +anyhow = { workspace = true } +sha2 = { workspace = true } diff --git a/src/error.rs b/crates/errors/src/lib.rs similarity index 100% rename from src/error.rs rename to crates/errors/src/lib.rs diff --git a/crates/groth16/Cargo.toml b/crates/groth16/Cargo.toml new file mode 100644 index 00000000..c4f7fb39 --- /dev/null +++ b/crates/groth16/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "prism-groth16" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +borsh = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +ed25519-dalek = { workspace = true } +ed25519 = { workspace = true } +bellman = { workspace = true } +bls12_381 = { workspace = true } +rand = { workspace = true } +hex = { workspace = true } +ff = { workspace = true } +log = { workspace = true } +thiserror = { workspace = true } +indexed-merkle-tree = { workspace = true } +celestia-types = { workspace = true } +anyhow = { workspace = true } +jmt = { workspace = true } +sha2 = { workspace = true } +prism-common = { workspace = true } +prism-errors = { workspace = true } diff --git a/crates/groth16/README.md b/crates/groth16/README.md new file mode 100644 index 00000000..9b91222f --- /dev/null +++ b/crates/groth16/README.md @@ -0,0 +1,4 @@ +# Groth16 Circuits + +This crate implements the initial PoC circuits. Because the Batch structure changes for every proof, a new pk/vk is generated for every epoch which was just for experimentation. +These circuits do not include the merkle verification on this branch. diff --git a/src/circuits/hashchain.rs b/crates/groth16/src/hashchain.rs similarity index 97% rename from src/circuits/hashchain.rs rename to crates/groth16/src/hashchain.rs index 32e3707a..bc52cdfb 100644 --- a/src/circuits/hashchain.rs +++ b/crates/groth16/src/hashchain.rs @@ -1,8 +1,8 @@ -use crate::common::HashchainEntry; use anyhow::Result; use bellman::{Circuit, ConstraintSystem, SynthesisError}; use bls12_381::Scalar; use indexed_merkle_tree::sha256_mod; +use prism_common::hashchain::HashchainEntry; /// HashChainEntryCircuit is a circuit that verifies that a given value is present in a hashchain. #[derive(Clone)] diff --git a/src/circuits/less_than.rs b/crates/groth16/src/less_than.rs similarity index 100% rename from src/circuits/less_than.rs rename to crates/groth16/src/less_than.rs diff --git a/src/circuits/mod.rs b/crates/groth16/src/lib.rs similarity index 98% rename from src/circuits/mod.rs rename to crates/groth16/src/lib.rs index 69a2cc7c..9dec6d3c 100644 --- a/src/circuits/mod.rs +++ b/crates/groth16/src/lib.rs @@ -1,8 +1,8 @@ -use crate::error::{GeneralError, PrismError}; use anyhow::{anyhow, Context, Result}; use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError}; use bls12_381::{Bls12, G1Affine, G2Affine, Scalar}; use borsh::{BorshDeserialize, BorshSerialize}; +use prism_errors::{GeneralError, PrismError}; use std::fmt; pub mod hashchain; @@ -11,6 +11,8 @@ pub mod merkle_batch; pub mod merkle_insertion; pub mod merkle_update; pub mod utils; +#[macro_use] +extern crate log; pub use hashchain::HashChainEntryCircuit; pub use less_than::LessThanCircuit; @@ -20,8 +22,8 @@ pub use merkle_update::UpdateMerkleProofCircuit; #[derive(Clone)] pub enum ProofVariantCircuit { - Update(UpdateMerkleProofCircuit), - Insert(InsertMerkleProofCircuit), + Update(Box), + Insert(Box), Batch(BatchMerkleProofCircuit), } diff --git a/src/circuits/merkle_batch.rs b/crates/groth16/src/merkle_batch.rs similarity index 95% rename from src/circuits/merkle_batch.rs rename to crates/groth16/src/merkle_batch.rs index 2323ac50..a042d561 100644 --- a/src/circuits/merkle_batch.rs +++ b/crates/groth16/src/merkle_batch.rs @@ -1,9 +1,6 @@ use crate::{ - circuits::{ - merkle_insertion::prove_insertion, merkle_update::prove_update, InsertMerkleProofCircuit, - ProofVariantCircuit, UpdateMerkleProofCircuit, - }, - utils::create_and_verify_snark, + merkle_insertion::prove_insertion, merkle_update::prove_update, utils::create_and_verify_snark, + InsertMerkleProofCircuit, ProofVariantCircuit, UpdateMerkleProofCircuit, }; use anyhow::Result; use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError}; @@ -30,14 +27,14 @@ impl BatchMerkleProofCircuit { for proof in proofs { match proof { Proof::Update(update_proof) => { - proof_circuit_array.push(ProofVariantCircuit::Update( + proof_circuit_array.push(ProofVariantCircuit::Update(Box::new( UpdateMerkleProofCircuit::new(&update_proof)?, - )); + ))); } Proof::Insert(insertion_proof) => { - proof_circuit_array.push(ProofVariantCircuit::Insert( + proof_circuit_array.push(ProofVariantCircuit::Insert(Box::new( InsertMerkleProofCircuit::new(&insertion_proof)?, - )); + ))); } } } diff --git a/src/circuits/merkle_insertion.rs b/crates/groth16/src/merkle_insertion.rs similarity index 95% rename from src/circuits/merkle_insertion.rs rename to crates/groth16/src/merkle_insertion.rs index ddd1a628..cb9b94d9 100644 --- a/src/circuits/merkle_insertion.rs +++ b/crates/groth16/src/merkle_insertion.rs @@ -1,11 +1,7 @@ use crate::{ - circuits::{ - merkle_update::prove_update, - utils::{recalculate_hash_as_scalar, unpack_and_process}, - LessThanCircuit, ProofVariantCircuit, UpdateMerkleProofCircuit, - }, - error::PrismError, - utils::create_and_verify_snark, + merkle_update::prove_update, + utils::{create_and_verify_snark, recalculate_hash_as_scalar, unpack_and_process}, + LessThanCircuit, ProofVariantCircuit, UpdateMerkleProofCircuit, }; use anyhow::Result; use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError}; @@ -14,6 +10,7 @@ use indexed_merkle_tree::{ node::{LeafNode, Node}, tree::InsertProof, }; +use prism_errors::PrismError; /// Represents a circuit for proving the insertion of a new leaf into a the IMT. /// @@ -63,7 +60,7 @@ impl InsertMerkleProofCircuit { self.new_leaf_activation.updated_root, ]; - create_and_verify_snark(ProofVariantCircuit::Insert(self.clone()), scalars) + create_and_verify_snark(ProofVariantCircuit::Insert(Box::new(self.clone())), scalars) } } diff --git a/src/circuits/merkle_update.rs b/crates/groth16/src/merkle_update.rs similarity index 94% rename from src/circuits/merkle_update.rs rename to crates/groth16/src/merkle_update.rs index 67840e63..cb850b7f 100644 --- a/src/circuits/merkle_update.rs +++ b/crates/groth16/src/merkle_update.rs @@ -1,12 +1,12 @@ -use crate::circuits::{ - utils::{recalculate_hash_as_scalar, unpack_and_process}, +use crate::{ + utils::{create_and_verify_snark, recalculate_hash_as_scalar, unpack_and_process}, ProofVariantCircuit, }; -use crate::{error::PrismError, utils::create_and_verify_snark}; use anyhow::Result; use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError}; use bls12_381::{Bls12, Scalar}; use indexed_merkle_tree::{node::Node, tree::UpdateProof}; +use prism_errors::PrismError; #[derive(Clone)] pub struct UpdateMerkleProofCircuit { @@ -55,7 +55,7 @@ impl UpdateMerkleProofCircuit { ) -> Result<(groth16::Proof, groth16::VerifyingKey)> { let scalars: Vec = vec![self.old_root, self.updated_root]; - create_and_verify_snark(ProofVariantCircuit::Update(self.clone()), scalars) + create_and_verify_snark(ProofVariantCircuit::Update(Box::new(self.clone())), scalars) } } diff --git a/crates/groth16/src/utils.rs b/crates/groth16/src/utils.rs new file mode 100644 index 00000000..f4147840 --- /dev/null +++ b/crates/groth16/src/utils.rs @@ -0,0 +1,90 @@ +use crate::ProofVariantCircuit; +use anyhow::{anyhow, Result}; +use bellman::groth16::{self, VerifyingKey}; +use bls12_381::{Bls12, Scalar}; +use indexed_merkle_tree::{node::Node, sha256_mod, tree::MerkleProof, Hash}; +use prism_errors::{GeneralError, PrismError, ProofError}; +use rand::rngs::OsRng; + +pub fn create_and_verify_snark( + circuit: ProofVariantCircuit, + scalars: Vec, +) -> Result<(groth16::Proof, VerifyingKey)> { + let rng = &mut OsRng; + + trace!("creating parameters with BLS12-381 pairing-friendly elliptic curve construction...."); + let params = + groth16::generate_random_parameters::(circuit.clone(), rng).map_err(|e| { + PrismError::Proof(ProofError::ProofUnpackError(format!( + "generating random params: {}", + e + ))) + })?; + + trace!("creating proof for zkSNARK..."); + let proof = groth16::create_random_proof(circuit, ¶ms, rng) + .map_err(|e| PrismError::Proof(ProofError::GenerationError(e.to_string())))?; + + trace!("preparing verifying key for zkSNARK..."); + let pvk = groth16::prepare_verifying_key(¶ms.vk); + + groth16::verify_proof(&pvk, &proof, &scalars) + .map_err(|e| PrismError::Proof(ProofError::VerificationError(e.to_string())))?; + + Ok((proof, params.vk)) +} + +pub fn unpack_and_process(proof: &MerkleProof) -> Result<(Scalar, &Vec)> { + if !proof.path.is_empty() { + let root: Scalar = proof.root_hash.try_into()?; + Ok((root, &proof.path)) + } else { + Err(anyhow!(ProofError::ProofUnpackError(format!( + "proof path is empty for root hash {}", + proof.root_hash + )))) + } +} + +pub fn validate_epoch( + previous_commitment: &Hash, + current_commitment: &Hash, + proof: groth16::Proof, + verifying_key: VerifyingKey, +) -> Result, PrismError> { + trace!("validate_epoch: preparing verifying key for zkSNARK"); + let pvk = groth16::prepare_verifying_key(&verifying_key); + + let scalars: Result, _> = vec![ + (*previous_commitment).try_into(), + (*current_commitment).try_into(), + ] + .into_iter() + .collect(); + + let scalars = scalars.map_err(|e| { + PrismError::General(GeneralError::ParsingError(format!( + "unable to parse public input parameters: {}", + e + ))) + })?; + + trace!("validate_epoch: verifying zkSNARK proof..."); + groth16::verify_proof(&pvk, &proof, &scalars) + .map_err(|e| PrismError::Proof(ProofError::VerificationError(e.to_string())))?; + + Ok(proof) +} + +pub fn recalculate_hash_as_scalar(path: &[Node]) -> Result { + let mut current_hash = path[0].get_hash(); + for node in path.iter().skip(1) { + let combined = if node.is_left_sibling() { + [node.get_hash().as_ref(), current_hash.as_ref()].concat() + } else { + [current_hash.as_ref(), node.get_hash().as_ref()].concat() + }; + current_hash = sha256_mod(&combined); + } + current_hash.try_into() +} diff --git a/crates/nova/Cargo.toml b/crates/nova/Cargo.toml new file mode 100644 index 00000000..1483105b --- /dev/null +++ b/crates/nova/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "prism-nova" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +borsh = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +ed25519 = { workspace = true } +base64 = { workspace = true } +num = { workspace = true } +bls12_381 = { workspace = true } +rand = { workspace = true } +hex = { workspace = true } +ff = { workspace = true } +thiserror = { workspace = true } +indexed-merkle-tree = { workspace = true } +celestia-types = { workspace = true } +anyhow = { workspace = true } +jmt = { workspace = true } +bellpepper-core = { workspace = true } +bellpepper = { workspace = true } +arecibo = { workspace = true } +itertools = { workspace = true } +sha2 = { workspace = true } +bincode = { workspace = true } +prism-common = { workspace = true } diff --git a/crates/nova/README.md b/crates/nova/README.md new file mode 100644 index 00000000..90d7a6d7 --- /dev/null +++ b/crates/nova/README.md @@ -0,0 +1,8 @@ +# SuperNova Circuits + +This crate implements jmt-based Update and Insert circuits, which get combined together for NIVC using Supernova recursive SNARKs. + +They are not currently in use, because after the switch from IMT to JMT the proof size became variable, leading to both the Update and Insert steps no longer being uniform across a batch - only the first few prover steps suceed before a InvalidWitnessLength error occurs. +There is an attempt to alleviate this by padding the JMT proofs to a max depth and using selectors but it is not complete yet. + +Performance is a concern, especially during the spartan compression, which takes orders of magnitudes longer than a simple groth16 batch. diff --git a/crates/nova/src/batch.rs b/crates/nova/src/batch.rs new file mode 100644 index 00000000..5e64a1e4 --- /dev/null +++ b/crates/nova/src/batch.rs @@ -0,0 +1,315 @@ +use super::{insert::InsertCircuit, update::UpdateCircuit}; +use arecibo::{ + supernova::{StepCircuit, TrivialSecondaryCircuit}, + traits::{CurveCycleEquipped, Dual, Engine}, +}; +use ff::{PrimeField, PrimeFieldBits}; +use prism_common::tree::{InsertProof, UpdateProof}; +use std::cell::RefCell; + +#[derive(Clone)] +pub struct EpochCircuitSequence +where + E1: CurveCycleEquipped, +{ + insert_circuits: Vec>, + update_circuits: Vec>, + rom: Vec, + insert_index: RefCell, + update_index: RefCell, +} + +impl EpochCircuitSequence +where + E1: CurveCycleEquipped, +{ + pub fn new(operations: Vec<(usize, EpochCircuit)>) -> Self { + let rom = operations.iter().map(|(op, _)| *op).collect(); + let (insert_circuits, update_circuits): (Vec<_>, Vec<_>) = operations + .into_iter() + .map(|(_, circuit)| circuit) + .partition(|circuit| matches!(circuit, EpochCircuit::Insert(_))); + + Self { + insert_circuits, + update_circuits, + rom, + insert_index: RefCell::new(0), + update_index: RefCell::new(0), + } + } + + pub fn reset_indices(&self) { + *self.insert_index.borrow_mut() = 0; + *self.update_index.borrow_mut() = 0; + } +} + +impl arecibo::supernova::NonUniformCircuit for EpochCircuitSequence +where + E1: CurveCycleEquipped, +{ + type C1 = EpochCircuit; + type C2 = TrivialSecondaryCircuit< as Engine>::Scalar>; + + fn num_circuits(&self) -> usize { + self.insert_circuits.len() + self.update_circuits.len() + } + + fn primary_circuit(&self, circuit_index: usize) -> Self::C1 { + let (circuits, index) = if circuit_index == 0 { + (&self.insert_circuits, &self.insert_index) + } else { + (&self.update_circuits, &self.update_index) + }; + + let mut current_index = index.borrow_mut(); + + if *current_index >= circuits.len() { + *current_index = 0; + } + + let circuit = circuits[*current_index].clone(); + *current_index += 1; + circuit + } + + fn secondary_circuit(&self) -> Self::C2 { + TrivialSecondaryCircuit::default() + } + + fn initial_circuit_index(&self) -> usize { + self.rom[0] + } +} + +#[derive(Clone)] +pub enum EpochCircuit { + Insert(InsertCircuit), + Update(UpdateCircuit), +} + +impl EpochCircuit { + pub fn new_insert(insertion_proof: InsertProof, rom_size: usize) -> Self { + Self::Insert(InsertCircuit::new(insertion_proof, rom_size)) + } + + pub fn new_update(update_proof: UpdateProof, rom_size: usize) -> Self { + Self::Update(UpdateCircuit::new(update_proof, rom_size)) + } +} + +impl StepCircuit for EpochCircuit { + fn arity(&self) -> usize { + match self { + Self::Insert(x) => x.arity(), + Self::Update(x) => x.arity(), + } + } + + fn synthesize>( + &self, + cs: &mut CS, + pc: Option<&bellpepper_core::num::AllocatedNum>, + z: &[bellpepper_core::num::AllocatedNum], + ) -> Result< + ( + Option>, + Vec>, + ), + bellpepper_core::SynthesisError, + > { + match self { + Self::Insert(x) => x.synthesize(cs, pc, z), + Self::Update(x) => x.synthesize(cs, pc, z), + } + } + + fn circuit_index(&self) -> usize { + match self { + Self::Insert(x) => x.circuit_index(), + Self::Update(x) => x.circuit_index(), + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::utils::Digest as NovaDigest; + use arecibo::{ + provider::PallasEngine, + supernova::{NonUniformCircuit, PublicParams, RecursiveSNARK}, + traits::snark::default_ck_hint, + }; + use ff::Field; + use jmt::{mock::MockTreeStore, KeyHash}; + use prism_common::{hashchain::Hashchain, tree::*}; + use rand::{rngs::StdRng, Rng, SeedableRng}; + use std::sync::Arc; + + use std::collections::HashSet; + + struct TestTreeState { + pub tree: KeyDirectoryTree, + inserted_keys: HashSet, + } + + impl TestTreeState { + fn new() -> Self { + let store = Arc::new(MockTreeStore::default()); + let tree = KeyDirectoryTree::new(store); + Self { + tree, + inserted_keys: HashSet::new(), + } + } + } + + fn create_random_insert(state: &mut TestTreeState, rng: &mut StdRng) -> InsertProof { + loop { + let random_string: String = (0..10) + .map(|_| rng.sample(rand::distributions::Alphanumeric) as char) + .collect(); + let hc = Hashchain::new(random_string); + let key = hc.get_keyhash(); + + if !state.inserted_keys.contains(&key) { + let proof = state.tree.insert(key, hc).expect("Insert should succeed"); + state.inserted_keys.insert(key); + println!("inserted key: {key:?}"); + return proof; + } + } + } + + fn create_random_update(state: &mut TestTreeState, rng: &mut StdRng) -> UpdateProof { + if state.inserted_keys.is_empty() { + panic!("No keys have been inserted yet. Cannot perform update."); + } + + let key = *state + .inserted_keys + .iter() + .nth(rng.gen_range(0..state.inserted_keys.len())) + .unwrap(); + let mut hc = state.tree.get(key).unwrap().unwrap(); + + let random_string: String = (0..10) + .map(|_| rng.sample(rand::distributions::Alphanumeric) as char) + .collect(); + hc.add(random_string) + .expect("Adding to hashchain should succeed"); + println!("updated key: {key:?}"); + + state.tree.update(key, hc).expect("Update should succeed") + } + + // ignored because proving in CI is slow + #[ignore] + #[test] + fn test_recursive_epoch_circuit_proof() { + type E1 = PallasEngine; + + let mut state = TestTreeState::new(); + let mut rng = StdRng::from_entropy(); + + let initial_commitment: ::Scalar = + NovaDigest::from_root_hash(state.tree.get_commitment().unwrap().into()) + .to_scalar() + .unwrap(); + + let operations = vec![ + ( + 0, + EpochCircuit::new_insert(create_random_insert(&mut state, &mut rng), 2), + ), + ( + 1, + EpochCircuit::new_update(create_random_update(&mut state, &mut rng), 2), + ), + // ( + // 0, + // EpochCircuit::new_insert(create_random_insert(&mut state, &mut rng), 3), + // ), + // ( + // 1, + // EpochCircuit::new_update(create_random_update(&mut state, &mut rng), 4), + // ), + ]; + + let circuit_sequence = EpochCircuitSequence::::new(operations); + + let pp = PublicParams::setup(&circuit_sequence, &*default_ck_hint(), &*default_ck_hint()); + + let mut z0_primary = vec![initial_commitment]; // Initial root + z0_primary.push(::Scalar::ZERO); // Initial ROM index + z0_primary.extend( + circuit_sequence + .rom + .iter() + .map(|&x| ::Scalar::from(x as u64)), + ); + + let z0_secondary = vec![< as Engine>::Scalar>::ONE]; + + let mut recursive_snark_option: Option> = None; + circuit_sequence.reset_indices(); + println!("ROM sequence: {:?}", circuit_sequence.rom); + for &op_code in circuit_sequence.rom.iter() { + println!("Processing operation: {}", op_code); + let primary_circuit = circuit_sequence.primary_circuit(op_code); + let secondary_circuit = circuit_sequence.secondary_circuit(); + + let mut recursive_snark = recursive_snark_option.unwrap_or_else(|| { + RecursiveSNARK::new( + &pp, + &circuit_sequence, + &primary_circuit, + &secondary_circuit, + &z0_primary, + &z0_secondary, + ) + .unwrap() + }); + + recursive_snark + .prove_step(&pp, &primary_circuit, &secondary_circuit) + .unwrap(); + + recursive_snark + .verify(&pp, &z0_primary, &z0_secondary) + .unwrap(); + + recursive_snark_option = Some(recursive_snark) + } + + assert!(recursive_snark_option.is_some()); + + let recursive_snark = recursive_snark_option.unwrap(); + + assert!(recursive_snark + .verify(&pp, &z0_primary, &z0_secondary) + .is_ok()); + + // Additional assertions + let zi_primary = recursive_snark.zi_primary(); + println!("Final primary state: {:?}", zi_primary); + + assert_eq!( + zi_primary.len(), + z0_primary.len(), + "Primary state vector length should remain constant" + ); + + let final_commitment: ::Scalar = + NovaDigest::new(state.tree.get_commitment().unwrap()) + .to_scalar() + .unwrap(); + + assert_eq!( + zi_primary[0], final_commitment, + "Final commitment should match the tree state" + ); + } +} diff --git a/crates/nova/src/insert.rs b/crates/nova/src/insert.rs new file mode 100644 index 00000000..a69b5d63 --- /dev/null +++ b/crates/nova/src/insert.rs @@ -0,0 +1,106 @@ +use crate::utils::{ + allocate_bits_to_binary_number, next_rom_index_and_pc, verify_membership_proof, Digest, +}; +use anyhow::Result; +use arecibo::supernova::StepCircuit; +use bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError}; +use ff::{PrimeField, PrimeFieldBits}; +use prism_common::tree::InsertProof; + +#[derive(Clone)] +pub struct InsertCircuit { + pub proof: InsertProof, + rom_size: usize, + _phantom: std::marker::PhantomData, +} + +impl InsertCircuit { + pub fn new(proof: InsertProof, rom_size: usize) -> Self { + Self { + proof, + rom_size, + _phantom: std::marker::PhantomData, + } + } +} + +impl StepCircuit for InsertCircuit { + fn arity(&self) -> usize { + 2 + self.rom_size // old_root + rom_index + rom[].len() + } + + fn synthesize>( + &self, + cs: &mut CS, + pc: Option<&AllocatedNum>, + z: &[AllocatedNum], + ) -> Result<(Option>, Vec>), SynthesisError> { + let old_root = &z[0]; + let rom_index = &z[1]; + let allocated_rom = &z[2..]; + + let pc = pc.ok_or(SynthesisError::AssignmentMissing)?; + + let (rom_index_next, pc_next) = next_rom_index_and_pc( + &mut cs.namespace(|| "next and rom_index and pc"), + rom_index, + allocated_rom, + pc, + )?; + + let pre_insertion_scalar = Digest::new(self.proof.non_membership_proof.root) + .to_scalar() + .map_err(|_| SynthesisError::Unsatisfiable); + let pre_insertion_root = + AllocatedNum::alloc(cs.namespace(|| "pre_insertion_root"), || { + pre_insertion_scalar + })?; + + cs.enforce( + || "z0 == pre_insertion_root", + |lc| lc + old_root.get_variable(), + |lc| lc + CS::one(), + |lc| lc + pre_insertion_root.get_variable(), + ); + + // Allocate the new root + let new_root = AllocatedNum::alloc(cs.namespace(|| "new_root"), || { + Digest::new(self.proof.new_root) + .to_scalar() + .map_err(|_| SynthesisError::Unsatisfiable) + })?; + + let new_root_bits = + allocate_bits_to_binary_number(cs, self.proof.membership_proof.root_hash().0.to_vec())?; + + self.proof + .verify() + .map_err(|_| SynthesisError::Unsatisfiable)?; + + // Verify the non-membership proof + // verify_non_membership_proof( + // cs.namespace(|| "non_membership_proof"), + // &self.proof.non_membership_proof, + // &old_root, + // &key_bits, + // )?; + + let leaf = &self + .proof + .membership_proof + .leaf() + .ok_or(SynthesisError::AssignmentMissing)?; + + verify_membership_proof(cs, &self.proof.membership_proof, new_root_bits, *leaf)?; + + let mut z_next = vec![new_root]; + z_next.push(rom_index_next); + z_next.extend(z[2..].iter().cloned()); + + Ok((Some(pc_next), z_next)) + } + + fn circuit_index(&self) -> usize { + 0 + } +} diff --git a/crates/nova/src/lib.rs b/crates/nova/src/lib.rs new file mode 100644 index 00000000..ef348743 --- /dev/null +++ b/crates/nova/src/lib.rs @@ -0,0 +1,4 @@ +pub mod batch; +pub mod insert; +pub mod update; +pub mod utils; diff --git a/crates/nova/src/update.rs b/crates/nova/src/update.rs new file mode 100644 index 00000000..894205ea --- /dev/null +++ b/crates/nova/src/update.rs @@ -0,0 +1,101 @@ +use crate::utils::{ + allocate_bits_to_binary_number, next_rom_index_and_pc, verify_membership_proof, + Digest as NovaDigest, +}; +use anyhow::Result; +use arecibo::supernova::StepCircuit; +use bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError}; +use ff::{PrimeField, PrimeFieldBits}; +use prism_common::tree::UpdateProof; + +#[derive(Clone)] +pub struct UpdateCircuit { + pub update_proof: UpdateProof, + rom_size: usize, + _phantom: std::marker::PhantomData, +} + +impl UpdateCircuit { + pub fn new(update_proof: UpdateProof, rom_size: usize) -> Self { + Self { + update_proof, + rom_size, + _phantom: std::marker::PhantomData, + } + } +} + +impl StepCircuit for UpdateCircuit +where + F: PrimeField + PrimeFieldBits, +{ + fn arity(&self) -> usize { + 2 + self.rom_size // old_root + rom_index + rom[].len() + } + + fn circuit_index(&self) -> usize { + 1 + } + + fn synthesize>( + &self, + cs: &mut CS, + pc: Option<&AllocatedNum>, + z: &[AllocatedNum], + ) -> Result<(Option>, Vec>), SynthesisError> { + let old_root = &z[0]; + let rom_index = &z[1]; + let allocated_rom = &z[2..]; + + let pc = pc.ok_or(SynthesisError::AssignmentMissing)?; + + let (rom_index_next, pc_next) = next_rom_index_and_pc( + &mut cs.namespace(|| "next rom_index and pc"), + rom_index, + allocated_rom, + pc, + )?; + + let pre_insertion_scalar = NovaDigest::from_root_hash(self.update_proof.old_root) + .to_scalar() + .map_err(|_| SynthesisError::Unsatisfiable); + let pre_insertion_root = + AllocatedNum::alloc(cs.namespace(|| "pre_insertion_root"), || { + pre_insertion_scalar + })?; + let new_scalar = NovaDigest::from_root_hash(self.update_proof.new_root) + .to_scalar() + .map_err(|_| SynthesisError::Unsatisfiable); + let new_root = AllocatedNum::alloc(cs.namespace(|| "new_root"), || new_scalar)?; + + // TODO: The provided merkle root is an inclusion proof of the node before the update. + // We actually need to create our own merkle proof by hashing the new node to verify the update + let old_root_bits = + allocate_bits_to_binary_number(cs, self.update_proof.old_root.0.to_vec())?; + + cs.enforce( + || "z0 == pre_insertion_root", + |lc| lc + old_root.get_variable(), + |lc| lc + CS::one(), + |lc| lc + pre_insertion_root.get_variable(), + ); + + let update_proof = &self.update_proof.proof.proofs()[0]; + + let leaf = &update_proof + .leaf() + .ok_or(SynthesisError::AssignmentMissing)?; + + verify_membership_proof(cs, update_proof, old_root_bits, *leaf)?; + + self.update_proof + .verify() + .map_err(|_| SynthesisError::Unsatisfiable)?; + + let mut z_next = vec![new_root]; + z_next.push(rom_index_next); + z_next.extend(z[2..].iter().cloned()); + + Ok((Some(pc_next), z_next)) + } +} diff --git a/crates/nova/src/utils.rs b/crates/nova/src/utils.rs new file mode 100644 index 00000000..f1eae530 --- /dev/null +++ b/crates/nova/src/utils.rs @@ -0,0 +1,441 @@ +// use bellpepper_core::ConstraintSystem; +use crate::batch::{EpochCircuit, EpochCircuitSequence}; +use anyhow::Result; +use arecibo::{provider::PallasEngine, supernova::PublicParams, traits::snark::default_ck_hint}; +use bellpepper::gadgets::sha256::sha256; +use bellpepper_core::{ + boolean::{AllocatedBit, Boolean}, + num::AllocatedNum, + ConstraintSystem, LinearCombination, SynthesisError, +}; +use ff::PrimeField; +use itertools::Itertools as _; +use jmt::{ + bytes32ext::Bytes32Ext, + mock::MockTreeStore, + proof::{SparseMerkleLeafNode, SparseMerkleNode, SparseMerkleProof, INTERNAL_DOMAIN_SEPARATOR}, + RootHash, +}; +use prism_common::{hashchain::Hashchain, tree::*}; +use std::{marker::PhantomData, sync::Arc}; + +use prism_common::tree; + +pub struct Digest { + digest: tree::Digest, + _p: PhantomData, +} + +impl Digest { + pub fn new(digest: tree::Digest) -> Self { + Self { + digest, + _p: PhantomData, + } + } + + pub fn from_root_hash(root_hash: RootHash) -> Self { + Self::new(root_hash.into()) + } + + // uses [`PrimeField::from_u128`] for inspiration. If the field element's capacity is not enough to hold the hash, + pub fn to_scalar(&self) -> Result { + let bytes = self.digest.as_ref(); + + // Convert the 32 bytes to two u128 values + let lower = u128::from_le_bytes(bytes[0..16].try_into()?); + let upper = u128::from_le_bytes(bytes[16..32].try_into()?); + + let mut tmp = Scalar::from_u128(upper); + for _ in 0..128 { + tmp = tmp.double(); + } + Ok(tmp + Scalar::from_u128(lower)) + } +} + +pub fn next_rom_index_and_pc>( + cs: &mut CS, + rom_index: &AllocatedNum, + allocated_rom: &[AllocatedNum], + pc: &AllocatedNum, +) -> Result<(AllocatedNum, AllocatedNum), SynthesisError> { + // Compute a selector for the current rom_index in allocated_rom + let current_rom_selector = get_selector_vec_from_index( + cs.namespace(|| "rom selector"), + rom_index, + allocated_rom.len(), + )?; + + // Enforce that allocated_rom[rom_index] = pc + for (rom, bit) in allocated_rom.iter().zip_eq(current_rom_selector.iter()) { + // if bit = 1, then rom = pc + // bit * (rom - pc) = 0 + cs.enforce( + || "enforce bit = 1 => rom = pc", + |lc| lc + &bit.lc(CS::one(), F::ONE), + |lc| lc + rom.get_variable() - pc.get_variable(), + |lc| lc, + ); + } + + // Get the index of the current rom, or the index of the invalid rom if no match + let current_rom_index = current_rom_selector + .iter() + .position(|bit| bit.get_value().is_some_and(|v| v)) + .unwrap_or_default(); + let next_rom_index = current_rom_index + 1; + + let rom_index_next = AllocatedNum::alloc_infallible(cs.namespace(|| "next rom index"), || { + F::from(next_rom_index as u64) + }); + cs.enforce( + || " rom_index + 1 - next_rom_index_num = 0", + |lc| lc, + |lc| lc, + |lc| lc + rom_index.get_variable() + CS::one() - rom_index_next.get_variable(), + ); + + // Allocate the next pc without checking. + // The next iteration will check whether the next pc is valid. + let pc_next = AllocatedNum::alloc_infallible(cs.namespace(|| "next pc"), || { + allocated_rom + .get(next_rom_index) + .and_then(|v| v.get_value()) + .unwrap_or(-F::ONE) + }); + + Ok((rom_index_next, pc_next)) +} + +/// Compute a selector vector `s` of size `num_indices`, such that +/// `s[i] == 1` if i == `target_index` and 0 otherwise. +pub fn get_selector_vec_from_index>( + mut cs: CS, + target_index: &AllocatedNum, + num_indices: usize, +) -> Result, SynthesisError> { + assert_ne!(num_indices, 0); + + // Compute the selector vector non-deterministically + let selector = (0..num_indices) + .map(|idx| { + // b <- idx == target_index + Ok(Boolean::Is(AllocatedBit::alloc( + cs.namespace(|| format!("allocate s_{:?}", idx)), + target_index.get_value().map(|v| v == F::from(idx as u64)), + )?)) + }) + .collect::, SynthesisError>>()?; + + // Enforce ∑ selector[i] = 1 + { + let selected_sum = selector.iter().fold(LinearCombination::zero(), |lc, bit| { + lc + &bit.lc(CS::one(), F::ONE) + }); + cs.enforce( + || "exactly-one-selection", + |_| selected_sum, + |lc| lc + CS::one(), + |lc| lc + CS::one(), + ); + } + + // Enforce `target_index - ∑ i * selector[i] = 0`` + { + let selected_value = selector + .iter() + .enumerate() + .fold(LinearCombination::zero(), |lc, (i, bit)| { + lc + &bit.lc(CS::one(), F::from(i as u64)) + }); + cs.enforce( + || "target_index - ∑ i * selector[i] = 0", + |lc| lc, + |lc| lc, + |lc| lc + target_index.get_variable() - &selected_value, + ); + } + + Ok(selector) +} + +pub fn create_pp() -> PublicParams { + type E1 = PallasEngine; + + let store = Arc::new(MockTreeStore::default()); + let mut tree = KeyDirectoryTree::new(store); + + let mut hc = Hashchain::new("publicparams".into()); + let key = hc.get_keyhash(); + + let insert_proof = tree.insert(key, hc.clone()).unwrap(); + + hc.add("test_value".into()).unwrap(); + let update_proof = tree.update(key, hc).unwrap(); + + let operations = vec![ + (0, EpochCircuit::new_insert(insert_proof, 2)), + (1, EpochCircuit::new_update(update_proof, 2)), + ]; + + let circuit_sequence = EpochCircuitSequence::::new(operations); + PublicParams::setup(&circuit_sequence, &*default_ck_hint(), &*default_ck_hint()) +} + +pub fn allocate_bits_to_binary_number>( + cs: &mut CS, + value: Vec, +) -> Result, SynthesisError> { + let bits: Vec = value + .iter() + .flat_map(|byte| (0..8).rev().map(move |i| (byte >> i) & 1 == 1)) + .collect(); + + let result: Result, SynthesisError> = bits + .into_iter() + .enumerate() + .map(|(i, bit)| { + let allocated_bit = + AllocatedBit::alloc(cs.namespace(|| format!("bit {}", i)), Some(bit))?; + Ok(Boolean::from(allocated_bit)) + }) + .collect(); + + result +} + +pub fn hash_node>( + cs: &mut CS, + node: &SparseMerkleNode, +) -> Result, SynthesisError> { + match node { + SparseMerkleNode::Leaf(node) => { + let node_bits = allocate_bits_to_binary_number(cs, node.to_bytes())?; + sha256(cs.namespace(|| "hash key"), &node_bits) + } + SparseMerkleNode::Internal(node) => { + let node_bits = allocate_bits_to_binary_number(cs, node.to_bytes())?; + sha256(cs.namespace(|| "hash key"), &node_bits) + } + SparseMerkleNode::Null => { + let node_bits = allocate_bits_to_binary_number( + cs, + SPARSE_MERKLE_PLACEHOLDER_HASH.to_bytes().to_vec(), + )?; + sha256( + cs.namespace(|| "placeholder"), + &[node_bits.clone(), node_bits.clone(), node_bits.clone()].concat(), + )?; + Ok(node_bits) + } + } +} + +// pub fn verify_membership_proof>( +// cs: &mut CS, +// proof: &SparseMerkleProof, +// root: &Vec, +// leaf: SparseMerkleLeafNode, +// ) -> Result<(), SynthesisError> { +// dbg!(proof); +// let mut current = hash_node(cs, &SparseMerkleNode::Leaf(leaf))?; + +// let element_key = leaf.key_hash; + +// for (i, (sibling, key_bit)) in proof +// .siblings() +// .iter() +// .zip( +// element_key +// .0 +// .iter_bits() +// .rev() +// .skip(256 - proof.siblings().len()), +// ) +// .enumerate() +// { +// let sibling_hash = hash_node(cs, sibling)?; +// let separator = allocate_bits_to_binary_number(cs, INTERNAL_DOMAIN_SEPARATOR.to_vec())?; + +// let mut result = Vec::new(); +// if key_bit { +// result.extend_from_slice(&separator); +// result.extend_from_slice(&sibling_hash); +// result.extend_from_slice(¤t); +// } else { +// result.extend_from_slice(&separator); +// result.extend_from_slice(¤t); +// result.extend_from_slice(&sibling_hash); +// } + +// current = sha256( +// cs.namespace(|| format!("hash node {}", i)), +// result.as_slice(), +// )?; +// } + +// for (i, (computed_bit, given_bit)) in current.iter().zip(root.iter()).enumerate() { +// Boolean::enforce_equal( +// cs.namespace(|| format!("root bit {} should be equal", i)), +// computed_bit, +// given_bit, +// )?; +// } + +// Ok(()) +// } + +pub fn verify_membership_proof>( + cs: &mut CS, + proof: &SparseMerkleProof, + root: Vec, + leaf: SparseMerkleLeafNode, +) -> Result<(), SynthesisError> { + let max_depth = 10; + let actual_depth = proof.siblings().len(); + + let mut current = hash_node(cs, &SparseMerkleNode::Leaf(leaf))?; + let element_key = leaf.key_hash; + + for i in 0..max_depth { + let cs = &mut cs.namespace(|| format!("proof step {}", i)); + + // Allocate sibling hash (use placeholder if beyond actual proof depth) + let sibling_hash = if i < actual_depth { + hash_node(cs, &proof.siblings()[i])? + } else { + let bits = allocate_bits_to_binary_number( + cs, + SPARSE_MERKLE_PLACEHOLDER_HASH.to_bytes().to_vec(), + )?; + sha256( + cs.namespace(|| "placeholder"), + &[bits.clone(), bits.clone(), bits.clone()].concat(), + )?; + bits + }; + + // Get the key bit + let key_bit = if i < actual_depth { + element_key.0.iter_bits().rev().nth(255 - i).unwrap() + } else { + false + }; + + let separator = allocate_bits_to_binary_number(cs, INTERNAL_DOMAIN_SEPARATOR.to_vec())?; + + let mut hash_input = Vec::new(); + if key_bit { + hash_input.extend_from_slice(&separator); + hash_input.extend_from_slice(&sibling_hash); + hash_input.extend_from_slice(¤t); + } else { + hash_input.extend_from_slice(&separator); + hash_input.extend_from_slice(¤t); + hash_input.extend_from_slice(&sibling_hash); + } + + let hashed = sha256(cs.namespace(|| "hash node"), &hash_input)?; + + if i < actual_depth { + current = hashed; + } + } + + // Final equality check + for (i, (computed_bit, given_bit)) in current.iter().zip(root.iter()).enumerate() { + Boolean::enforce_equal( + cs.namespace(|| format!("root bit {} should be equal", i)), + computed_bit, + given_bit, + )?; + } + + Ok(()) +} + +/// Helper function to conditionally swap two vectors of Booleans +#[allow(dead_code)] +fn conditionally_swap>( + cs: &mut CS, + a: &[Boolean], + b: &[Boolean], + condition: &Boolean, +) -> Result<(Vec, Vec), SynthesisError> { + let mut left = Vec::with_capacity(a.len()); + let mut right = Vec::with_capacity(a.len()); + + for (a_bit, b_bit) in a.iter().zip(b.iter()) { + let (left_bit, right_bit) = { + let and1 = Boolean::and(cs.namespace(|| "condition and a"), condition, a_bit)?; + let and2 = Boolean::and( + cs.namespace(|| "not condition a and b"), + &condition.not(), + b_bit, + )?; + + let left = Boolean::xor(cs.namespace(|| "left xor"), &and1, &and2)?; + + let and3 = Boolean::and(cs.namespace(|| "condition and b"), condition, b_bit)?; + let and4 = Boolean::and( + cs.namespace(|| "not condition and a"), + &condition.not(), + a_bit, + )?; + let right = Boolean::xor(cs.namespace(|| "right xor"), &and3, &and4)?; + + (left, right) + }; + + left.push(left_bit); + right.push(right_bit); + } + + Ok((left, right)) +} + +/// Helper function to conditionally select between two vectors of Booleans +#[allow(dead_code)] +fn conditionally_select_vector>( + cs: &mut CS, + condition: &Boolean, + a: &[Boolean], + b: &[Boolean], +) -> Result, SynthesisError> { + assert_eq!(a.len(), b.len()); + let mut result = Vec::with_capacity(a.len()); + + for (i, (a_bit, b_bit)) in a.iter().zip(b.iter()).enumerate() { + let cs = &mut cs.namespace(|| format!("select bit {}", i)); + let and1 = Boolean::and(cs.namespace(|| "condition and a"), condition, a_bit)?; + let and2 = Boolean::and( + cs.namespace(|| "not condition and b"), + &Boolean::not(condition), + b_bit, + )?; + + let selected_bit = Boolean::xor(cs.namespace(|| "xor"), &and1, &and2)?; + + result.push(selected_bit); + } + + Ok(result) +} + +#[allow(dead_code)] +fn boolvec_to_bytes(value: Vec) -> Vec { + let bits: Vec = value + .iter() + .map(|b| b.get_value().unwrap_or(false)) + .collect(); + + bits.chunks(8) + .map(|chunk| { + chunk + .iter() + .enumerate() + .fold(0u8, |acc, (i, &bit)| acc | ((bit as u8) << i)) + }) + .collect() +} diff --git a/crates/prism/Cargo.toml b/crates/prism/Cargo.toml new file mode 100644 index 00000000..dbc8d2a5 --- /dev/null +++ b/crates/prism/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "prism-main" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +axum = { workspace = true } +borsh = { workspace = true } +tower-http = { workspace = true } +utoipa = { workspace = true } +utoipa-swagger-ui = { workspace = true } +async-trait = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +redis = { workspace = true } +ed25519-dalek = { workspace = true } +ed25519 = { workspace = true } +base64 = { workspace = true } +tokio = { workspace = true } +bellman = { workspace = true } +bls12_381 = { workspace = true } +rand = { workspace = true } +hex = { workspace = true } +ff = { workspace = true } +log = { workspace = true } +pretty_env_logger = { workspace = true } +clap = { workspace = true } +config = { workspace = true } +thiserror = { workspace = true } +indexed-merkle-tree = { workspace = true } +dotenvy = { workspace = true } +celestia-rpc = { workspace = true } +celestia-types = { workspace = true } +mockall = { workspace = true } +keystore-rs = { workspace = true } +toml = { workspace = true } +dirs = { workspace = true } +anyhow = { workspace = true } +jmt = { workspace = true } +sha2 = { workspace = true } +auto_impl = { workspace = true } +prism-common = { workspace = true } +prism-errors = { workspace = true } +prism-groth16 = { workspace = true } + +[dev-dependencies] +serial_test = "3.1.1" +criterion = "0.5.1" diff --git a/src/cfg.rs b/crates/prism/src/cfg.rs similarity index 98% rename from src/cfg.rs rename to crates/prism/src/cfg.rs index d3217979..2b3c5d36 100644 --- a/src/cfg.rs +++ b/crates/prism/src/cfg.rs @@ -1,6 +1,8 @@ -use crate::consts::{DA_RETRY_COUNT, DA_RETRY_INTERVAL}; -use crate::da::memory::InMemoryDataAvailabilityLayer; -use crate::error::{DataAvailabilityError, GeneralError, PrismError}; +use crate::{ + consts::{DA_RETRY_COUNT, DA_RETRY_INTERVAL}, + da::memory::InMemoryDataAvailabilityLayer, +}; +use prism_errors::{DataAvailabilityError, GeneralError, PrismError}; use anyhow::{anyhow, Context, Result}; use clap::{Parser, Subcommand}; use config::{builder::DefaultState, ConfigBuilder, File}; diff --git a/src/consts.rs b/crates/prism/src/consts.rs similarity index 100% rename from src/consts.rs rename to crates/prism/src/consts.rs diff --git a/src/da/celestia.rs b/crates/prism/src/da/celestia.rs similarity index 96% rename from src/da/celestia.rs rename to crates/prism/src/da/celestia.rs index 27bd53ec..e3d77347 100644 --- a/src/da/celestia.rs +++ b/crates/prism/src/da/celestia.rs @@ -1,15 +1,15 @@ use crate::{ cfg::CelestiaConfig, - common::Operation, consts::CHANNEL_BUFFER_SIZE, da::{DataAvailabilityLayer, FinalizedEpoch}, - error::{DataAvailabilityError, GeneralError}, }; +use prism_errors::{DataAvailabilityError, GeneralError}; use anyhow::{anyhow, bail, Context, Result}; use async_trait::async_trait; use borsh::from_slice; use celestia_rpc::{BlobClient, Client, HeaderClient}; use celestia_types::{blob::GasPrice, nmt::Namespace, Blob}; +use prism_common::operation::Operation; use std::{self, sync::Arc}; use tokio::{ sync::{ @@ -29,15 +29,6 @@ impl TryFrom<&Blob> for FinalizedEpoch { } } -impl TryFrom<&Blob> for Operation { - type Error = anyhow::Error; - - fn try_from(value: &Blob) -> Result { - from_slice::(&value.data) - .context(format!("Failed to decode blob into Operation: {value:?}")) - } -} - pub struct CelestiaConnection { pub client: celestia_rpc::Client, pub snark_namespace: Namespace, diff --git a/src/da/memory.rs b/crates/prism/src/da/memory.rs similarity index 96% rename from src/da/memory.rs rename to crates/prism/src/da/memory.rs index 78efea9a..cc4651ad 100644 --- a/src/da/memory.rs +++ b/crates/prism/src/da/memory.rs @@ -1,12 +1,12 @@ -use crate::{ - common::Operation, - da::{DataAvailabilityLayer, FinalizedEpoch}, -}; +use crate::da::{DataAvailabilityLayer, FinalizedEpoch}; use anyhow::Result; use async_trait::async_trait; +use prism_common::operation::Operation; use std::sync::Arc; -use tokio::sync::{broadcast, RwLock}; -use tokio::time::{interval, Duration}; +use tokio::{ + sync::{broadcast, RwLock}, + time::{interval, Duration}, +}; #[derive(Clone, Debug)] pub struct Block { diff --git a/src/da/mod.rs b/crates/prism/src/da/mod.rs similarity index 87% rename from src/da/mod.rs rename to crates/prism/src/da/mod.rs index 3f10be05..2a279fc7 100644 --- a/src/da/mod.rs +++ b/crates/prism/src/da/mod.rs @@ -1,14 +1,10 @@ -use crate::{ - circuits::{Bls12Proof, VerifyingKey}, - common::Operation, - error::GeneralError, - utils::SignedContent, -}; +use crate::utils::SignedContent; use anyhow::Result; use async_trait::async_trait; use borsh::{BorshDeserialize, BorshSerialize}; use ed25519::Signature; -use indexed_merkle_tree::Hash; +use prism_common::{operation::Operation, tree::Digest}; +use prism_errors::GeneralError; use std::{self, str::FromStr}; pub mod celestia; @@ -18,10 +14,10 @@ pub mod memory; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug)] pub struct FinalizedEpoch { pub height: u64, - pub prev_commitment: Hash, - pub current_commitment: Hash, - pub proof: Bls12Proof, - pub verifying_key: VerifyingKey, + pub prev_commitment: Digest, + pub current_commitment: Digest, + // pub proof: Bls12Proof, + // pub verifying_key: VerifyingKey, pub signature: Option, } diff --git a/src/lib.rs b/crates/prism/src/lib.rs similarity index 74% rename from src/lib.rs rename to crates/prism/src/lib.rs index 7d93911b..6aff7332 100644 --- a/src/lib.rs +++ b/crates/prism/src/lib.rs @@ -1,9 +1,6 @@ pub mod cfg; -pub mod circuits; -pub mod common; pub mod consts; pub mod da; -pub mod error; pub mod node_types; pub mod storage; pub mod utils; diff --git a/src/main.rs b/crates/prism/src/main.rs similarity index 83% rename from src/main.rs rename to crates/prism/src/main.rs index 09d9079e..7f080e78 100644 --- a/src/main.rs +++ b/crates/prism/src/main.rs @@ -1,9 +1,6 @@ mod cfg; -pub mod circuits; -pub mod common; pub mod consts; pub mod da; -pub mod error; mod node_types; pub mod storage; mod utils; @@ -22,16 +19,16 @@ use storage::RedisConnection; extern crate log; /// The main function that initializes and runs a prism client. -#[actix_web::main] +#[tokio::main()] async fn main() -> std::io::Result<()> { let args = CommandLineArgs::parse(); + let config = load_config(args.clone()) .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; let da = initialize_da_layer(&config) .await .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; - let node: Arc = match args.command { Commands::LightClient {} => { let celestia_config = config.celestia_config.ok_or_else(|| { @@ -57,12 +54,16 @@ async fn main() -> std::io::Result<()> { .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; Arc::new( - Sequencer::new(Arc::new(redis_connections), da, config, signing_key).map_err( - |e| { - error!("error initializing sequencer: {}", e); - std::io::Error::new(std::io::ErrorKind::Other, e.to_string()) - }, - )?, + Sequencer::new( + Arc::new(Box::new(redis_connections)), + da, + config, + signing_key, + ) + .map_err(|e| { + error!("error initializing sequencer: {}", e); + std::io::Error::new(std::io::ErrorKind::Other, e.to_string()) + })?, ) } }; diff --git a/src/node_types/lightclient.rs b/crates/prism/src/node_types/lightclient.rs similarity index 63% rename from src/node_types/lightclient.rs rename to crates/prism/src/node_types/lightclient.rs index 75a7aeb2..fdbe2316 100644 --- a/src/node_types/lightclient.rs +++ b/crates/prism/src/node_types/lightclient.rs @@ -1,17 +1,11 @@ -use crate::{ - cfg::CelestiaConfig, - error::{DataAvailabilityError, GeneralError}, -}; +use crate::cfg::CelestiaConfig; use anyhow::{Context, Result}; use async_trait::async_trait; +use prism_errors::{DataAvailabilityError, GeneralError}; use std::{self, sync::Arc, time::Duration}; use tokio::{task::spawn, time::interval}; -use crate::{ - da::DataAvailabilityLayer, - node_types::NodeType, - utils::{validate_epoch, verify_signature}, -}; +use crate::{da::DataAvailabilityLayer, node_types::NodeType, utils::verify_signature}; pub struct LightClient { pub da: Arc, @@ -77,26 +71,26 @@ impl LightClient { // todo: verify adjacency to last heights, <- for this we need some sort of storage of epochs for epoch_json in epoch_json_vec { - let prev_commitment = &epoch_json.prev_commitment; - let current_commitment = &epoch_json.current_commitment; + // let prev_commitment = &epoch_json.prev_commitment; + // let current_commitment = &epoch_json.current_commitment; - let proof = match epoch_json.proof.clone().try_into() { - Ok(proof) => proof, - Err(e) => { - error!("failed to deserialize proof, skipping a blob at height {}: {:?}", i, e); - continue; - } - }; + // let proof = match epoch_json.proof.clone().try_into() { + // Ok(proof) => proof, + // Err(e) => { + // error!("failed to deserialize proof, skipping a blob at height {}: {:?}", i, e); + // continue; + // } + // }; // TODO(@distractedm1nd): i don't know rust yet but this seems like non-idiomatic rust - // is there not a Trait that can satisfy these properties for us? - let verifying_key = match epoch_json.verifying_key.clone().try_into() { - Ok(vk) => vk, - Err(e) => { - error!("failed to deserialize verifying key, skipping a blob at height {}: {:?}", i, e); - continue; - } - }; + // let verifying_key = match epoch_json.verifying_key.clone().try_into() { + // Ok(vk) => vk, + // Err(e) => { + // error!("failed to deserialize verifying key, skipping a blob at height {}: {:?}", i, e); + // continue; + // } + // }; // if the user does not add a verifying key, we will not verify the signature, // but only log a warning on startup @@ -105,27 +99,30 @@ impl LightClient { &epoch_json.clone(), self.verifying_key.clone(), ) { - Ok(_) => trace!("valid signature for epoch {}", epoch_json.height), + Ok(_) => trace!( + "valid signature for epoch {}", + epoch_json.height + ), Err(e) => { panic!("invalid signature in epoch {}: {:?}", i, e) } } } - match validate_epoch( - prev_commitment, - current_commitment, - proof, - verifying_key, - ) { - Ok(_) => { - info!( - "zkSNARK for epoch {} was validated successfully", - epoch_json.height - ) - } - Err(err) => panic!("failed to validate epoch: {:?}", err), - } + // match validate_epoch( + // prev_commitment, + // current_commitment, + // proof, + // verifying_key, + // ) { + // Ok(_) => { + // info!( + // "zkSNARK for epoch {} was validated successfully", + // epoch_json.height + // ) + // } + // Err(err) => panic!("failed to validate epoch: {:?}", err), + // } } } Err(e) => { @@ -136,6 +133,7 @@ impl LightClient { ticker.tick().await; // only for testing purposes current_position = target; // Update the current position to the latest target } - }).await + }) + .await } } diff --git a/src/node_types/mod.rs b/crates/prism/src/node_types/mod.rs similarity index 100% rename from src/node_types/mod.rs rename to crates/prism/src/node_types/mod.rs diff --git a/src/node_types/sequencer.rs b/crates/prism/src/node_types/sequencer.rs similarity index 87% rename from src/node_types/sequencer.rs rename to crates/prism/src/node_types/sequencer.rs index 7b0b3245..ffb25185 100644 --- a/src/node_types/sequencer.rs +++ b/crates/prism/src/node_types/sequencer.rs @@ -2,12 +2,8 @@ use anyhow::{Context, Result}; use async_trait::async_trait; use ed25519::Signature; use ed25519_dalek::{Signer, SigningKey}; -use indexed_merkle_tree::{ - node::Node, - sha256_mod, - tree::{IndexedMerkleTree, Proof}, - Hash, -}; +use jmt::KeyHash; +use prism_common::tree::{hash, Digest, Hasher, KeyDirectoryTree, Proof, SnarkableTree}; use std::{self, str::FromStr, sync::Arc}; use tokio::{ sync::{ @@ -19,19 +15,21 @@ use tokio::{ }; #[cfg(test)] -use crate::error::DataAvailabilityError; +use prism_errors::DataAvailabilityError; use crate::{ cfg::Config, - circuits::BatchMerkleProofCircuit, - common::{AccountSource, HashchainEntry, Operation}, consts::{CHANNEL_BUFFER_SIZE, DA_RETRY_COUNT, DA_RETRY_INTERVAL}, da::{DataAvailabilityLayer, FinalizedEpoch}, - error::{DatabaseError, GeneralError}, node_types::NodeType, storage::Database, webserver::{OperationInput, WebServer}, }; +use prism_common::{ + hashchain::{Hashchain, HashchainEntry}, + operation::{AccountSource, Operation}, +}; +use prism_errors::{DatabaseError, GeneralError}; pub struct Sequencer { pub db: Arc, @@ -48,7 +46,7 @@ pub struct Sequencer { // [`pending_operations`] is a buffer for operations that have not yet been // posted to the DA layer. pending_operations: Arc>>, - tree: Arc>, + tree: Arc>>>, epoch_buffer_tx: Arc>, epoch_buffer_rx: Arc>>, @@ -77,24 +75,25 @@ impl NodeType for Sequencer { impl Sequencer { pub fn new( - db: Arc, + db: Arc>, da: Arc, cfg: Config, key: SigningKey, ) -> Result { let (tx, rx) = channel(CHANNEL_BUFFER_SIZE); - let ws = cfg.webserver.context("Missing webserver configuration")?; - let start_height = cfg.celestia_config.unwrap_or_default().start_height; + // Create the KeyDirectory + let tree = Arc::new(Mutex::new(KeyDirectoryTree::new(db.clone()))); + Ok(Sequencer { - db, + db: db.clone(), da, ws: WebServer::new(ws), key, start_height, - tree: Arc::new(Mutex::new(IndexedMerkleTree::new_with_size(1024).unwrap())), + tree, pending_operations: Arc::new(Mutex::new(Vec::new())), epoch_buffer_tx: Arc::new(tx), epoch_buffer_rx: Arc::new(Mutex::new(rx)), @@ -103,13 +102,14 @@ impl Sequencer { // sync_loop is responsible for downloading operations from the DA layer async fn sync_loop(self: Arc) -> Result<(), tokio::task::JoinError> { + let self_clone = self.clone(); info!("starting operation sync loop"); let epoch_buffer = self.epoch_buffer_tx.clone(); spawn(async move { - let mut current_position = self.start_height; + let mut current_position = self_clone.start_height; loop { // target is updated when a new header is received - let target = match self.da.get_latest_height().await { + let target = match self_clone.da.get_latest_height().await { Ok(target) => target, Err(e) => { error!("failed to update sync target, retrying: {:?}", e); @@ -124,7 +124,7 @@ impl Sequencer { debug!("updated sync target to height {}", target); while current_position < target { trace!("processing height: {}", current_position); - match self.da.get_operations(current_position + 1).await { + match self_clone.da.get_operations(current_position + 1).await { Ok(operations) => { if !operations.is_empty() { debug!( @@ -133,7 +133,7 @@ impl Sequencer { ); } - let epoch = match self.finalize_epoch(operations).await { + let epoch = match self_clone.finalize_epoch(operations).await { Ok(e) => e, Err(e) => { error!("sequencer_loop: finalizing epoch: {}", e); @@ -262,7 +262,7 @@ impl Sequencer { .await } - pub async fn get_commitment(&self) -> Result { + pub async fn get_commitment(&self) -> Result { let tree = self.tree.lock().await; tree.get_commitment().context("Failed to get commitment") } @@ -280,7 +280,7 @@ impl Sequencer { "Failed to get commitment for previous epoch {}", prev_epoch ))?; - Hash::from_hex(&hash_string).context("Failed to parse commitment")? + Digest::from_hex(&hash_string).context("Failed to parse commitment")? } else { self.get_commitment().await? }; @@ -302,22 +302,22 @@ impl Sequencer { .context("Failed to set new epoch")?; // add the commitment for the operations ran since the last epoch self.db - .add_commitment(&epoch, ¤t_commitment) + .set_commitment(&epoch, ¤t_commitment) .context("Failed to add commitment for new epoch")?; - let batch_circuit = - BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs) - .context("Failed to create BatchMerkleProofCircuit")?; - let (proof, verifying_key) = batch_circuit - .create_and_verify_snark() - .context("Failed to create and verify snark")?; + // let batch_circuit = + // BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs) + // .context("Failed to create BatchMerkleProofCircuit")?; + // let (proof, verifying_key) = batch_circuit + // .create_and_verify_snark() + // .context("Failed to create and verify snark")?; let epoch_json = FinalizedEpoch { height: epoch, prev_commitment, current_commitment, - proof: proof.into(), - verifying_key: verifying_key.into(), + // proof: proof.into(), + // verifying_key: verifying_key.into(), signature: None, }; @@ -363,41 +363,24 @@ impl Sequencer { .context(format!("Failed to get hashchain for ID {}", id))?; let mut tree = self.tree.lock().await; - let hashed_id = sha256_mod(id.as_bytes()); - - let node = tree.find_leaf_by_label(&hashed_id).context(format!( - "Node with label {} not found in the tree", - hashed_id - ))?; + let hashed_id = hash(id.as_bytes()); let previous_hash = current_chain.last().context("Hashchain is empty")?.hash; let new_chain_entry = HashchainEntry::new(operation.clone(), previous_hash); - current_chain.push(new_chain_entry.clone()); - - let updated_node = Node::new_leaf( - node.is_left_sibling(), - hashed_id, - new_chain_entry.hash, - node.get_next(), - ); - - let index = tree.find_node_index(&node).context(format!( - "Node with label {} not found in the tree, but has a hashchain entry", - hashed_id - ))?; + current_chain.push(new_chain_entry.operation.clone())?; debug!("updating hashchain for user id {}", id.clone()); + let proof = + tree.update(KeyHash::with::(hashed_id), current_chain.clone())?; self.db - .update_hashchain(operation, ¤t_chain) + .set_hashchain(operation, ¤t_chain) .context(format!( "Failed to update hashchain for operation {:?}", operation ))?; - tree.update_node(index, updated_node) - .map(Proof::Update) - .context("Failed to update node in tree") + Ok(Proof::Update(proof)) } Operation::CreateAccount { id, value, source } => { // validation of account source @@ -412,7 +395,7 @@ impl Sequencer { } }?; - let hashchain: Result> = self.db.get_hashchain(id); + let hashchain: Result = self.db.get_hashchain(id); if hashchain.is_ok() { return Err(DatabaseError::NotFoundError(format!( "empty slot for ID {}", @@ -422,23 +405,20 @@ impl Sequencer { } debug!("creating new hashchain for user id {}", id.clone()); - let new_chain = vec![HashchainEntry::new(operation.clone(), Node::HEAD)]; + let mut chain = Hashchain::new(id.clone()); + chain.create_account(value.into(), source.clone())?; - self.db - .update_hashchain(operation, &new_chain) - .context(format!( - "Failed to create hashchain for operation {:?}", - operation - ))?; + self.db.set_hashchain(operation, &chain).context(format!( + "Failed to create hashchain for operation {:?}", + operation + ))?; let mut tree = self.tree.lock().await; - let hashed_id = sha256_mod(id.as_bytes()); + let hashed_id = hash(id.as_bytes()); - let mut node = - Node::new_leaf(true, hashed_id, new_chain.first().unwrap().hash, Node::TAIL); - tree.insert_node(&mut node) - .map(Proof::Insert) - .context("Failed to insert node into tree") + Ok(Proof::Insert( + tree.insert(KeyHash::with::(hashed_id), chain)?, + )) } } } @@ -476,7 +456,7 @@ mod tests { } // flush database after each test - fn teardown_db(redis_connections: &RedisConnection) { + fn teardown_db(redis_connections: Arc>) { redis_connections.flush_database().unwrap(); } @@ -484,7 +464,7 @@ mod tests { async fn create_test_sequencer() -> Arc { let (da_layer, _rx, _brx) = InMemoryDataAvailabilityLayer::new(1); let da_layer = Arc::new(da_layer); - let db = Arc::new(setup_db()); + let db: Arc> = Arc::new(Box::new(setup_db())); let signing_key = create_signing_key(); Arc::new( Sequencer::new(db.clone(), da_layer, Config::default(), signing_key.clone()).unwrap(), @@ -527,7 +507,7 @@ mod tests { async fn test_validate_and_queue_update() { let (da_layer, _rx, _brx) = InMemoryDataAvailabilityLayer::new(1); let da_layer = Arc::new(da_layer); - let db = Arc::new(setup_db()); + let db: Arc> = Arc::new(Box::new(setup_db())); let sequencer = Arc::new( Sequencer::new( db.clone(), @@ -545,7 +525,7 @@ mod tests { .validate_and_queue_update(&update_entry) .await .unwrap(); - teardown_db(&db); + teardown_db(db); } #[tokio::test] @@ -553,7 +533,7 @@ mod tests { async fn test_queued_update_gets_finalized() { let (da_layer, _rx, _brx) = InMemoryDataAvailabilityLayer::new(1); let da_layer = Arc::new(da_layer); - let db = Arc::new(setup_db()); + let db: Arc> = Arc::new(Box::new(setup_db())); let signing_key = create_signing_key(); let sequencer = Arc::new( Sequencer::new(db.clone(), da_layer, Config::default(), signing_key.clone()).unwrap(), @@ -580,10 +560,10 @@ mod tests { assert_ne!(prev_commitment, new_commitment); let hashchain = sequencer.db.get_hashchain(id.as_str()); - let value = hashchain.unwrap().first().unwrap().operation.value(); + let value = hashchain.unwrap().get(0).operation.value(); assert_eq!(value, "test"); - teardown_db(&db); + teardown_db(db); } #[tokio::test] @@ -591,7 +571,7 @@ mod tests { async fn test_validate_invalid_update_fails() { let (da_layer, _rx, _brx) = InMemoryDataAvailabilityLayer::new(1); let da_layer = Arc::new(da_layer); - let db = Arc::new(setup_db()); + let db: Arc> = Arc::new(Box::new(setup_db())); let sequencer = Arc::new( Sequencer::new( db.clone(), @@ -610,7 +590,7 @@ mod tests { let res = sequencer.validate_and_queue_update(&update_entry).await; assert!(res.is_err()); - teardown_db(&db); + teardown_db(db); } #[tokio::test] @@ -698,7 +678,7 @@ mod tests { let hashchain = sequencer.db.get_hashchain("user@example.com").unwrap(); assert_eq!(hashchain.len(), 2); - assert_eq!(hashchain[1].operation.value(), "new_value"); + assert_eq!(hashchain.get(1).operation.value(), "new_value"); } #[tokio::test] @@ -726,7 +706,10 @@ mod tests { let hashchain = sequencer.db.get_hashchain("user@example.com").unwrap(); assert_eq!(hashchain.len(), 2); - assert!(matches!(hashchain[1].operation, Operation::Revoke { .. })); + assert!(matches!( + hashchain.get(1).operation, + Operation::Revoke { .. } + )); } #[tokio::test] diff --git a/src/storage.rs b/crates/prism/src/storage.rs similarity index 51% rename from src/storage.rs rename to crates/prism/src/storage.rs index b93e864b..c2d21566 100644 --- a/src/storage.rs +++ b/crates/prism/src/storage.rs @@ -1,6 +1,10 @@ use anyhow::{anyhow, Result}; -use indexed_merkle_tree::{tree::Proof, Hash}; -use mockall::{predicate::*, *}; +use auto_impl::auto_impl; +use jmt::{ + storage::{LeafNode, Node, NodeBatch, NodeKey, TreeReader, TreeWriter}, + KeyHash, OwnedValue, Version, +}; +use mockall::predicate::*; use redis::{Client, Commands, Connection}; use std::{ self, @@ -10,46 +14,34 @@ use std::{ time::Duration, }; -use crate::{ - cfg::RedisConfig, - common::{HashchainEntry, Operation}, - error::{DatabaseError, GeneralError, PrismError}, - utils::parse_json_to_proof, +use crate::cfg::RedisConfig; +use prism_common::{ + hashchain::{Hashchain, HashchainEntry}, + operation::Operation, + tree::Digest, }; +use prism_errors::{DatabaseError, GeneralError, PrismError}; // there are different key prefixes for the different tables in the database -// main:key => clear text key with hashchain -// input_order => input order of the hashchain keys // app_state:key => app state (just epoch counter for now) -// merkle_proofs:key => merkle proofs (in the form: epoch_{epochnumber}_{commitment}) // commitments:key => epoch commitments pub struct RedisConnection { connection: Mutex, } -#[automock] -pub trait Database: Send + Sync { - fn get_keys(&self) -> Result>; - fn get_hashchain(&self, key: &str) -> Result>; +#[auto_impl(&, Box, Arc)] +pub trait Database: Send + Sync + TreeReader + TreeWriter { + fn get_hashchain(&self, key: &str) -> Result; + fn set_hashchain(&self, incoming_operation: &Operation, value: &[HashchainEntry]) + -> Result<()>; + fn get_commitment(&self, epoch: &u64) -> Result; - fn get_proof(&self, id: &str) -> Result; - fn get_proofs_in_epoch(&self, epoch: &u64) -> Result>; + fn set_commitment(&self, epoch: &u64, commitment: &Digest) -> Result<()>; + fn get_epoch(&self) -> Result; fn set_epoch(&self, epoch: &u64) -> Result<()>; - fn update_hashchain( - &self, - incoming_operation: &Operation, - value: &[HashchainEntry], - ) -> Result<()>; - fn get_epochs(&self) -> Result>; - fn add_merkle_proof( - &self, - epoch: &u64, - epoch_operation: &u64, - commitment: &Hash, - proofs: &str, - ) -> Result<()>; - fn add_commitment(&self, epoch: &u64, commitment: &Hash) -> Result<()>; + + #[cfg(test)] fn flush_database(&self) -> Result<()>; } @@ -96,23 +88,94 @@ impl RedisConnection { } } -impl Database for RedisConnection { - fn get_keys(&self) -> Result> { +impl TreeReader for RedisConnection { + fn get_node_option(&self, node_key: &NodeKey) -> Result> { + let mut con = self.lock_connection()?; + let serialized_key = hex::encode(borsh::to_vec(node_key)?); + let node_data: Option> = con.get(format!("node:{}", serialized_key))?; + Ok(node_data.map(|data| borsh::from_slice(&data).unwrap())) + } + + fn get_rightmost_leaf(&self) -> Result> { + let mut con = self.lock_connection()?; + let keys: Vec = con.keys("node:*")?; + let mut rightmost: Option<(NodeKey, LeafNode)> = None; + + for key in keys { + let node_data: Vec = con.get(&key)?; + let node: Node = borsh::from_slice(&node_data)?; + if let Node::Leaf(leaf_node) = node { + let node_key_bytes = hex::decode(key.strip_prefix("node:").unwrap())?; + let node_key: NodeKey = borsh::from_slice(&node_key_bytes)?; + if rightmost.is_none() + || leaf_node.key_hash() > rightmost.as_ref().unwrap().1.key_hash() + { + rightmost = Some((node_key, leaf_node)); + } + } + } + + Ok(rightmost) + } + + fn get_value_option( + &self, + max_version: Version, + key_hash: KeyHash, + ) -> Result> { + let mut con = self.lock_connection()?; + let value_key = format!("value_history:{}", hex::encode(key_hash.0)); + let values: Vec<(String, f64)> = + con.zrevrangebyscore_withscores(&value_key, max_version as f64, 0f64)?; + + if let Some((encoded_value, _)) = values.first() { + if encoded_value.is_empty() { + Ok(None) + } else { + Ok(Some(hex::decode(encoded_value)?)) + } + } else { + Ok(None) + } + } +} + +impl TreeWriter for RedisConnection { + fn write_node_batch(&self, node_batch: &NodeBatch) -> Result<()> { let mut con = self.lock_connection()?; - let keys: Vec = con - .keys("main:*") - .map_err(|_| DatabaseError::KeysError("main".to_string()))?; - Ok(keys.into_iter().map(|k| k.replace("main:", "")).collect()) + let mut pipe = redis::pipe(); + + for (node_key, node) in node_batch.nodes() { + let serialized_key = hex::encode(borsh::to_vec(node_key)?); + let node_data = borsh::to_vec(node)?; + pipe.set(format!("node:{}", serialized_key), node_data); + } + + for ((version, key_hash), value) in node_batch.values() { + let value_key = format!("value_history:{}", hex::encode(key_hash.0)); + let encoded_value = value.as_ref().map(hex::encode).unwrap_or_default(); + pipe.zadd(&value_key, encoded_value, *version as f64); + } + + pipe.execute(&mut con); + Ok(()) } +} - fn get_hashchain(&self, key: &str) -> Result> { +impl Database for RedisConnection { + fn get_hashchain(&self, key: &str) -> Result { let mut con = self.lock_connection()?; let value: String = con .get(format!("main:{}", key)) .map_err(|_| DatabaseError::NotFoundError(format!("hashchain key {}", key)))?; - serde_json::from_str(&value) - .map_err(|e| anyhow!(GeneralError::ParsingError(format!("hashchain: {}", e)))) + let res: Vec = serde_json::from_str(&value) + .map_err(|e| anyhow!(GeneralError::ParsingError(format!("hashchain: {}", e))))?; + + Ok(Hashchain { + id: key.to_string(), + entries: res, + }) } fn get_commitment(&self, epoch: &u64) -> Result { @@ -125,40 +188,6 @@ impl Database for RedisConnection { Ok(value.trim_matches('"').to_string()) } - fn get_proof(&self, id: &str) -> Result { - let mut con = self.lock_connection()?; - con.get(format!("merkle_proofs:{}", id)).map_err(|_| { - anyhow!(DatabaseError::NotFoundError(format!( - "Proof with id: {}", - id - ))) - }) - } - - fn get_proofs_in_epoch(&self, epoch: &u64) -> Result> { - let mut con = self.lock_connection()?; - let mut epoch_proofs: Vec = con - .keys::<&String, Vec>(&format!("merkle_proofs:epoch_{}*", epoch)) - .map_err(|_| DatabaseError::NotFoundError(format!("epoch: {}", epoch)))?; - - epoch_proofs.sort_by(|a, b| { - let a_parts: Vec<&str> = a.split('_').collect(); - let b_parts: Vec<&str> = b.split('_').collect(); - let a_number: u64 = a_parts[2].parse().unwrap_or(0); - let b_number: u64 = b_parts[2].parse().unwrap_or(0); - a_number.cmp(&b_number) - }); - - Ok(epoch_proofs - .into_iter() - .filter_map(|proof| { - con.get::<&str, String>(&proof) - .ok() - .and_then(|proof_str| parse_json_to_proof(&proof_str).ok()) - }) - .collect()) - } - fn get_epoch(&self) -> Result { let mut con = self.lock_connection()?; con.get("app_state:epoch") @@ -171,7 +200,7 @@ impl Database for RedisConnection { .map_err(|_| anyhow!(DatabaseError::WriteError(format!("epoch: {}", epoch)))) } - fn update_hashchain( + fn set_hashchain( &self, incoming_operation: &Operation, value: &[HashchainEntry], @@ -192,48 +221,7 @@ impl Database for RedisConnection { }) } - fn get_epochs(&self) -> Result> { - let mut con = self.lock_connection()?; - con.keys::<&str, Vec>("commitments:*") - .map_err(|_| { - PrismError::Database(DatabaseError::NotFoundError("Commitments".to_string())) - })? - .into_iter() - .map(|epoch| { - epoch - .replace("commitments:epoch_", "") - .parse::() - .map_err(|_| { - anyhow!(GeneralError::ParsingError( - "failed to parse epoch".to_string(), - )) - }) - }) - .collect() - } - - fn add_merkle_proof( - &self, - epoch: &u64, - epoch_operation: &u64, - commitment: &Hash, - proofs: &str, - ) -> Result<()> { - let mut con = self.lock_connection()?; - let formatted_epoch = format!( - "merkle_proofs:epoch_{}_{}_{}", - epoch, epoch_operation, commitment - ); - con.set::<&String, &String, ()>(&formatted_epoch, &proofs.to_string()) - .map_err(|_| { - anyhow!(DatabaseError::WriteError(format!( - "merkle proof for epoch: {}", - formatted_epoch - ))) - }) - } - - fn add_commitment(&self, epoch: &u64, commitment: &Hash) -> Result<()> { + fn set_commitment(&self, epoch: &u64, commitment: &Digest) -> Result<()> { let mut con = self.lock_connection()?; con.set::<&String, &String, ()>( &format!("commitments:epoch_{}", epoch), @@ -247,6 +235,7 @@ impl Database for RedisConnection { }) } + #[cfg(test)] fn flush_database(&self) -> Result<()> { let mut conn = self.lock_connection()?; redis::cmd("FLUSHALL") @@ -258,8 +247,8 @@ impl Database for RedisConnection { #[cfg(test)] mod tests { use super::*; - use crate::common::Operation; - use indexed_merkle_tree::sha256_mod; + use crate::storage::Database; + use prism_common::{operation::Operation, tree::hash}; use serde::{Deserialize, Serialize}; use serial_test::serial; @@ -279,8 +268,8 @@ mod tests { fn create_mock_chain_entry() -> HashchainEntry { HashchainEntry { - hash: sha256_mod(b"test_hash"), - previous_hash: sha256_mod(b"test_previous_hash"), + hash: hash(b"test_hash"), + previous_hash: hash(b"test_previous_hash"), operation: Operation::Add { id: "test_id".to_string(), value: "test_value".to_string(), @@ -295,131 +284,6 @@ mod tests { } } - // TESTS FOR fn get_keys(&self) -> Vec - - // TODO: In this context it occurs to me now that we should probably rename the get_keys() function to get_hashchain_keys() or something, because it actually only returns the keys of the hashchain. - // Better yet, there's also the get_derived_keys() function, which returns the derived_dict keys. These are simply the hashed keys. So possibly: get_keys() and get_hashed_keys() ?! - // probably not thaaat important - // TODO: get_keys() returns the keys in reverse order - #[test] - #[serial] - fn test_get_keys() { - // set up redis connection and flush database - let redis_connections = setup(); - - let incoming_operation1 = create_add_operation_with_test_value("main:test_key1"); - let incoming_operation2 = create_add_operation_with_test_value("main:test_key2"); - let incoming_operation3 = create_add_operation_with_test_value("main:test_key3"); - - redis_connections - .update_hashchain(&incoming_operation1, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation2, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation3, &[create_mock_chain_entry()]) - .unwrap(); - - let mut keys = redis_connections.get_keys().unwrap(); - keys.sort(); - - let expected_keys: Vec = vec![ - "test_key1".to_string(), - "test_key2".to_string(), - "test_key3".to_string(), - ]; - let returned_keys: Vec = keys; - - assert_eq!(expected_keys, returned_keys); - - teardown(&redis_connections); - } - - #[test] - #[serial] - fn test_get_keys_from_empty_dictionary() { - let redis_connections = setup(); - - let keys = redis_connections.get_keys().unwrap(); - - let expected_keys: Vec = vec![]; - let returned_keys: Vec = keys; - - assert_eq!(expected_keys, returned_keys); - - teardown(&redis_connections); - } - - #[test] - #[serial] - #[should_panic(expected = "assertion `left == right` failed")] - fn test_get_too_much_returned_keys() { - let redis_connections = setup(); - - let incoming_operation1 = create_add_operation_with_test_value("test_key_1"); - let incoming_operation2 = create_add_operation_with_test_value("test_key_2"); - let incoming_operation3 = create_add_operation_with_test_value("test_key_3"); - - redis_connections - .update_hashchain(&incoming_operation1, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation2, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation3, &[create_mock_chain_entry()]) - .unwrap(); - - let mut keys = redis_connections.get_keys().unwrap(); - - let too_little_keys: Vec = vec!["test_key1".to_string(), "test_key2".to_string()]; - keys.reverse(); - let returned_keys: Vec = keys; - - assert_eq!(too_little_keys, returned_keys); - - teardown(&redis_connections); - } - - #[test] - #[serial] - #[should_panic(expected = "assertion `left == right` failed")] - fn test_get_too_little_returned_keys() { - let redis_connections = setup(); - - let incoming_operation1 = create_add_operation_with_test_value("test_key_1"); - let incoming_operation2 = create_add_operation_with_test_value("test_key_2"); - let incoming_operation3 = create_add_operation_with_test_value("test_key_3"); - - redis_connections - .update_hashchain(&incoming_operation1, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation2, &[create_mock_chain_entry()]) - .unwrap(); - redis_connections - .update_hashchain(&incoming_operation3, &[create_mock_chain_entry()]) - .unwrap(); - - let mut keys = redis_connections.get_keys().unwrap(); - - let too_little_keys: Vec = vec![ - "test_key1".to_string(), - "test_key2".to_string(), - "test_key3".to_string(), - "test_key4".to_string(), - ]; - keys.reverse(); - let returned_keys: Vec = keys; - - assert_eq!(too_little_keys, returned_keys); - - teardown(&redis_connections); - } - - // TESTS FOR fn get_hashchain(&self, key: &String) -> Result, &str> - #[test] #[serial] fn test_get_hashchain() { @@ -429,15 +293,18 @@ mod tests { let chain_entry = create_mock_chain_entry(); redis_connections - .update_hashchain(&incoming_operation, &[chain_entry.clone()]) + .set_hashchain(&incoming_operation, &[chain_entry.clone()]) .unwrap(); let hashchain = redis_connections .get_hashchain(&incoming_operation.id()) .unwrap(); - assert_eq!(hashchain[0].hash, chain_entry.hash); - assert_eq!(hashchain[0].previous_hash, chain_entry.previous_hash); - assert_eq!(hashchain[0].operation, chain_entry.operation); + + let first = hashchain.get(0); + + assert_eq!(first.hash, chain_entry.hash); + assert_eq!(first.previous_hash, chain_entry.previous_hash); + assert_eq!(first.operation, chain_entry.operation); teardown(&redis_connections); } @@ -451,7 +318,7 @@ mod tests { let chain_entry = create_mock_chain_entry(); redis_connections - .update_hashchain(&incoming_operation, &[chain_entry.clone()]) + .set_hashchain(&incoming_operation, &[chain_entry.clone()]) .unwrap(); let hashchain = redis_connections.get_hashchain("main:missing_test_key"); @@ -501,8 +368,6 @@ mod tests { teardown(&redis_connection); } - // TESTS FOR fn get_derived_value(&self, key: &String) -> Result - #[test] #[serial] /* @@ -521,7 +386,7 @@ mod tests { let chain_entries: Vec = vec![create_mock_chain_entry()]; - match redis_connections.update_hashchain(&incoming_operation, &chain_entries) { + match redis_connections.set_hashchain(&incoming_operation, &chain_entries) { Ok(_) => (), Err(e) => panic!("Failed to update hashchain: {}", e), } @@ -529,7 +394,7 @@ mod tests { let hashchain = redis_connections .get_hashchain(&incoming_operation.id()) .unwrap(); - assert_eq!(hashchain[0].hash, sha256_mod(b"test_hash")); + assert_eq!(hashchain.get(0).hash, hash(b"test_hash")); assert_eq!(hashchain.len(), 1); teardown(&redis_connections); diff --git a/src/utils.rs b/crates/prism/src/utils.rs similarity index 80% rename from src/utils.rs rename to crates/prism/src/utils.rs index c00dccda..f00dd9a4 100644 --- a/src/utils.rs +++ b/crates/prism/src/utils.rs @@ -1,16 +1,14 @@ -use crate::{ - circuits::ProofVariantCircuit, - error::{GeneralError, PrismError, ProofError}, -}; use anyhow::Result; use base64::{engine::general_purpose::STANDARD as engine, Engine as _}; use bellman::groth16::{self, VerifyingKey}; use bls12_381::{Bls12, Scalar}; use ed25519::Signature; use ed25519_dalek::{Verifier, VerifyingKey as Ed25519VerifyingKey}; -use indexed_merkle_tree::{tree::Proof, Hash}; -use rand::rngs::OsRng; +use indexed_merkle_tree::tree::Proof; +use prism_common::tree::Digest; +use prism_errors::{GeneralError, PrismError, ProofError}; +#[allow(dead_code)] pub fn parse_json_to_proof(json_str: &str) -> Result> { let proof: Proof = serde_json::from_str(json_str)?; @@ -31,37 +29,10 @@ pub fn decode_public_key(pub_key_str: &String) -> Result { .map_err(|_| GeneralError::DecodingError("ed25519 verifying key".to_string()).into()) } -pub fn create_and_verify_snark( - circuit: ProofVariantCircuit, - scalars: Vec, -) -> Result<(groth16::Proof, VerifyingKey)> { - let rng = &mut OsRng; - - trace!("creating parameters with BLS12-381 pairing-friendly elliptic curve construction...."); - let params = - groth16::generate_random_parameters::(circuit.clone(), rng).map_err(|e| { - PrismError::Proof(ProofError::ProofUnpackError(format!( - "generating random params: {}", - e - ))) - })?; - - trace!("creating proof for zkSNARK..."); - let proof = groth16::create_random_proof(circuit, ¶ms, rng) - .map_err(|e| PrismError::Proof(ProofError::GenerationError(e.to_string())))?; - - trace!("preparing verifying key for zkSNARK..."); - let pvk = groth16::prepare_verifying_key(¶ms.vk); - - groth16::verify_proof(&pvk, &proof, &scalars) - .map_err(|e| PrismError::Proof(ProofError::VerificationError(e.to_string())))?; - - Ok((proof, params.vk)) -} - +#[allow(dead_code)] pub fn validate_epoch( - previous_commitment: &Hash, - current_commitment: &Hash, + previous_commitment: &Digest, + current_commitment: &Digest, proof: groth16::Proof, verifying_key: VerifyingKey, ) -> Result, PrismError> { @@ -119,10 +90,6 @@ pub fn verify_signature( #[cfg(test)] mod tests { - use crate::circuits::BatchMerkleProofCircuit; - use indexed_merkle_tree::tree::{IndexedMerkleTree, Proof}; - - use indexed_merkle_tree::{node::Node, sha256_mod}; use super::*; @@ -145,6 +112,10 @@ mod tests { assert!(decode_public_key(&invalid_length_pub_key_str.to_string()).is_err()); } + /* + + TODO: rewrite with supernova + #[test] fn test_validate_epoch_valid_proof() { let mut tree = IndexedMerkleTree::new_with_size(8).unwrap(); @@ -201,5 +172,5 @@ mod tests { assert!(result.is_ok()); assert_eq!(result.unwrap(), proof); - } + } */ } diff --git a/src/webserver.rs b/crates/prism/src/webserver.rs similarity index 96% rename from src/webserver.rs rename to crates/prism/src/webserver.rs index 1ba9bcdc..19bc41cb 100644 --- a/src/webserver.rs +++ b/crates/prism/src/webserver.rs @@ -1,10 +1,9 @@ use crate::{ cfg::WebServerConfig, - common::{HashchainEntry, Operation}, - error::GeneralError, node_types::sequencer::Sequencer, utils::{verify_signature, SignedContent}, }; +use prism_errors::GeneralError; use anyhow::{Context, Result}; use axum::{ extract::State, @@ -14,11 +13,13 @@ use axum::{ Json, Router, }; use ed25519::Signature; -use indexed_merkle_tree::tree::{Proof, UpdateProof}; -use indexed_merkle_tree::Hash as TreeHash; +use indexed_merkle_tree::{ + tree::{Proof, UpdateProof}, + Hash as TreeHash, +}; +use prism_common::{hashchain::Hashchain, operation::Operation}; use serde::{Deserialize, Serialize}; -use std::sync::Arc; -use std::{self, str::FromStr}; +use std::{self, str::FromStr, sync::Arc}; use tower_http::cors::CorsLayer; use utoipa::{OpenApi, ToSchema}; use utoipa_swagger_ui::SwaggerUi; @@ -92,7 +93,7 @@ pub struct UserKeyRequest { // TODO: Retrieve Merkle proof of current epoch #[derive(Serialize, Deserialize, ToSchema)] pub struct UserKeyResponse { - pub hashchain: Vec, + pub hashchain: Hashchain, // pub proof: MerkleProof } diff --git a/crates/sp1/Cargo.toml b/crates/sp1/Cargo.toml new file mode 100644 index 00000000..593f4140 --- /dev/null +++ b/crates/sp1/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "prism-sp1" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +prism-common = { workspace = true } +sp1-zkvm = { workspace = true } diff --git a/crates/sp1/README.md b/crates/sp1/README.md new file mode 100644 index 00000000..94b0b8e0 --- /dev/null +++ b/crates/sp1/README.md @@ -0,0 +1,6 @@ +# SP1 Proof + +After experimenting with Supernova, we decided it makes sense to test a zkVM that will let us keep our small, variable sized JMT merkle proofs without padding. +At first glance, the performance seems okay but we need further benchmarks to confirm. + +In the long term, we will likely require a zkVM anyways if we need to prove over Celestia's NMT (for example, that all operations from the last Celestia block were included). diff --git a/crates/sp1/src/main.rs b/crates/sp1/src/main.rs new file mode 100644 index 00000000..29d985c0 --- /dev/null +++ b/crates/sp1/src/main.rs @@ -0,0 +1,34 @@ +#![no_main] +sp1_zkvm::entrypoint!(main); + +use prism_common::tree::{Batch, Digest, Proof}; + +pub fn main() { + println!("cycle-tracker-start: setup"); + let batch = sp1_zkvm::io::read::(); + let mut current = batch.prev_root; + println!("cycle-tracker-end: setup"); + + println!("cycle-tracker-start: proof-iteration"); + for proof in batch.proofs.iter() { + match proof { + Proof::Update(p) => { + assert_eq!(current, Digest::new(p.old_root.into())); + println!("cycle-tracker-start: update"); + assert!(p.verify().is_ok()); + println!("cycle-tracker-end: update"); + current = Digest::new(p.new_root.into()); + } + Proof::Insert(p) => { + assert_eq!(current, p.non_membership_proof.root); + println!("cycle-tracker-start: insert"); + assert!(p.verify().is_ok()); + println!("cycle-tracker-end: insert"); + current = p.new_root; + } + } + } + println!("cycle-tracker-end: proof-iteration"); + + sp1_zkvm::io::commit_slice(¤t.to_bytes()); +} diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 00000000..b3524b52 --- /dev/null +++ b/rust-toolchain @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.79.0" +components = ["llvm-tools", "rustc-dev"] diff --git a/rustfmt.toml b/rustfmt.toml index e86028b1..a811a490 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1,2 @@ -imports_granularity="Crate" +merge_imports = true +imports_granularity = "Crate" diff --git a/src/circuits/utils.rs b/src/circuits/utils.rs deleted file mode 100644 index c201a5d3..00000000 --- a/src/circuits/utils.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::error::ProofError; -use anyhow::{anyhow, Result}; -use bls12_381::Scalar; -use indexed_merkle_tree::{node::Node, sha256_mod, tree::MerkleProof}; - -pub fn unpack_and_process(proof: &MerkleProof) -> Result<(Scalar, &Vec)> { - if !proof.path.is_empty() { - let root: Scalar = proof.root_hash.try_into()?; - Ok((root, &proof.path)) - } else { - Err(anyhow!(ProofError::ProofUnpackError(format!( - "proof path is empty for root hash {}", - proof.root_hash - )))) - } -} - -pub fn recalculate_hash_as_scalar(path: &[Node]) -> Result { - let mut current_hash = path[0].get_hash(); - for node in path.iter().skip(1) { - let combined = if node.is_left_sibling() { - [node.get_hash().as_ref(), current_hash.as_ref()].concat() - } else { - [current_hash.as_ref(), node.get_hash().as_ref()].concat() - }; - current_hash = sha256_mod(&combined); - } - current_hash.try_into() -} diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 50e4ad61..363cc416 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,140 +1,127 @@ -use base64::{engine::general_purpose::STANDARD as engine, Engine as _}; -use ed25519_dalek::{Signer, SigningKey}; -use keystore_rs::create_signing_key; -use prism::{ - cfg::{Config, RedisConfig}, - common::{AccountSource, Operation}, - da::memory::InMemoryDataAvailabilityLayer, - node_types::{lightclient::LightClient, sequencer::Sequencer, NodeType}, - storage::{Database, RedisConnection}, - webserver::OperationInput, -}; -use rand::{rngs::StdRng, Rng, SeedableRng}; -use std::{sync::Arc, time::Duration}; - -fn create_new_account_operation(id: String, value: String, key: &SigningKey) -> OperationInput { - let incoming = Operation::CreateAccount { - id: id.clone(), - value: value.clone(), - source: AccountSource::SignedBySequencer { - signature: key.sign(format!("{}{}", id, value).as_bytes()).to_string(), - }, - }; - let content = serde_json::to_string(&incoming).unwrap(); - let sig = key.sign(content.clone().as_bytes()); - OperationInput { - operation: incoming, - signed_operation: sig.to_string(), - public_key: engine.encode(key.verifying_key().to_bytes()), - } -} - -fn create_update_operation(id: String, value: String) -> OperationInput { - let key = create_signing_key(); - let incoming = Operation::Add { id, value }; - let content = serde_json::to_string(&incoming).unwrap(); - let sig = key.sign(content.clone().as_bytes()); - OperationInput { - operation: incoming, - signed_operation: sig.to_string(), - public_key: engine.encode(key.verifying_key().to_bytes()), - } -} - -#[tokio::test] -async fn test_light_client_sequencer_talking() { - std::env::set_var("RUST_LOG", "DEBUG"); - pretty_env_logger::init(); - - let (da_layer, mut height_rx, mut _block_rx) = InMemoryDataAvailabilityLayer::new(1); - let da_layer = Arc::new(da_layer); - let db = Arc::new(setup_db()); - let cfg = Config::default(); - let signing_key = create_signing_key(); - let pubkey = engine.encode(signing_key.verifying_key().to_bytes()); - - let sequencer = Arc::new( - Sequencer::new( - db.clone(), - da_layer.clone(), - cfg.clone(), - signing_key.clone(), - ) - .unwrap(), - ); - - let lightclient = Arc::new(LightClient::new( - da_layer, - cfg.celestia_config.unwrap(), - Some(pubkey), - )); - - let seq_1 = sequencer.clone(); - tokio::spawn(async move { - seq_1.start().await.unwrap(); - }); - - tokio::spawn(async move { - lightclient.clone().start().await.unwrap(); - }); - - let seq = sequencer.clone(); - tokio::spawn(async move { - let mut rng = StdRng::from_entropy(); - let mut accounts = Vec::new(); - let mut i = 0; - - loop { - let seq_clone = seq.clone(); - // Create 1 or 2 new accounts - let num_new_accounts = rng.gen_range(1..=10); - for _ in 0..num_new_accounts { - let seq_i = seq_clone.clone(); - let new_acc = create_new_account_operation( - format!("{}@gmail.com", i), - format!("key_{}", i), - &signing_key, - ); - seq_i.validate_and_queue_update(&new_acc).await.unwrap(); - accounts.push(format!("{}@gmail.com", i)); - i += 1; - } - - // Update 5 random existing accounts (if we have at least 5) - if accounts.len() >= 5 { - for _ in 0..5 { - let seq_i = seq_clone.clone(); - let account_index = rng.gen_range(0..accounts.len()); - let account_id = accounts[account_index].clone(); - let update_op = create_update_operation( - account_id, - format!("updated_key_{}", rng.gen::()), - ); - seq_i.validate_and_queue_update(&update_op).await.unwrap(); - } - } - - tokio::time::sleep(Duration::from_millis(500)).await; - } - }); - - while let Ok(height) = height_rx.recv().await { - if height == 60 { - break; - } - } - - teardown_db(db.clone()) -} - -// set up redis connection and flush database before each test -fn setup_db() -> RedisConnection { - let redis_connection = RedisConnection::new(&RedisConfig::default()).unwrap(); - redis_connection.flush_database().unwrap(); - redis_connection -} - -// flush database after each test -fn teardown_db(redis_connections: Arc) { - redis_connections.flush_database().unwrap(); -} + +// fn create_new_account_operation(id: String, value: String, key: &SigningKey) -> OperationInput { +// let incoming = Operation::CreateAccount { +// id: id.clone(), +// value: value.clone(), +// source: AccountSource::SignedBySequencer { +// signature: key.sign(format!("{}{}", id, value).as_bytes()).to_string(), +// }, +// }; +// let content = serde_json::to_string(&incoming).unwrap(); +// let sig = key.sign(content.clone().as_bytes()); +// OperationInput { +// operation: incoming, +// signed_operation: sig.to_string(), +// public_key: engine.encode(key.verifying_key().to_bytes()), +// } +// } + +// fn create_update_operation(id: String, value: String) -> OperationInput { +// let key = create_signing_key(); +// let incoming = Operation::Add { id, value }; +// let content = serde_json::to_string(&incoming).unwrap(); +// let sig = key.sign(content.clone().as_bytes()); +// OperationInput { +// operation: incoming, +// signed_operation: sig.to_string(), +// public_key: engine.encode(key.verifying_key().to_bytes()), +// } +// } + +// #[tokio::test] +// async fn test_light_client_sequencer_talking() { +// std::env::set_var("RUST_LOG", "DEBUG"); +// pretty_env_logger::init(); + +// let (da_layer, mut height_rx, mut _block_rx) = InMemoryDataAvailabilityLayer::new(1); +// let da_layer = Arc::new(da_layer); +// let db = Arc::new(setup_db()); +// let cfg = Config::default(); +// let signing_key = create_signing_key(); +// let pubkey = engine.encode(signing_key.verifying_key().to_bytes()); + +// let sequencer = Arc::new( +// Sequencer::new( +// db.clone(), +// da_layer.clone(), +// cfg.clone(), +// signing_key.clone(), +// ) +// .unwrap(), +// ); + +// let lightclient = Arc::new(LightClient::new( +// da_layer, +// cfg.celestia_config.unwrap(), +// Some(pubkey), +// )); + +// let seq_1 = sequencer.clone(); +// tokio::spawn(async move { +// seq_1.start().await.unwrap(); +// }); + +// tokio::spawn(async move { +// lightclient.clone().start().await.unwrap(); +// }); + +// let seq = sequencer.clone(); +// tokio::spawn(async move { +// let mut rng = StdRng::from_entropy(); +// let mut accounts = Vec::new(); +// let mut i = 0; + +// loop { +// let seq_clone = seq.clone(); +// // Create 1 or 2 new accounts +// let num_new_accounts = rng.gen_range(1..=10); +// for _ in 0..num_new_accounts { +// let seq_i = seq_clone.clone(); +// let new_acc = create_new_account_operation( +// format!("{}@gmail.com", i), +// format!("key_{}", i), +// &signing_key, +// ); +// seq_i.validate_and_queue_update(&new_acc).await.unwrap(); +// accounts.push(format!("{}@gmail.com", i)); +// i += 1; +// } + +// // Update 5 random existing accounts (if we have at least 5) +// if accounts.len() >= 5 { +// for _ in 0..5 { +// let seq_i = seq_clone.clone(); +// let account_index = rng.gen_range(0..accounts.len()); +// let account_id = accounts[account_index].clone(); +// let update_op = create_update_operation( +// account_id, +// format!("updated_key_{}", rng.gen::()), +// ); +// seq_i.validate_and_queue_update(&update_op).await.unwrap(); +// } +// } + +// tokio::time::sleep(Duration::from_millis(500)).await; +// } +// }); + +// while let Ok(height) = height_rx.recv().await { +// if height == 60 { +// break; +// } +// } + +// teardown_db(db.clone()) +// } + +// // set up redis connection and flush database before each test +// fn setup_db() -> RedisConnection { +// let redis_connection = RedisConnection::new(&RedisConfig::default()).unwrap(); +// redis_connection.flush_database().unwrap(); +// redis_connection +// } + +// // flush database after each test +// fn teardown_db(redis_connections: Arc) { +// redis_connections.flush_database().unwrap(); +// }