diff --git a/Cargo.lock b/Cargo.lock index 08b3718a..7055b437 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,23 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "abomonation" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e72913c99b1f927aa7bd59a41518fdd9995f63ffc8760f211609e0241c4fb2" + +[[package]] +name = "abomonation_derive_ng" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34056136e0910411c88e9af0bca6e23fcdba258da239684014cd45ca900c9f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "actix-codec" version = "0.5.2" @@ -15,25 +32,10 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "tokio-util 0.7.11", + "tokio-util", "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" @@ -58,17 +60,17 @@ dependencies = [ "http", "httparse", "httpdate", - "itoa 1.0.11", + "itoa", "language-tags", "local-channel", "mime", "percent-encoding", "pin-project-lite", - "rand 0.8.5", - "sha1 0.10.6", + "rand", + "sha1", "smallvec", "tokio", - "tokio-util 0.7.11", + "tokio-util", "tracing", "zstd", ] @@ -90,7 +92,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" dependencies = [ "bytestring", - "cfg-if 1.0.0", + "cfg-if", "http", "regex", "regex-lite", @@ -164,13 +166,13 @@ dependencies = [ "ahash", "bytes", "bytestring", - "cfg-if 1.0.0", + "cfg-if", "cookie", "derive_more", "encoding_rs", "futures-core", "futures-util", - "itoa 1.0.11", + "itoa", "language-tags", "log", "mime", @@ -199,6 +201,17 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "addchain" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2e69442aa5628ea6951fa33e24efe8313f4321a91bd729fc2f75bdfc858570" +dependencies = [ + "num-bigint 0.3.3", + "num-integer", + "num-traits", +] + [[package]] name = "addr2line" version = "0.22.0" @@ -214,12 +227,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "adler32" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" - [[package]] name = "aead" version = "0.5.2" @@ -227,7 +234,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 +243,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 +268,8 @@ 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", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -298,25 +305,10 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a43b18702501396fa9bcdeecd533bc85fac75150d308fc0f6800a01e6234a003" 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" @@ -378,6 +370,51 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +[[package]] +name = "arecibo" +version = "0.2.0" +source = "git+https://github.com/deltadevsde/arecibo#1b6b7a772893bb6f0ce54556a0d52cd13bd1175c" +dependencies = [ + "abomonation", + "abomonation_derive_ng", + "bellpepper", + "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" version = "0.3.0" @@ -389,7 +426,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,7 +446,7 @@ 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", @@ -442,7 +479,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 +491,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 +516,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-std 0.4.0", "digest 0.10.7", - "num-bigint", + "num-bigint 0.4.6", ] [[package]] @@ -489,7 +526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -499,7 +536,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand 0.8.5", + "rand", ] [[package]] @@ -508,191 +545,21 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" 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" -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", -] - [[package]] name = "async-lock" 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", -] - -[[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", + "event-listener", ] -[[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" @@ -704,23 +571,6 @@ dependencies = [ "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", -] - [[package]] name = "auto_impl" version = "1.2.0" @@ -752,7 +602,7 @@ dependencies = [ "http", "http-body", "hyper", - "itoa 1.0.11", + "itoa", "matchit", "memchr", "mime", @@ -795,7 +645,7 @@ checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object", @@ -863,11 +713,35 @@ dependencies = [ "log", "num_cpus", "pairing", - "rand_core 0.6.4", + "rand_core", "rayon", "subtle", ] +[[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 = "bellpepper-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d8abb418570756396d722841b19edfec21d4e89e1cf8990610663040ecb1aea" +dependencies = [ + "blake2s_simd", + "byteorder", + "ff", + "serde", + "thiserror", +] + [[package]] name = "bincode" version = "1.3.3" @@ -877,6 +751,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 +793,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 +820,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.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" 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 +843,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 +852,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 +876,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 +915,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" dependencies = [ "borsh-derive", - "cfg_aliases 0.2.1", + "cfg_aliases", ] [[package]] @@ -1100,7 +1022,7 @@ checksum = "7f22a6baf972f7277acfd5c4ff9b894df7db5b0aaecdb57b9b77b5679fff323e" dependencies = [ "anyhow", "celestia-tendermint-proto", - "prost 0.12.6", + "prost", "prost-build", "prost-types", "serde", @@ -1115,7 +1037,7 @@ dependencies = [ "async-trait", "celestia-types", "http", - "jsonrpsee 0.20.3", + "jsonrpsee", "serde", "thiserror", "tracing", @@ -1136,7 +1058,7 @@ dependencies = [ "futures", "num-traits", "once_cell", - "prost 0.12.6", + "prost", "prost-types", "serde", "serde_bytes", @@ -1160,7 +1082,7 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost 0.12.6", + "prost", "prost-types", "serde", "serde_bytes", @@ -1196,43 +1118,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" @@ -1282,23 +1179,6 @@ dependencies = [ "inout", ] -[[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.13" @@ -1306,7 +1186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", - "clap_derive 4.5.13", + "clap_derive", ] [[package]] @@ -1317,21 +1197,8 @@ checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", - "clap_lex 0.7.2", - "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]] @@ -1346,15 +1213,6 @@ dependencies = [ "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", -] - [[package]] name = "clap_lex" version = "0.7.2" @@ -1367,16 +1225,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" -[[package]] -name = "colored" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" -dependencies = [ - "lazy_static", - "windows-sys 0.48.0", -] - [[package]] name = "combine" version = "4.6.7" @@ -1384,38 +1232,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,7 +1276,7 @@ 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", ] @@ -1484,12 +1301,6 @@ dependencies = [ "unicode-xid", ] -[[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" @@ -1547,15 +1358,6 @@ 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" @@ -1571,7 +1373,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 +1385,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.13", + "clap", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1656,43 +1458,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,23 +1472,13 @@ 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", @@ -1747,7 +1507,7 @@ checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core 0.6.4", + "rand_core", "subtle-ng", "zeroize", ] @@ -1758,7 +1518,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 +1551,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" @@ -1849,7 +1600,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 +1676,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 +1693,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 +1707,7 @@ checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand_core 0.6.4", + "rand_core", "serde", "sha2 0.10.8", "subtle", @@ -1981,7 +1726,7 @@ version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -2031,27 +1776,6 @@ 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" @@ -2062,15 +1786,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.1.0" @@ -2083,7 +1798,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 +1810,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 +1845,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand 0.8.5", + "rand", "rustc-hex", "static_assertions", ] @@ -2161,21 +1882,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 +1897,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 +1951,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 +1978,6 @@ dependencies = [ "futures-channel", "futures-core", "futures-io", - "futures-macro", "futures-sink", "futures-task", "memchr", @@ -2341,14 +1997,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 +2011,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]] @@ -2379,16 +2035,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[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 +2047,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 +2083,10 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.3.0", + "indexmap", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util", "tracing", ] @@ -2426,21 +2096,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,38 +2152,20 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" -[[package]] -name = "hermit-abi" -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 +2173,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 +2202,7 @@ checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", - "itoa 1.0.11", + "itoa", ] [[package]] @@ -2582,7 +2255,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 1.0.11", + "itoa", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -2601,46 +2274,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,24 +2344,14 @@ 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", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.3.0" @@ -2718,47 +2364,31 @@ dependencies = [ ] [[package]] -name = "inout" -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" +name = "informalsystems-pbjson" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +checksum = "9aa4a0980c8379295100d70854354e78df2ee1c6ca0f96ffe89afeb3140e3a3d" dependencies = [ - "cfg-if 1.0.0", + "base64 0.21.7", + "serde", ] [[package]] -name = "io-lifetimes" -version = "1.0.11" +name = "inout" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" 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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.52.0", ] @@ -2788,10 +2418,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" @@ -2799,6 +2432,29 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "jmt" +version = "0.10.0" +source = "git+https://github.com/deltadevsde/jmt#dc521ef17fcba2fe96990dbd1831fcb274ebb541" +dependencies = [ + "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 = "jobserver" version = "0.1.32" @@ -2817,12 +2473,6 @@ 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" @@ -2840,25 +2490,14 @@ version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" 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", + "jsonrpsee-types", + "jsonrpsee-ws-client", "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" @@ -2867,35 +2506,14 @@ 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", - "tracing", - "url", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" -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", + "tokio-rustls", + "tokio-util", "tracing", "url", ] @@ -2907,40 +2525,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" dependencies = [ "anyhow", - "async-lock 2.8.0", + "async-lock", "async-trait", "beef", "futures-timer", "futures-util", "hyper", - "jsonrpsee-types 0.20.3", - "rustc-hash", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "jsonrpsee-core" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" -dependencies = [ - "anyhow", - "async-trait", - "beef", - "futures-timer", - "futures-util", - "jsonrpsee-types 0.22.5", - "pin-project", + "jsonrpsee-types", "rustc-hash", "serde", "serde_json", "thiserror", "tokio", - "tokio-stream", "tracing", ] @@ -2953,8 +2549,8 @@ dependencies = [ "async-trait", "hyper", "hyper-rustls", - "jsonrpsee-core 0.20.3", - "jsonrpsee-types 0.20.3", + "jsonrpsee-core", + "jsonrpsee-types", "serde", "serde_json", "thiserror", @@ -2991,19 +2587,6 @@ 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" @@ -3011,23 +2594,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" 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]] @@ -3046,22 +2625,13 @@ 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" @@ -3073,6 +2643,9 @@ 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" @@ -3091,26 +2664,6 @@ 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" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf" -dependencies = [ - "rle-decode-fast", -] - [[package]] name = "libm" version = "0.2.8" @@ -3148,12 +2701,6 @@ 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" @@ -3192,9 +2739,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 +2752,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" @@ -3256,7 +2791,7 @@ checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", "windows-sys 0.48.0", ] @@ -3266,19 +2801,25 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "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", @@ -3293,7 +2834,7 @@ 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", @@ -3346,53 +2887,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" +name = "neptune" +version = "13.0.0" +source = "git+https://github.com/lurk-lab/neptune?branch=dev#b6fb1f9372be2a50c5686c1dfa27bb0d8c4253e7" 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" -dependencies = [ - "bitflags 2.6.0", - "cfg-if 1.0.0", - "cfg_aliases 0.1.1", - "libc", + "abomonation", + "abomonation_derive_ng", + "bellpepper", + "bellpepper-core", + "blake2s_simd", + "blstrs", + "byteorder", + "ff", + "generic-array 0.14.7", + "pasta_curves", + "serde", + "trait-set", ] [[package]] @@ -3421,7 +2931,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", @@ -3429,6 +2939,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" @@ -3437,6 +2958,8 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", + "rand", + "serde", ] [[package]] @@ -3491,7 +3014,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", ] @@ -3512,7 +3035,16 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", + "libc", +] + +[[package]] +name = "num_threads" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9" +dependencies = [ "libc", ] @@ -3543,50 +3075,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" @@ -3603,12 +3097,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" @@ -3624,7 +3112,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", @@ -3644,12 +3132,6 @@ dependencies = [ "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" @@ -3666,13 +3148,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" @@ -3743,7 +3242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.3.0", + "indexmap", ] [[package]] @@ -3778,17 +3277,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" @@ -3833,44 +3321,13 @@ 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", @@ -3882,26 +3339,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" -[[package]] -name = "pprof" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978385d59daf9269189d052ca8a84c1acfd0715c0599a5d5188d4acc078ca46a" -dependencies = [ - "backtrace", - "cfg-if 1.0.0", - "findshlibs", - "libc", - "log", - "nix 0.26.4", - "once_cell", - "parking_lot", - "smallvec", - "symbolic-demangle", - "tempfile", - "thiserror", -] - [[package]] name = "ppv-lite86" version = "0.2.20" @@ -3972,52 +3409,43 @@ dependencies = [ name = "prism" version = "0.1.0" dependencies = [ - "actix-cors", "actix-web", - "ahash", "anyhow", - "async-redis-session", + "arecibo", "async-trait", + "auto_impl", "axum", "base64 0.22.1", "bellman", + "bellpepper-core", + "bincode", "bls12_381", "borsh", "celestia-rpc", "celestia-types", - "clap 4.5.13", - "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", + "itertools 0.13.0", + "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", + "rand", + "redis", "serde", "serde_json", "serial_test", + "sha2 0.10.8", "thiserror", "tokio", "toml", @@ -4084,26 +3512,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" @@ -4111,7 +3533,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", - "prost-derive 0.12.6", + "prost-derive", ] [[package]] @@ -4128,26 +3550,13 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost 0.12.6", + "prost", "prost-types", "regex", "syn 2.0.72", "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" @@ -4167,38 +3576,14 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ - "prost 0.12.6", + "prost", ] [[package]] -name = "pyroscope" -version = "0.5.7" +name = "quick-error" +version = "1.2.3" 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", -] - -[[package]] -name = "pyroscope_pprofrs" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f010b2a981a7f8449a650f25f309e520b5206ea2d89512dcb146aaa5518ff4" -dependencies = [ - "log", - "pprof", - "pyroscope", - "thiserror", -] +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-protobuf" @@ -4224,19 +3609,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" @@ -4244,18 +3616,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]] @@ -4265,16 +3627,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]] @@ -4283,16 +3636,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]] @@ -4301,7 +3645,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]] @@ -4325,24 +3669,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]] @@ -4352,7 +3684,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", @@ -4375,90 +3707,66 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.15", + "getrandom", "libredox", "thiserror", ] [[package]] -name = "regex" -version = "1.10.6" +name = "ref-cast" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "ref-cast-impl", ] [[package]] -name = "regex-automata" -version = "0.4.7" +name = "ref-cast-impl" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "proc-macro2", + "quote", + "syn 2.0.72", ] [[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" +name = "regex" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" 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", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "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 = "ring" version = "0.17.8" @@ -4466,8 +3774,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", @@ -4475,10 +3783,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" @@ -4513,12 +3824,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", @@ -4573,7 +3884,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", ] @@ -4613,20 +3924,6 @@ 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" @@ -4636,7 +3933,7 @@ dependencies = [ "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.14", + "linux-raw-sys", "windows-sys 0.52.0", ] @@ -4648,24 +3945,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.6", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -4673,20 +3956,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", ] @@ -4700,22 +3970,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" @@ -4726,23 +3980,24 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.102.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" -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" @@ -4821,6 +4076,16 @@ dependencies = [ "libc", ] +[[package]] +name = "semolina" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0111fd4fa831becb0606b9a2285ef3bee3c6a70d690209b8ae9514e9befe23" +dependencies = [ + "cc", + "glob", +] + [[package]] name = "semver" version = "0.11.0" @@ -4854,6 +4119,15 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde_arrays" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38636132857f68ec3d5f3eb121166d2af33cb55174c4d5ff645db6165cbef0fd" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.15" @@ -4880,7 +4154,7 @@ version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ - "itoa 1.0.11", + "itoa", "memchr", "ryu", "serde", @@ -4892,7 +4166,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6" dependencies = [ - "itoa 1.0.11", + "itoa", "serde", ] @@ -4923,7 +4197,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 1.0.11", + "itoa", "ryu", "serde", ] @@ -4960,28 +4234,19 @@ 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", + "cfg-if", "cpufeatures", "digest 0.10.7", ] @@ -4999,7 +4264,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", @@ -5011,11 +4276,21 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" 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" @@ -5040,7 +4315,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]] @@ -5089,7 +4364,7 @@ dependencies = [ "futures", "httparse", "log", - "rand 0.8.5", + "rand", "sha-1", ] @@ -5110,10 +4385,14 @@ dependencies = [ ] [[package]] -name = "stable_deref_trait" -version = "1.2.0" +name = "sppark" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "a075ecc826f50c645a1e6bb2f94560ded74ec7584a6061e72470802a2eee350c" +dependencies = [ + "cc", + "which", +] [[package]] name = "static_assertions" @@ -5121,12 +4400,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" @@ -5154,29 +4427,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "symbolic-common" -version = "12.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16629323a4ec5268ad23a575110a724ad4544aae623451de600c747bf87b36cf" -dependencies = [ - "debugid", - "memmap2", - "stable_deref_trait", - "uuid", -] - -[[package]] -name = "symbolic-demangle" -version = "12.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c043a45f08f41187414592b3ceb53fb0687da57209cc77401767fb69d5b596" -dependencies = [ - "cpp_demangle", - "rustc-demangle", - "symbolic-common", -] - [[package]] name = "syn" version = "1.0.109" @@ -5217,27 +4467,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" @@ -5250,10 +4479,10 @@ version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ - "cfg-if 1.0.0", - "fastrand 2.1.0", + "cfg-if", + "fastrand", "once_cell", - "rustix 0.38.34", + "rustix", "windows-sys 0.52.0", ] @@ -5272,12 +4501,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" @@ -5298,6 +4521,15 @@ dependencies = [ "syn 2.0.72", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.36" @@ -5305,8 +4537,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", @@ -5392,59 +4626,13 @@ dependencies = [ "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", -] - [[package]] name = "tokio-rustls" 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", ] @@ -5489,7 +4677,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.3.0", + "indexmap", "toml_datetime", "winnow 0.5.40", ] @@ -5500,7 +4688,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.3.0", + "indexmap", "toml_datetime", "winnow 0.5.40", ] @@ -5511,7 +4699,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.3.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -5596,6 +4784,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" @@ -5622,7 +4821,7 @@ checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", - "hex 0.4.3", + "hex", "static_assertions", ] @@ -5725,7 +4924,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82b1bc5417102a73e8464c686eef947bdfb99fcdfc0a4f228e81afa9526470a" dependencies = [ - "indexmap 2.3.0", + "indexmap", "serde", "serde_json", "utoipa-gen", @@ -5760,12 +4959,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" @@ -5773,16 +4966,16 @@ 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" @@ -5791,10 +4984,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" 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" @@ -5815,12 +5011,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" @@ -5833,7 +5023,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] @@ -5852,18 +5042,6 @@ dependencies = [ "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" @@ -5904,10 +5082,16 @@ dependencies = [ ] [[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" @@ -5940,15 +5124,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" @@ -6115,16 +5290,6 @@ 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" diff --git a/Cargo.toml b/Cargo.toml index 25fb21e1..b5a1aff3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,51 +23,44 @@ 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 = { git = "https://github.com/deltadevsde/jmt", features = [ + "mocks", +] } #{ version = "0.10.0", features = ["mocks"] } +bellpepper-core = { version = "0.4.0", default-features = false } +arecibo = { git = "https://github.com/deltadevsde/arecibo" } +itertools = "0.13.0" # zip_eq +sha2 = "0.10.8" +auto_impl = "1.2.0" +bincode = "1.3.3" [dev-dependencies] serial_test = "3.1.1" 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/cfg.rs b/src/cfg.rs index d3217979..c305c8b8 100644 --- a/src/cfg.rs +++ b/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, + error::{DataAvailabilityError, GeneralError, PrismError}, +}; use anyhow::{anyhow, Context, Result}; use clap::{Parser, Subcommand}; use config::{builder::DefaultState, ConfigBuilder, File}; @@ -15,6 +17,7 @@ use crate::da::{celestia::CelestiaConnection, DataAvailabilityLayer}; pub enum Commands { LightClient, Sequencer, + GeneratePublicParams, } #[derive(Parser, Clone, Debug, Deserialize)] @@ -57,6 +60,10 @@ pub struct CommandLineArgs { #[arg(long)] config_path: Option, + /// Path to the bin file containing serialized PublicParams + #[arg(long)] + public_params_path: Option, + #[command(subcommand)] pub command: Commands, } @@ -70,6 +77,7 @@ pub struct Config { pub da_layer: Option, pub redis_config: Option, pub verifying_key: Option, + pub public_params_path: Option, } #[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)] @@ -135,6 +143,7 @@ impl Default for Config { celestia_config: Some(CelestiaConfig::default()), redis_config: Some(RedisConfig::default()), verifying_key: None, + public_params_path: None, } } } @@ -201,6 +210,7 @@ fn merge_configs(loaded: Config, default: Config) -> Config { celestia_config: loaded.celestia_config.or(default.celestia_config), da_layer: loaded.da_layer.or(default.da_layer), verifying_key: loaded.verifying_key.or(default.verifying_key), + public_params_path: loaded.public_params_path.or(default.public_params_path), } } @@ -264,6 +274,7 @@ fn apply_command_line_args(config: Config, args: CommandLineArgs) -> Config { }), da_layer: config.da_layer, verifying_key: args.verifying_key.or(config.verifying_key), + public_params_path: args.public_params_path.or(config.public_params_path), } } diff --git a/src/circuits/merkle_batch.rs b/src/circuits/merkle_batch.rs index 2323ac50..46833d8d 100644 --- a/src/circuits/merkle_batch.rs +++ b/src/circuits/merkle_batch.rs @@ -3,12 +3,13 @@ use crate::{ merkle_insertion::prove_insertion, merkle_update::prove_update, InsertMerkleProofCircuit, ProofVariantCircuit, UpdateMerkleProofCircuit, }, + tree::Digest, utils::create_and_verify_snark, }; use anyhow::Result; use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError}; use bls12_381::{Bls12, Scalar}; -use indexed_merkle_tree::{tree::Proof, Hash}; +use indexed_merkle_tree::tree::Proof; /// BatchMerkleProofCircuit represents a circuit for proving a batch of merkle proof circuits. #[derive(Clone)] @@ -20,8 +21,8 @@ pub struct BatchMerkleProofCircuit { impl BatchMerkleProofCircuit { pub fn new( - old_commitment: &Hash, - new_commitment: &Hash, + old_commitment: &Digest, + new_commitment: &Digest, proofs: Vec, ) -> Result { let parsed_old_commitment: Scalar = (*old_commitment).try_into()?; diff --git a/src/circuits/mod.rs b/src/circuits/mod.rs index 69a2cc7c..7e59845a 100644 --- a/src/circuits/mod.rs +++ b/src/circuits/mod.rs @@ -12,7 +12,6 @@ pub mod merkle_insertion; pub mod merkle_update; pub mod utils; -pub use hashchain::HashChainEntryCircuit; pub use less_than::LessThanCircuit; pub use merkle_batch::BatchMerkleProofCircuit; pub use merkle_insertion::InsertMerkleProofCircuit; @@ -189,6 +188,7 @@ impl TryFrom for groth16::VerifyingKey { #[cfg(test)] mod tests { use super::*; + use crate::tree::Digest; use bellman::groth16; use bls12_381::Bls12; use indexed_merkle_tree::{ @@ -278,58 +278,58 @@ mod tests { setup_and_test_less_than_circuit(head, head) } - #[test] - fn test_serialize_and_deserialize_proof() { - let mut tree = IndexedMerkleTree::new_with_size(4).unwrap(); - let prev_commitment = tree.get_commitment().unwrap(); - - // create two nodes to insert - let ryan = sha256_mod(b"Ryan"); - let ford = sha256_mod(b"Ford"); - let sebastian = sha256_mod(b"Sebastian"); - let pusch = sha256_mod(b"Pusch"); - let ethan = sha256_mod(b"Ethan"); - let triple_zero = sha256_mod(b"000"); - - let mut ryans_node = Node::new_leaf(true, ryan, ford, Node::TAIL); - let mut sebastians_node = Node::new_leaf(true, sebastian, pusch, Node::TAIL); - let mut ethans_node = Node::new_leaf(true, ethan, triple_zero, Node::TAIL); - - // generate proofs for the two nodes - let first_insert_proof = tree.insert_node(&mut ryans_node).unwrap(); - let second_insert_proof = tree.insert_node(&mut sebastians_node).unwrap(); - let third_insert_proof = tree.insert_node(&mut ethans_node).unwrap(); - - // create zkSNARKs for the two proofs - let first_insert_zk_snark = Proof::Insert(first_insert_proof); - let second_insert_zk_snark = Proof::Insert(second_insert_proof); - let third_insert_zk_snark = Proof::Insert(third_insert_proof); - - let proofs = vec![ - first_insert_zk_snark, - second_insert_zk_snark, - third_insert_zk_snark, - ]; - let current_commitment = tree.get_commitment().unwrap(); - - let batched_proof = - BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs).unwrap(); - - let rng = &mut OsRng; - let params = - groth16::generate_random_parameters::(batched_proof.clone(), rng).unwrap(); - let proof = groth16::create_random_proof(batched_proof.clone(), ¶ms, rng).unwrap(); - - let serialized_proof: Bls12Proof = proof.clone().into(); - let deserialized_proof_result: Result> = - serialized_proof.clone().try_into(); - assert!(deserialized_proof_result.is_ok(), "Deserialization failed"); - - let deserialized_proof = deserialized_proof_result.unwrap(); - assert_eq!(proof.a, deserialized_proof.a); - assert_eq!(proof.b, deserialized_proof.b); - assert_eq!(proof.c, deserialized_proof.c); - } + // Commented because needs to be rewritten to JMT + // #[test] + // fn test_serialize_and_deserialize_proof() { + // let mut tree = IndexedMerkleTree::new_with_size(4).unwrap(); + + // // create two nodes to insert + // let ryan = sha256_mod(b"Ryan"); + // let ford = sha256_mod(b"Ford"); + // let sebastian = sha256_mod(b"Sebastian"); + // let pusch = sha256_mod(b"Pusch"); + // let ethan = sha256_mod(b"Ethan"); + // let triple_zero = sha256_mod(b"000"); + + // let mut ryans_node = Node::new_leaf(true, ryan, ford, Node::TAIL); + // let mut sebastians_node = Node::new_leaf(true, sebastian, pusch, Node::TAIL); + // let mut ethans_node = Node::new_leaf(true, ethan, triple_zero, Node::TAIL); + + // // generate proofs for the two nodes + // let first_insert_proof = tree.insert_node(&mut ryans_node).unwrap(); + // let second_insert_proof = tree.insert_node(&mut sebastians_node).unwrap(); + // let third_insert_proof = tree.insert_node(&mut ethans_node).unwrap(); + + // // create zkSNARKs for the two proofs + // let first_insert_zk_snark = Proof::Insert(first_insert_proof); + // let second_insert_zk_snark = Proof::Insert(second_insert_proof); + // let third_insert_zk_snark = Proof::Insert(third_insert_proof); + + // let proofs = vec![ + // first_insert_zk_snark, + // second_insert_zk_snark, + // third_insert_zk_snark, + // ]; + // let current_commitment = tree.get_commitment().unwrap(); + + // let batched_proof = + // BatchMerkleProofCircuit::new(&prev_commitment, ¤t_commitment, proofs).unwrap(); + + // let rng = &mut OsRng; + // let params = + // groth16::generate_random_parameters::(batched_proof.clone(), rng).unwrap(); + // let proof = groth16::create_random_proof(batched_proof.clone(), ¶ms, rng).unwrap(); + + // let serialized_proof: Bls12Proof = proof.clone().into(); + // let deserialized_proof_result: Result> = + // serialized_proof.clone().try_into(); + // assert!(deserialized_proof_result.is_ok(), "Deserialization failed"); + + // let deserialized_proof = deserialized_proof_result.unwrap(); + // assert_eq!(proof.a, deserialized_proof.a); + // assert_eq!(proof.b, deserialized_proof.b); + // assert_eq!(proof.c, deserialized_proof.c); + // } #[test] fn test_deserialize_invalid_proof() { diff --git a/src/common.rs b/src/common.rs index 8869da49..63f822fd 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,13 @@ +use anyhow::{bail, Result}; use borsh::{BorshDeserialize, BorshSerialize}; -use indexed_merkle_tree::{sha256_mod, Hash}; +use jmt::KeyHash; use serde::{Deserialize, Serialize}; -use std::fmt::Display; +use std::{ + fmt::Display, + ops::{Deref, DerefMut}, +}; + +use crate::tree::{hash, Digest, Hasher}; #[derive(Clone, BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, PartialEq)] // An [`Operation`] represents a state transition in the system. @@ -56,22 +62,144 @@ impl Display for Operation { } } -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] +#[derive(Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq)] +pub struct Hashchain { + id: String, + 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 let Operation::CreateAccount { .. } = operation { + bail!("Cannot CreateAccount on an already existing hashchain"); + } + 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 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: Hash, - pub previous_hash: Hash, + pub hash: Digest, + pub previous_hash: Digest, pub operation: Operation, } impl HashchainEntry { - pub fn new(operation: Operation, previous_hash: Hash) -> Self { + 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()); - sha256_mod(&data) + // TODO: replace with sha256 after JMT complete + hash(&data) }; Self { hash, diff --git a/src/da/memory.rs b/src/da/memory.rs index 78efea9a..6f24fd1b 100644 --- a/src/da/memory.rs +++ b/src/da/memory.rs @@ -5,8 +5,10 @@ use crate::{ use anyhow::Result; use async_trait::async_trait; 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/src/da/mod.rs index 3f10be05..35f78cdf 100644 --- a/src/da/mod.rs +++ b/src/da/mod.rs @@ -2,13 +2,13 @@ use crate::{ circuits::{Bls12Proof, VerifyingKey}, common::Operation, error::GeneralError, + tree::Digest, utils::SignedContent, }; use anyhow::Result; use async_trait::async_trait; use borsh::{BorshDeserialize, BorshSerialize}; use ed25519::Signature; -use indexed_merkle_tree::Hash; use std::{self, str::FromStr}; pub mod celestia; @@ -18,8 +18,8 @@ pub mod memory; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug)] pub struct FinalizedEpoch { pub height: u64, - pub prev_commitment: Hash, - pub current_commitment: Hash, + 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/src/lib.rs index 7d93911b..67ea3a9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,11 +1,13 @@ pub mod cfg; -pub mod circuits; +mod circuits; pub mod common; pub mod consts; pub mod da; pub mod error; pub mod node_types; +pub mod nova; pub mod storage; +pub mod tree; pub mod utils; pub mod webserver; #[macro_use] diff --git a/src/main.rs b/src/main.rs index 09d9079e..4d902b75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,25 @@ mod cfg; -pub mod circuits; pub mod common; pub mod consts; pub mod da; pub mod error; mod node_types; +mod nova; pub mod storage; +mod tree; mod utils; mod webserver; use cfg::{initialize_da_layer, load_config}; use clap::Parser; use keystore_rs::{KeyChain, KeyStore, KeyStoreType}; +use prism::nova::utils::create_pp; use crate::cfg::{CommandLineArgs, Commands}; +use anyhow::{Context, Result}; +use arecibo::{provider::PallasEngine, supernova::PublicParams}; use node_types::{lightclient::LightClient, sequencer::Sequencer, NodeType}; +use std::io; use std::sync::Arc; use storage::RedisConnection; @@ -25,13 +30,21 @@ extern crate log; #[actix_web::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 pp = load_or_generate_public_params(&config.public_params_path) + .expect("Failed to deserialize or generate public params."); + + if let Commands::GeneratePublicParams {} = args.command { + bincode::serialize_into(io::stdout(), &pp).unwrap(); + return Ok(()); + } + 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,17 +70,38 @@ 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()) + })?, ) } + _ => { + return Err(std::io::Error::new( + std::io::ErrorKind::InvalidInput, + "Invalid node type", + )); + } }; node.start() .await .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string())) } + +fn load_or_generate_public_params(path: &Option) -> Result> { + if let Some(path) = path { + info!("Loading public params from file: {:?}", path); + let bytes = std::fs::read(path).context("Failed to read public params file")?; + bincode::deserialize(&bytes).context("Failed to deserialize public params") + } else { + warn!("No public params file provided, generating new ones. This may take a while."); + Ok(create_pp()) + } +} diff --git a/src/node_types/lightclient.rs b/src/node_types/lightclient.rs index 75a7aeb2..5a616bb3 100644 --- a/src/node_types/lightclient.rs +++ b/src/node_types/lightclient.rs @@ -96,7 +96,7 @@ impl LightClient { 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,7 +105,10 @@ 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) } @@ -136,6 +139,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/sequencer.rs b/src/node_types/sequencer.rs index 7b0b3245..32109977 100644 --- a/src/node_types/sequencer.rs +++ b/src/node_types/sequencer.rs @@ -1,13 +1,12 @@ +use crate::{ + circuits::BatchMerkleProofCircuit, + tree::{hash, Digest, Hasher, KeyDirectoryTree, Proof, SnarkableTree}, +}; 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 std::{self, str::FromStr, sync::Arc}; use tokio::{ sync::{ @@ -23,8 +22,7 @@ use crate::error::DataAvailabilityError; use crate::{ cfg::Config, - circuits::BatchMerkleProofCircuit, - common::{AccountSource, HashchainEntry, Operation}, + common::{AccountSource, Hashchain, HashchainEntry, Operation}, consts::{CHANNEL_BUFFER_SIZE, DA_RETRY_COUNT, DA_RETRY_INTERVAL}, da::{DataAvailabilityLayer, FinalizedEpoch}, error::{DatabaseError, GeneralError}, @@ -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,7 +302,7 @@ 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 = @@ -363,31 +363,23 @@ 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(), - ); + current_chain.push(new_chain_entry.operation.clone()); - let index = tree.find_node_index(&node).context(format!( - "Node with label {} not found in the tree, but has a hashchain entry", - hashed_id - ))?; + // let updated_node = Node::new_leaf( + // node.is_left_sibling(), + // hashed_id, + // new_chain_entry.hash, + // node.get_next(), + // ); 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) .context(format!( @@ -395,9 +387,7 @@ impl Sequencer { 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 +402,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 +412,22 @@ 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) + .update_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 +465,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 +473,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 +516,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 +534,7 @@ mod tests { .validate_and_queue_update(&update_entry) .await .unwrap(); - teardown_db(&db); + teardown_db(db); } #[tokio::test] @@ -553,7 +542,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 +569,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 +580,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 +599,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 +687,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 +715,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/nova/batch.rs b/src/nova/batch.rs new file mode 100644 index 00000000..0f977ef6 --- /dev/null +++ b/src/nova/batch.rs @@ -0,0 +1,312 @@ +use super::{insert::InsertCircuit, update::UpdateCircuit}; +use crate::tree::{InsertProof, UpdateProof}; +use arecibo::{ + supernova::{StepCircuit, TrivialSecondaryCircuit}, + traits::{CurveCycleEquipped, Dual, Engine}, +}; +use ff::PrimeField; +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::{common::Hashchain, nova::utils::Digest as NovaDigest, tree::*}; + use arecibo::{ + provider::PallasEngine, + supernova::{NonUniformCircuit, PublicParams, RecursiveSNARK}, + traits::snark::default_ck_hint, + }; + use ff::Field; + use jmt::{mock::MockTreeStore, KeyHash}; + 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") + } + + #[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), 4), + ), + ( + 1, + EpochCircuit::new_update(create_random_update(&mut state, &mut rng), 4), + ), + ( + 0, + EpochCircuit::new_insert(create_random_insert(&mut state, &mut rng), 4), + ), + ( + 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/src/nova/insert.rs b/src/nova/insert.rs new file mode 100644 index 00000000..e3f6d07d --- /dev/null +++ b/src/nova/insert.rs @@ -0,0 +1,87 @@ +use crate::{ + nova::utils::{next_rom_index_and_pc, Digest}, + tree::InsertProof, +}; +use anyhow::Result; +use arecibo::supernova::StepCircuit; +use bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError}; +use ff::PrimeField; + +#[derive(Clone)] +pub struct InsertCircuit { + pub insertion_proof: InsertProof, + rom_size: usize, + _phantom: std::marker::PhantomData, +} + +impl InsertCircuit { + pub fn new(insertion_proof: InsertProof, rom_size: usize) -> Self { + Self { + insertion_proof, + rom_size, + _phantom: std::marker::PhantomData, + } + } +} + +impl StepCircuit for InsertCircuit +where + F: PrimeField, +{ + fn arity(&self) -> usize { + 2 + self.rom_size // old_root + rom_index + rom[].len() + } + + fn circuit_index(&self) -> usize { + 0 + } + + 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.insertion_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 + })?; + let new_scalar = Digest::new(self.insertion_proof.new_root) + .to_scalar() + .map_err(|_| SynthesisError::Unsatisfiable); + let new_root = AllocatedNum::alloc(cs.namespace(|| "new_root"), || new_scalar)?; + + cs.enforce( + || "z0 == pre_insertion_root", + |lc| lc + old_root.get_variable(), + |lc| lc + CS::one(), + |lc| lc + pre_insertion_root.get_variable(), + ); + // TODO: bellpepper merkle proof gadget + self.insertion_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/src/nova/mod.rs b/src/nova/mod.rs new file mode 100644 index 00000000..ef348743 --- /dev/null +++ b/src/nova/mod.rs @@ -0,0 +1,4 @@ +pub mod batch; +pub mod insert; +pub mod update; +pub mod utils; diff --git a/src/nova/update.rs b/src/nova/update.rs new file mode 100644 index 00000000..62f9ead2 --- /dev/null +++ b/src/nova/update.rs @@ -0,0 +1,87 @@ +use crate::{ + nova::utils::{next_rom_index_and_pc, Digest as NovaDigest}, + tree::UpdateProof, +}; +use anyhow::Result; +use arecibo::supernova::StepCircuit; +use bellpepper_core::{num::AllocatedNum, ConstraintSystem, SynthesisError}; +use ff::PrimeField; + +#[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, +{ + 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)?; + + cs.enforce( + || "z0 == pre_insertion_root", + |lc| lc + old_root.get_variable(), + |lc| lc + CS::one(), + |lc| lc + pre_insertion_root.get_variable(), + ); + // // TODO: bellpepper merkle proof gadget + 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/src/nova/utils.rs b/src/nova/utils.rs new file mode 100644 index 00000000..e29b11ab --- /dev/null +++ b/src/nova/utils.rs @@ -0,0 +1,186 @@ +// use bellpepper_core::ConstraintSystem; +use crate::nova::batch::EpochCircuitSequence; +use crate::tree::*; +use crate::{common::Hashchain, nova::batch::EpochCircuit}; +use anyhow::Result; +use arecibo::{provider::PallasEngine, supernova::PublicParams, traits::snark::default_ck_hint}; +use bellpepper_core::{ + boolean::{AllocatedBit, Boolean}, + num::AllocatedNum, + ConstraintSystem, LinearCombination, SynthesisError, +}; +use ff::PrimeField; +use itertools::Itertools as _; +use jmt::RootHash; +use jmt::{mock::MockTreeStore, KeyHash}; +use std::marker::PhantomData; +use std::sync::Arc; + +use crate::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 struct Hash { + hash: indexed_merkle_tree::Hash, + _p: PhantomData, +} + +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()) +} diff --git a/src/storage.rs b/src/storage.rs index b93e864b..acca317d 100644 --- a/src/storage.rs +++ b/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, @@ -12,44 +16,34 @@ use std::{ use crate::{ cfg::RedisConfig, - common::{HashchainEntry, Operation}, + common::{Hashchain, HashchainEntry, Operation}, error::{DatabaseError, GeneralError, PrismError}, - utils::parse_json_to_proof, + tree::Digest, }; // 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>; - fn get_commitment(&self, epoch: &u64) -> Result; - fn get_proof(&self, id: &str) -> Result; - fn get_proofs_in_epoch(&self, epoch: &u64) -> Result>; - fn get_epoch(&self) -> Result; - fn set_epoch(&self, epoch: &u64) -> Result<()>; +#[auto_impl(&, Box, Arc)] +pub trait Database: Send + Sync + TreeReader + TreeWriter { + fn get_hashchain(&self, key: &str) -> 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<()>; + + fn get_commitment(&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<()>; + + #[cfg(test)] fn flush_database(&self) -> Result<()>; } @@ -96,16 +90,86 @@ 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).unwrap()); + let node_data: Option> = con.get(format!("node:{}", serialized_key))?; + match node_data { + None => return Ok(None), + Some(data) => { + let node: Node = borsh::from_slice::(&data).unwrap(); + Ok(Some(node)) + } + } + } + + 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 { + // let node_key = NodeKey::from_str(key.strip_prefix("node:").unwrap())?; + let node_key_bytes = hex::decode(key.strip_prefix("node:").unwrap()).unwrap(); + let node_key = borsh::from_slice::(node_key_bytes.as_ref()).unwrap(); + if rightmost.is_none() || leaf.key_hash() > rightmost.as_ref().unwrap().1.key_hash() + { + rightmost.replace((node_key, leaf)); + } + } + } + + Ok(rightmost) + } + + fn get_value_option( + &self, + max_version: Version, + key_hash: KeyHash, + ) -> Result> { + let mut con = self.lock_connection()?; + let versions: Vec<(Version, OwnedValue)> = con.zrangebyscore_withscores( + format!("value_history:{:?}", key_hash), + 0, + max_version as f64, + )?; + Ok(versions.last().map(|(_, value)| value.clone())) + } +} + +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 node_data = borsh::to_vec(node)?; + pipe.set(format!("node:{:?}", node_key), node_data); + } + + for ((version, key_hash), value) in node_batch.values() { + if let Some(v) = value { + pipe.zadd(format!("value_history:{:?}", key_hash), v, *version as f64); + } else { + pipe.zadd( + format!("value_history:{:?}", key_hash), + Vec::::new(), + *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)) @@ -125,40 +189,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") @@ -192,48 +222,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 +236,7 @@ impl Database for RedisConnection { }) } + #[cfg(test)] fn flush_database(&self) -> Result<()> { let mut conn = self.lock_connection()?; redis::cmd("FLUSHALL") @@ -258,8 +248,7 @@ impl Database for RedisConnection { #[cfg(test)] mod tests { use super::*; - use crate::common::Operation; - use indexed_merkle_tree::sha256_mod; + use crate::{common::Operation, storage::Database, 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() { @@ -435,9 +299,12 @@ mod tests { 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); } @@ -501,8 +368,6 @@ mod tests { teardown(&redis_connection); } - // TESTS FOR fn get_derived_value(&self, key: &String) -> Result - #[test] #[serial] /* @@ -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/tree/mod.rs b/src/tree/mod.rs new file mode 100644 index 00000000..181f1979 --- /dev/null +++ b/src/tree/mod.rs @@ -0,0 +1,517 @@ +use anyhow::{anyhow, bail, ensure, 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, Sha256Jmt, SimpleHasher, +}; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +use crate::common::Hashchain; + +pub const SPARSE_MERKLE_PLACEHOLDER_HASH: Digest = + Digest::new(*b"SPARSE_MERKLE_PLACEHOLDER_HASH__"); + +pub type Hasher = sha2::Sha256; + +#[derive( + Debug, Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize, PartialEq, Eq, Copy, +)] +pub struct Digest([u8; 32]); + +// 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 Into for Digest { + fn into(self) -> RootHash { + RootHash::from(self.0) + } +} + +impl Into for RootHash { + fn into(self) -> Digest { + Digest(self.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 = sha2::Sha256::new(); + hasher.update(data); + Digest(hasher.finalize()) +} + +#[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: UpdateMerkleProof, + 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_update( + self.non_membership_proof.root.into(), + self.new_root.into(), + vec![(self.non_membership_proof.key, Some(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: Sha256Jmt::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(()) + } + + 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()?; + 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"); + } + + let (new_root, membership_proof, 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()?; + + ensure!( + membership_proof.len() == 1, + "UpdateProof does not span only a single update" + ); + + 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/src/utils.rs b/src/utils.rs index c00dccda..42b7edee 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,7 @@ use crate::{ circuits::ProofVariantCircuit, error::{GeneralError, PrismError, ProofError}, + tree::Digest, }; use anyhow::Result; use base64::{engine::general_purpose::STANDARD as engine, Engine as _}; @@ -8,7 +9,7 @@ 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 indexed_merkle_tree::tree::Proof; use rand::rngs::OsRng; pub fn parse_json_to_proof(json_str: &str) -> Result> { @@ -60,8 +61,8 @@ pub fn create_and_verify_snark( } 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 +120,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 +142,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 +202,5 @@ mod tests { assert!(result.is_ok()); assert_eq!(result.unwrap(), proof); - } + } */ } diff --git a/src/webserver.rs b/src/webserver.rs index 1ba9bcdc..819c3dfc 100644 --- a/src/webserver.rs +++ b/src/webserver.rs @@ -1,6 +1,6 @@ use crate::{ cfg::WebServerConfig, - common::{HashchainEntry, Operation}, + common::{Hashchain, Operation}, error::GeneralError, node_types::sequencer::Sequencer, utils::{verify_signature, SignedContent}, @@ -14,11 +14,12 @@ 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 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/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(); +// }