diff --git a/Cargo.lock b/Cargo.lock index 8c84dec..1cbacc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "utxo", ] @@ -31,7 +31,7 @@ dependencies = [ "actix-macros", "actix-rt", "actix_derive", - "bitflags 2.9.0", + "bitflags 2.9.1", "bytes", "crossbeam-channel", "futures-core", @@ -53,7 +53,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "bytes", "futures-core", "futures-sink", @@ -72,7 +72,7 @@ checksum = "0346d8c1f762b41b458ed3145eea914966bb9ad20b9be0d6d463b20d45586370" dependencies = [ "actix-utils", "actix-web", - "derive_more 0.99.19", + "derive_more 0.99.20", "futures-util", "log", "once_cell", @@ -81,16 +81,16 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.10.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa882656b67966045e4152c634051e70346939fced7117d5f0b52146a7c74c9" +checksum = "44dfe5c9e0004c623edc65391dfd51daa201e7e30ebd9c9bedf873048ec32bc2" dependencies = [ "actix-codec", "actix-rt", "actix-service", "actix-utils", "base64 0.22.1", - "bitflags 2.9.0", + "bitflags 2.9.1", "bytes", "bytestring", "derive_more 2.0.1", @@ -107,7 +107,7 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", - "rand 0.9.0", + "rand 0.9.1", "sha1", "smallvec", "tokio", @@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -132,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" dependencies = [ "bytestring", - "cfg-if 1.0.0", + "cfg-if", "http 0.2.12", "regex", "regex-lite", @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6398974fd4284f4768af07965701efbbb5fdc0616bff20cade1bb14b77675e24" +checksum = "a65064ea4a457eaf07f2fba30b4c695bf43b721790e9530d26cb6f9019ff7502" dependencies = [ "actix-rt", "actix-service", @@ -163,7 +163,7 @@ dependencies = [ "futures-core", "futures-util", "mio", - "socket2 0.5.9", + "socket2 0.5.10", "tokio", "tracing", ] @@ -204,8 +204,8 @@ dependencies = [ "ahash 0.7.8", "bytes", "bytestring", - "cfg-if 1.0.0", - "derive_more 0.99.19", + "cfg-if", + "derive_more 0.99.20", "encoding_rs", "futures-core", "futures-util", @@ -233,7 +233,7 @@ checksum = "b6ac1e58cded18cb28ddc17143c4dea5345b3ad575e14f32f66e4054a56eb271" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -284,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -293,7 +293,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", ] @@ -309,36 +309,30 @@ dependencies = [ "cipher", "ctr", "ghash", - "subtle 2.6.1", + "subtle", ] -[[package]] -name = "ahash" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" - [[package]] name = "ahash" version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "version_check", - "zerocopy 0.7.35", + "zerocopy", ] [[package]] @@ -358,9 +352,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" dependencies = [ "backtrace", ] @@ -401,7 +395,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e0c292754729c8a190e50414fd1a37093c786c709899f29c9f7daccecfa855e" dependencies = [ - "ahash 0.8.11", + "ahash 0.8.12", "ark-crypto-primitives-macros", "ark-ec", "ark-ff", @@ -411,10 +405,10 @@ dependencies = [ "ark-std", "blake2", "derivative", - "digest 0.10.7", + "digest", "fnv", "merlin", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -425,7 +419,7 @@ checksum = "e7e89fe77d1f0f4fe5b96dfc940923d88d17b6a773808124f21e764dfb063c6a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -434,14 +428,14 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" dependencies = [ - "ahash 0.8.11", + "ahash 0.8.12", "ark-ff", "ark-poly", "ark-serialize", "ark-std", "educe", "fnv", - "hashbrown 0.15.2", + "hashbrown 0.15.3", "itertools 0.13.0", "num-bigint 0.4.6", "num-integer", @@ -459,13 +453,13 @@ dependencies = [ "ark-ff-macros", "ark-serialize", "ark-std", - "arrayvec 0.7.6", - "digest 0.10.7", + "arrayvec", + "digest", "educe", "itertools 0.13.0", "num-bigint 0.4.6", "num-traits", - "paste 1.0.15", + "paste", "zeroize", ] @@ -476,7 +470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" dependencies = [ "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -489,7 +483,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -513,13 +507,13 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" dependencies = [ - "ahash 0.8.11", + "ahash 0.8.12", "ark-ff", "ark-serialize", "ark-std", "educe", "fnv", - "hashbrown 0.15.2", + "hashbrown 0.15.3", ] [[package]] @@ -559,8 +553,8 @@ checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" dependencies = [ "ark-serialize-derive", "ark-std", - "arrayvec 0.7.6", - "digest 0.10.7", + "arrayvec", + "digest", "num-bigint 0.4.6", ] @@ -572,7 +566,7 @@ checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -603,27 +597,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" -[[package]] -name = "arrayref" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" - -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] - -[[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.6" @@ -664,12 +637,12 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line 0.24.2", - "cfg-if 1.0.0", + "cfg-if", "libc", "miniz_oxide", "object 0.36.7", @@ -728,7 +701,7 @@ dependencies = [ "regex", "rustc-hash 1.1.0", "shlex", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -751,9 +724,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bitvec" @@ -773,32 +746,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "blake2-rfc" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" -dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", -] - -[[package]] -name = "blake3" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "667d945f23cefed0b5f973af35c4bc3319caa6776fbda270e4897d8504afa8e4" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac", - "digest 0.8.1", + "digest", ] [[package]] @@ -807,44 +755,23 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] name = "bonsai-sdk" version = "1.4.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "duplicate", "maybe-async", - "reqwest 0.12.15", + "reqwest 0.12.18", "serde", "thiserror 1.0.69", ] @@ -869,7 +796,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -878,17 +805,11 @@ version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "bytemuck" -version = "1.22.0" +version = "1.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" +checksum = "9134a6ef01ce4b366b50689c94f82c14bc72bc5d0386829828a2e2752ef7958c" dependencies = [ "bytemuck_derive", ] @@ -901,7 +822,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -972,9 +893,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.17" +version = "1.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7" dependencies = [ "jobserver", "libc", @@ -990,12 +911,6 @@ dependencies = [ "nom", ] -[[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" @@ -1082,14 +997,13 @@ dependencies = [ "elliptic-curve", "hex", "log", - "monotree", "reqwest 0.11.27", "risc0-zkvm", "rs_merkle", "secp256k1-zkp", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "thiserror 1.0.69", ] @@ -1112,12 +1026,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "convert_case" version = "0.4.0" @@ -1157,7 +1065,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96e58d342ad113c2b878f16d5d034c03be492ae460cdbc02b7f0f2284d310c7d" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1175,7 +1083,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]] @@ -1186,9 +1094,9 @@ checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" [[package]] name = "crossbeam-channel" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" dependencies = [ "crossbeam-utils", ] @@ -1224,9 +1132,9 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", - "subtle 2.6.1", + "subtle", "zeroize", ] @@ -1236,21 +1144,11 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.4", - "subtle 1.0.0", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1327,7 +1225,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1338,14 +1236,14 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] name = "der" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", "zeroize", @@ -1353,9 +1251,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.4.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", ] @@ -1379,7 +1277,7 @@ checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1400,7 +1298,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1410,20 +1308,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] name = "derive_more" -version = "0.99.19" +version = "0.99.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da29a38df43d6f156149c9b43ded5e018ddff2a855cf2cfd62e8cd7d079c69f" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1443,29 +1341,20 @@ checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "unicode-xid", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", - "subtle 2.6.1", + "subtle", ] [[package]] @@ -1506,7 +1395,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1527,10 +1416,10 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ac1e888d6830712d565b2f3a974be3200be9296bc1b03db8251a4cbf18a4a34" dependencies = [ - "digest 0.10.7", + "digest", "futures", "rand 0.8.5", - "reqwest 0.12.15", + "reqwest 0.12.18", "thiserror 1.0.69", "tokio", ] @@ -1552,7 +1441,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", - "digest 0.10.7", + "digest", "elliptic-curve", "rfc6979", "serdect", @@ -1569,7 +1458,7 @@ dependencies = [ "enum-ordinalize", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1592,15 +1481,15 @@ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "digest 0.10.7", + "digest", "ff", - "generic-array 0.14.7", + "generic-array", "group", "pkcs8", "rand_core 0.6.4", "sec1", "serdect", - "subtle 2.6.1", + "subtle", "zeroize", ] @@ -1622,7 +1511,7 @@ version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1642,7 +1531,7 @@ checksum = "f282cfdfe92516eb26c2af8589c274c7c17681f5ecc03c18255fe741c6aa64eb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1662,7 +1551,7 @@ checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1696,20 +1585,14 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.10" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18" dependencies = [ "libc", "windows-sys 0.59.0", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fallible-iterator" version = "0.3.0" @@ -1732,7 +1615,7 @@ dependencies = [ "byteorder", "ff_derive", "rand_core 0.6.4", - "subtle 2.6.1", + "subtle", ] [[package]] @@ -1808,7 +1691,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1894,7 +1777,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -1927,15 +1810,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1949,22 +1823,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.16" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -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", @@ -1973,11 +1836,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "libc", "r-efi", @@ -1991,7 +1854,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" dependencies = [ - "opaque-debug 0.3.1", + "opaque-debug", "polyval", ] @@ -2034,7 +1897,7 @@ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", - "subtle 2.6.1", + "subtle", ] [[package]] @@ -2049,7 +1912,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.8.0", + "indexmap 2.9.0", "slab", "tokio", "tokio-util", @@ -2065,16 +1928,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" -dependencies = [ - "ahash 0.3.8", - "autocfg", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -2090,14 +1943,14 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.11", + "ahash 0.8.12", ] [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "84b26c544d002229e640969970a2e74021aadf6e2f96372b9c58eff97de08eb3" dependencies = [ "allocator-api2", ] @@ -2148,9 +2001,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" +checksum = "f154ce46856750ed433c8649605bf7ed2de3bc35fd9d2a9f30cddd873c80cb08" [[package]] name = "hex" @@ -2170,7 +2023,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] @@ -2273,7 +2126,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.9", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -2301,11 +2154,10 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.5" +version = "0.27.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +checksum = "03a01595e11bdcec50946522c32dde3fc6914743000a68b93000965f2f02406d" dependencies = [ - "futures-util", "http 1.3.1", "hyper 1.6.0", "hyper-util", @@ -2332,19 +2184,23 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" +checksum = "b1c293b6b3d21eca78250dc7dbebd6b9210ec5530e038cbfe0661b5c47ab06e8" dependencies = [ + "base64 0.22.1", "bytes", "futures-channel", + "futures-core", "futures-util", "http 1.3.1", "http-body 1.0.1", "hyper 1.6.0", + "ipnet", "libc", + "percent-encoding", "pin-project-lite", - "socket2 0.5.9", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -2352,21 +2208,22 @@ dependencies = [ [[package]] name = "icu_collections" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" dependencies = [ "displaydoc", + "potential_utf", "yoke", "zerofrom", "zerovec", ] [[package]] -name = "icu_locid" -version = "1.5.0" +name = "icu_locale_core" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" dependencies = [ "displaydoc", "litemap", @@ -2375,31 +2232,11 @@ dependencies = [ "zerovec", ] -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" - [[package]] name = "icu_normalizer" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" dependencies = [ "displaydoc", "icu_collections", @@ -2407,67 +2244,54 @@ dependencies = [ "icu_properties", "icu_provider", "smallvec", - "utf16_iter", - "utf8_iter", - "write16", "zerovec", ] [[package]] name = "icu_normalizer_data" -version = "1.5.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" [[package]] name = "icu_properties" -version = "1.5.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" dependencies = [ "displaydoc", "icu_collections", - "icu_locid_transform", + "icu_locale_core", "icu_properties_data", "icu_provider", - "tinystr", + "potential_utf", + "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "1.5.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" [[package]] name = "icu_provider" -version = "1.5.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" dependencies = [ "displaydoc", - "icu_locid", - "icu_provider_macros", + "icu_locale_core", "stable_deref_trait", "tinystr", "writeable", "yoke", "zerofrom", + "zerotrie", "zerovec", ] -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -2487,9 +2311,9 @@ dependencies = [ [[package]] name = "idna_adapter" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ "icu_normalizer", "icu_properties", @@ -2513,12 +2337,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown 0.15.3", ] [[package]] @@ -2527,7 +2351,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -2545,13 +2369,23 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "is-terminal" version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ - "hermit-abi 0.5.0", + "hermit-abi 0.5.1", "libc", "windows-sys 0.59.0", ] @@ -2604,7 +2438,7 @@ version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ - "getrandom 0.3.2", + "getrandom 0.3.3", "libc", ] @@ -2624,12 +2458,12 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "ecdsa", "elliptic-curve", "once_cell", "serdect", - "sha2 0.10.8", + "sha2", "signature", ] @@ -2668,7 +2502,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2688,25 +2522,25 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ - "cfg-if 1.0.0", - "windows-targets 0.52.6", + "cfg-if", + "windows-targets 0.53.0", ] [[package]] name = "libm" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" @@ -2714,7 +2548,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "libc", ] @@ -2763,15 +2597,15 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" [[package]] name = "local-channel" @@ -2800,12 +2634,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "lockfree-object-pool" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" - [[package]] name = "log" version = "0.4.27" @@ -2821,6 +2649,12 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "lzma-sys" version = "0.1.20" @@ -2901,9 +2735,9 @@ dependencies = [ [[package]] name = "matrixmultiply" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9380b911e3e96d10c1f415da0876389aaf1b56759054eeb0de7df940c456ba1a" +checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08" dependencies = [ "autocfg", "rawpointer", @@ -2917,7 +2751,7 @@ checksum = "5cf92c10c7e361d6b99666ec1c6f9805b0bea2c3bd8c78dc6fe98ac5bd78db11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -2964,13 +2798,13 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ecfd3296f8c56b7c1f6fbac3c71cefa9d78ce009850c45000015f206dc7fa21" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "block", "core-graphics-types", "foreign-types 0.5.0", "log", "objc", - "paste 1.0.15", + "paste", ] [[package]] @@ -2987,9 +2821,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] @@ -3002,33 +2836,14 @@ checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff" [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", -] - -[[package]] -name = "monotree" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6724f66abef26ea20981177c87a500f2416a420d96daf50c5d96d97a10892d5f" -dependencies = [ - "blake2-rfc", - "blake3", - "digest 0.8.1", - "hashbrown 0.7.2", - "hex", - "num", - "paste 0.1.18", - "rand 0.7.3", - "scopeguard", - "sha2 0.8.2", - "sha3", + "windows-sys 0.59.0", ] [[package]] @@ -3055,7 +2870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" dependencies = [ "matrixmultiply", - "num-complex 0.4.6", + "num-complex", "num-integer", "num-traits", "portable-atomic", @@ -3095,7 +2910,6 @@ dependencies = [ "hex", "k256", "log", - "monotree", "rand 0.8.5", "reqwest 0.11.27", "risc0-zkvm", @@ -3103,7 +2917,7 @@ dependencies = [ "secp256k1-zkp", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "storage", "tempfile", "thiserror 1.0.69", @@ -3164,12 +2978,6 @@ dependencies = [ "zkvm", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" - [[package]] name = "nom" version = "7.1.3" @@ -3180,31 +2988,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "num" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" -dependencies = [ - "num-bigint 0.2.6", - "num-complex 0.2.4", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.3.3" @@ -3226,16 +3009,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.6" @@ -3259,7 +3032,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3271,29 +3044,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg", - "num-bigint 0.2.6", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -3348,12 +3098,6 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.1" @@ -3362,12 +3106,12 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.71" +version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ - "bitflags 2.9.0", - "cfg-if 1.0.0", + "bitflags 2.9.1", + "cfg-if", "foreign-types 0.3.2", "libc", "once_cell", @@ -3383,7 +3127,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3394,9 +3138,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.106" +version = "0.9.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" dependencies = [ "cc", "libc", @@ -3432,38 +3176,19 @@ 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 = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3510,9 +3235,9 @@ 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 0.3.1", + "opaque-debug", "universal-hash", ] @@ -3544,6 +3269,15 @@ dependencies = [ "serde", ] +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -3556,17 +3290,17 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.8.24", + "zerocopy", ] [[package]] name = "prettyplease" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5316f57387668042f561aae71480de936257848f9c43ce528e311d89a07cadeb" +checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3575,7 +3309,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" dependencies = [ - "toml_edit 0.22.24", + "toml_edit 0.22.26", ] [[package]] @@ -3602,17 +3336,11 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -3637,7 +3365,7 @@ dependencies = [ "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -3648,7 +3376,7 @@ checksum = "fa9dae7b05c02ec1a6bc9bcf20d8bc64a7dcbf57934107902a872014899b741f" dependencies = [ "anyhow", "byteorder", - "cfg-if 1.0.0", + "cfg-if", "itertools 0.10.5", "once_cell", "parking_lot", @@ -3656,9 +3384,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3bd15a6f2967aef83887dcb9fec0014580467e33720d073560cf015a5683012" +checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" dependencies = [ "bytes", "cfg_aliases", @@ -3667,7 +3395,7 @@ dependencies = [ "quinn-udp", "rustc-hash 2.1.1", "rustls", - "socket2 0.5.9", + "socket2 0.5.10", "thiserror 2.0.12", "tokio", "tracing", @@ -3676,13 +3404,14 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.10" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b820744eb4dc9b57a3398183639c511b5a26d2ed702cedd3febaa1393caa22cc" +checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" dependencies = [ "bytes", - "getrandom 0.3.2", - "rand 0.9.0", + "getrandom 0.3.3", + "lru-slab", + "rand 0.9.1", "ring", "rustc-hash 2.1.1", "rustls", @@ -3696,14 +3425,14 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "541d0f57c6ec747a90738a52741d3221f7960e8ac2f0ff4b1a63680e033b4ab5" +checksum = "ee4e529991f949c5e25755532370b8af5d114acae52326361d68d47af64aa842" dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.5.9", + "socket2 0.5.10", "tracing", "windows-sys 0.59.0", ] @@ -3729,19 +3458,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" @@ -3755,23 +3471,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy 0.8.24", -] - -[[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", ] [[package]] @@ -3794,22 +3499,13 @@ dependencies = [ "rand_core 0.9.3", ] -[[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", -] - [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", ] [[package]] @@ -3818,16 +3514,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ - "getrandom 0.3.2", -] - -[[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 0.3.3", ] [[package]] @@ -3858,11 +3545,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "928fca9cf2aa042393a8325b9ead81d2f0df4cb12e1e24cef072922ccd99c5af" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -3871,7 +3558,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.2.16", "libredox", "thiserror 1.0.69", ] @@ -3935,7 +3622,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", @@ -3953,9 +3640,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.15" +version = "0.12.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +checksum = "e98ff6b0dbbe4d5a37318f433d4fc82babd21631f194d370409ceb2e40b2f0b5" dependencies = [ "base64 0.22.1", "bytes", @@ -3977,7 +3664,6 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", @@ -3987,6 +3673,7 @@ dependencies = [ "tokio-rustls", "tokio-util", "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", @@ -3994,7 +3681,6 @@ dependencies = [ "wasm-streams", "web-sys", "webpki-roots", - "windows-registry", ] [[package]] @@ -4004,7 +3690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ "hmac", - "subtle 2.6.1", + "subtle", ] [[package]] @@ -4014,8 +3700,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", - "cfg-if 1.0.0", - "getrandom 0.2.15", + "cfg-if", + "getrandom 0.2.16", "libc", "untrusted", "windows-sys 0.52.0", @@ -4029,8 +3715,8 @@ checksum = "3df6368f71f205ff9c33c076d170dd56ebf68e8161c733c0caa07a7a5509ed53" [[package]] name = "risc0-binfmt" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.1" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "borsh", @@ -4047,8 +3733,8 @@ dependencies = [ [[package]] name = "risc0-build" -version = "2.1.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.1.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "cargo_metadata", @@ -4071,27 +3757,27 @@ dependencies = [ [[package]] name = "risc0-build-kernel" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "directories", "glob", "hex", "rayon", - "sha2 0.10.8", + "sha2", "tempfile", ] [[package]] name = "risc0-circuit-keccak" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "bytemuck", - "cfg-if 1.0.0", + "cfg-if", "keccak", - "paste 1.0.15", + "paste", "rayon", "risc0-binfmt", "risc0-circuit-keccak-sys", @@ -4106,7 +3792,7 @@ dependencies = [ [[package]] name = "risc0-circuit-keccak-sys" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "cust", @@ -4120,12 +3806,12 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "bytemuck", - "cfg-if 1.0.0", + "cfg-if", "cust", "downloader", "hex", @@ -4138,7 +3824,7 @@ dependencies = [ "risc0-sys", "risc0-zkp", "serde", - "sha2 0.10.8", + "sha2", "tracing", "zip", ] @@ -4146,7 +3832,7 @@ dependencies = [ [[package]] name = "risc0-circuit-recursion-sys" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "glob", "risc0-build-kernel", @@ -4157,21 +3843,21 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "2.0.2" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.4" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "auto_ops", "bit-vec", "bytemuck", "byteorder", - "cfg-if 1.0.0", + "cfg-if", "derive_more 2.0.1", "enum-map", "malachite", "num-derive", "num-traits", - "paste 1.0.15", + "paste", "postcard", "rand 0.8.5", "rayon", @@ -4188,8 +3874,8 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im-sys" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "cc", "cust", @@ -4204,7 +3890,7 @@ dependencies = [ [[package]] name = "risc0-core" version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "bytemuck", "bytemuck_derive", @@ -4215,8 +3901,8 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.1" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "ark-bn254", @@ -4240,7 +3926,7 @@ dependencies = [ [[package]] name = "risc0-sys" version = "1.4.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "cust", @@ -4250,8 +3936,8 @@ dependencies = [ [[package]] name = "risc0-zkos-v1compat" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.1" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "include_bytes_aligned", "no_std_strings", @@ -4259,23 +3945,23 @@ dependencies = [ [[package]] name = "risc0-zkp" -version = "2.0.0" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.1" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "anyhow", "blake2", "borsh", "bytemuck", - "cfg-if 1.0.0", + "cfg-if", "cust", - "digest 0.10.7", + "digest", "ff", "hex", "hex-literal", "metal", "ndarray", "parking_lot", - "paste 1.0.15", + "paste", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -4283,15 +3969,15 @@ dependencies = [ "risc0-sys", "risc0-zkvm-platform", "serde", - "sha2 0.10.8", + "sha2", "stability", "tracing", ] [[package]] name = "risc0-zkvm" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.1.0" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "addr2line 0.22.0", "anyhow", @@ -4303,7 +3989,7 @@ dependencies = [ "derive_more 2.0.1", "elf", "enum-map", - "getrandom 0.2.15", + "getrandom 0.2.16", "hex", "keccak", "lazy-regex", @@ -4327,7 +4013,7 @@ dependencies = [ "rzup", "semver", "serde", - "sha2 0.10.8", + "sha2", "stability", "tempfile", "tracing", @@ -4336,12 +4022,13 @@ dependencies = [ [[package]] name = "risc0-zkvm-platform" -version = "2.0.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +version = "2.0.2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "bytemuck", - "cfg-if 1.0.0", - "getrandom 0.2.15", + "cfg-if", + "getrandom 0.2.16", + "getrandom 0.3.3", "libm", "stability", ] @@ -4363,7 +4050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4382d3af3a4ebdae7f64ba6edd9114fff92c89808004c4943b393377a25d001" dependencies = [ "downcast-rs", - "paste 1.0.15", + "paste", ] [[package]] @@ -4372,7 +4059,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb09b49230ba22e8c676e7b75dfe2887dea8121f18b530ae0ba519ce442d2b21" dependencies = [ - "sha2 0.10.8", + "sha2", ] [[package]] @@ -4408,7 +4095,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys 0.4.15", @@ -4417,28 +4104,28 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", - "linux-raw-sys 0.9.3", + "linux-raw-sys 0.9.4", "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.25" +version = "0.23.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" +checksum = "730944ca083c1c233a75c09f199e973ca499344a2b7ba9e755c457e86fb4a321" dependencies = [ "once_cell", "ring", "rustls-pki-types", "rustls-webpki", - "subtle 2.6.1", + "subtle", "zeroize", ] @@ -4451,29 +4138,21 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "rustls-pki-types" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" dependencies = [ "web-time", + "zeroize", ] [[package]] name = "rustls-webpki" -version = "0.103.1" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "ring", "rustls-pki-types", @@ -4482,9 +4161,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" [[package]] name = "ruzstd" @@ -4493,7 +4172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5174a470eeb535a721ae9fdd6e291c2411a906b96592182d05217591d5c5cf7b" dependencies = [ "byteorder", - "derive_more 0.99.19", + "derive_more 0.99.20", "twox-hash", ] @@ -4506,14 +4185,14 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "rzup" version = "0.4.1" -source = "git+https://github.com/risc0/risc0.git?branch=release-2.0#fdd54f961b84b38831a8a488b9d67534a02d80a2" +source = "git+https://github.com/risc0/risc0.git?branch=release-2.1#f34d6913945ab9f214219f3cbee1703f63936cc4" dependencies = [ "semver", "serde", "strum", "tempfile", "thiserror 2.0.12", - "toml 0.8.20", + "toml 0.8.22", "yaml-rust2", ] @@ -4533,13 +4212,12 @@ dependencies = [ "k256", "light-poseidon", "log", - "monotree", "rand 0.8.5", "risc0-zkvm", "secp256k1-zkp", "serde", "serde_json", - "sha2 0.10.8", + "sha2", "storage", "utxo", ] @@ -4567,10 +4245,10 @@ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", - "generic-array 0.14.7", + "generic-array", "pkcs8", "serdect", - "subtle 2.6.1", + "subtle", "zeroize", ] @@ -4623,7 +4301,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation", "core-foundation-sys", "libc", @@ -4730,7 +4408,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -4782,45 +4460,20 @@ 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", + "digest", ] [[package]] name = "sha2" -version = "0.8.2" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -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.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" -dependencies = [ - "block-buffer 0.7.3", - "byte-tools", - "digest 0.8.1", - "keccak", - "opaque-debug 0.2.3", + "digest", ] [[package]] @@ -4831,9 +4484,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.2" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] @@ -4844,7 +4497,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.7", + "digest", "rand_core 0.6.4", ] @@ -4865,9 +4518,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "socket2" @@ -4881,9 +4534,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4925,7 +4578,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d904e7009df136af5297832a3ace3370cd14ff1546a232f4f185036c2736fcac" dependencies = [ "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -4987,15 +4640,9 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.100", + "syn 2.0.101", ] -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - [[package]] name = "subtle" version = "2.6.1" @@ -5015,9 +4662,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.100" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -5041,13 +4688,13 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -5079,14 +4726,14 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.19.1" +version = "3.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom 0.3.2", + "getrandom 0.3.3", "once_cell", - "rustix 1.0.5", + "rustix 1.0.7", "windows-sys 0.59.0", ] @@ -5138,7 +4785,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -5149,7 +4796,7 @@ checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -5185,9 +4832,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.7.6" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" dependencies = [ "displaydoc", "zerovec", @@ -5210,9 +4857,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.44.1" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "bytes", @@ -5221,7 +4868,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.9", + "socket2 0.5.10", "windows-sys 0.52.0", ] @@ -5247,9 +4894,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.14" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" dependencies = [ "bytes", "futures-core", @@ -5272,21 +4919,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.20" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" +checksum = "05ae329d1f08c4d17a59bed7ff5b5a769d062e64a62d34a3261b219e62cd5aae" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.24", + "toml_edit 0.22.26", ] [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "3da5db5a963e24bc68be8b17b6fa82814bb22ee8660f192bb182771d498f09a3" dependencies = [ "serde", ] @@ -5297,7 +4944,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", @@ -5306,17 +4953,24 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.24" +version = "0.22.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" +checksum = "310068873db2c5b3e7659d2cc35d21855dbafa50d1ce336397c666e3cb08137e" dependencies = [ - "indexmap 2.8.0", + "indexmap 2.9.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.7.4", + "toml_write", + "winnow 0.7.10", ] +[[package]] +name = "toml_write" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfb942dfe1d8e29a7ee7fcbde5bd2b9a25fb89aa70caea2eba3bee836ff41076" + [[package]] name = "tower" version = "0.5.2" @@ -5332,6 +4986,24 @@ dependencies = [ "tower-service", ] +[[package]] +name = "tower-http" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdb0c213ca27a9f57ab69ddb290fd80d970922355b83ae380b395d3986b8a2e" +dependencies = [ + "bitflags 2.9.1", + "bytes", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -5364,7 +5036,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -5398,7 +5070,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "static_assertions", ] @@ -5435,7 +5107,7 @@ checksum = "35f5380909ffc31b4de4f4bdf96b877175a016aa2ca98cee39fcfd8c4d53d952" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -5457,7 +5129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ "crypto-common", - "subtle 2.6.1", + "subtle", ] [[package]] @@ -5477,12 +5149,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - [[package]] name = "utf8_iter" version = "1.0.4" @@ -5498,10 +5164,10 @@ dependencies = [ "env_logger", "hex", "log", - "monotree", + "rand 0.8.5", "serde", "serde_json", - "sha2 0.10.8", + "sha2", ] [[package]] @@ -5554,12 +5220,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" @@ -5581,7 +5241,7 @@ version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", @@ -5597,7 +5257,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "wasm-bindgen-shared", ] @@ -5607,7 +5267,7 @@ version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "once_cell", "wasm-bindgen", @@ -5632,7 +5292,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5681,9 +5341,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" +checksum = "2853738d1cc4f2da3a225c18ec6c3721abb31961096e9dbf5ab35fa88b19cfdb" dependencies = [ "rustls-pki-types", ] @@ -5731,41 +5391,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-link" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" - -[[package]] -name = "windows-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" -dependencies = [ - "windows-result", - "windows-strings", - "windows-targets 0.53.0", -] - -[[package]] -name = "windows-result" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" -dependencies = [ - "windows-link", -] - -[[package]] -name = "windows-strings" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" -dependencies = [ - "windows-link", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -5989,9 +5614,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.4" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97b544156e9bebe1a0ffbc03484fc1ffe3100cbce3ffb17eac35f7cdd7ab36" +checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" dependencies = [ "memchr", ] @@ -6002,7 +5627,7 @@ version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "windows-sys 0.48.0", ] @@ -6012,20 +5637,14 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - [[package]] name = "writeable" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" [[package]] name = "wyz" @@ -6058,9 +5677,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" dependencies = [ "serde", "stable_deref_trait", @@ -6070,54 +5689,34 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.5" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "synstructure", ] [[package]] name = "zerocopy" -version = "0.7.35" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" dependencies = [ - "zerocopy-derive 0.7.35", -] - -[[package]] -name = "zerocopy" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" -dependencies = [ - "zerocopy-derive 0.8.24", + "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.35" +version = "0.8.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] @@ -6137,7 +5736,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", "synstructure", ] @@ -6158,14 +5757,25 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", +] + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", ] [[package]] name = "zerovec" -version = "0.10.4" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", @@ -6174,27 +5784,29 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.100", + "syn 2.0.101", ] [[package]] name = "zip" -version = "2.5.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27c03817464f64e23f6f37574b4fdc8cf65925b5bfd2b0f2aedf959791941f88" +checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50" dependencies = [ "arbitrary", "crc32fast", "crossbeam-utils", + "displaydoc", "flate2", - "indexmap 2.8.0", + "indexmap 2.9.0", "memchr", + "thiserror 2.0.12", "zopfli", ] @@ -6207,6 +5819,7 @@ dependencies = [ "common", "env_logger", "log", + "rand 0.8.5", "risc0-zkvm", "serde", "serde_json", @@ -6217,14 +5830,12 @@ dependencies = [ [[package]] name = "zopfli" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +checksum = "edfc5ee405f504cd4984ecc6f14d02d55cfda60fa4b689434ef4102aae150cd7" dependencies = [ "bumpalo", "crc32fast", - "lockfree-object-pool", "log", - "once_cell", "simd-adler32", ] diff --git a/Cargo.toml b/Cargo.toml index 59417cd..7af2e24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,6 @@ lru = "0.7.8" thiserror = "1.0" rs_merkle = "1.4" sha2 = "0.10.8" -monotree = "0.1.5" hex = "0.4.3" aes-gcm = "0.10.3" toml = "0.7.4" diff --git a/accounts/src/account_core/mod.rs b/accounts/src/account_core/mod.rs index 2d3417c..192c158 100644 --- a/accounts/src/account_core/mod.rs +++ b/accounts/src/account_core/mod.rs @@ -1,14 +1,11 @@ use std::collections::HashMap; use anyhow::Result; -use common::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier, transaction::Tag}; +use common::{merkle_tree_public::TreeHashType, transaction::Tag}; use k256::AffinePoint; use log::info; -use serde::Serialize; -use utxo::{ - utxo_core::{UTXOPayload, UTXO}, - utxo_tree::UTXOSparseMerkleTree, -}; +use serde::{Deserialize, Serialize}; +use utxo::utxo_core::UTXO; use crate::key_management::{ constants_types::{CipherText, Nonce}, @@ -19,11 +16,70 @@ use crate::key_management::{ pub type PublicKey = AffinePoint; pub type AccountAddress = TreeHashType; +#[derive(Clone)] pub struct Account { pub key_holder: AddressKeyHolder, pub address: AccountAddress, pub balance: u64, - pub utxo_tree: UTXOSparseMerkleTree, + pub utxos: HashMap, +} + +#[derive(Serialize, Deserialize, Clone)] +pub struct AccountForSerialization { + pub key_holder: AddressKeyHolder, + pub address: AccountAddress, + pub balance: u64, + pub utxos: HashMap, +} + +impl From for AccountForSerialization { + fn from(value: Account) -> Self { + AccountForSerialization { + key_holder: value.key_holder, + address: value.address, + balance: value.balance, + utxos: value + .utxos + .into_iter() + .map(|(key, val)| (hex::encode(key), val)) + .collect(), + } + } +} + +impl From for Account { + fn from(value: AccountForSerialization) -> Self { + Account { + key_holder: value.key_holder, + address: value.address, + balance: value.balance, + utxos: value + .utxos + .into_iter() + .map(|(key, val)| (hex::decode(key).unwrap().try_into().unwrap(), val)) + .collect(), + } + } +} + +impl Serialize for Account { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let account_for_serialization: AccountForSerialization = From::from(self.clone()); + account_for_serialization.serialize(serializer) + } +} + +impl<'de> Deserialize<'de> for Account { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + let account_for_serialization = ::deserialize(deserializer)?; + Ok(account_for_serialization.into()) + } } ///A strucure, which represents all the visible(public) information @@ -42,26 +98,26 @@ impl Account { let key_holder = AddressKeyHolder::new_os_random(); let address = key_holder.address; let balance = 0; - let utxo_tree = UTXOSparseMerkleTree::new(); + let utxos = HashMap::new(); Self { key_holder, address, balance, - utxo_tree, + utxos, } } pub fn new_with_balance(balance: u64) -> Self { let key_holder = AddressKeyHolder::new_os_random(); let address = key_holder.address; - let utxo_tree = UTXOSparseMerkleTree::new(); + let utxos = HashMap::new(); Self { key_holder, address, balance, - utxo_tree, + utxos, } } @@ -87,21 +143,14 @@ impl Account { .decrypt_data(ephemeral_public_key_sender, ciphertext, nonce) } - pub fn mark_spent_utxo( - &mut self, - utxo_nullifier_map: HashMap, - ) -> Result<()> { - for (hash, nullifier) in utxo_nullifier_map { - if let Some(utxo_entry) = self.utxo_tree.store.get_mut(&hash) { - utxo_entry.consume_utxo(nullifier)?; - } - } - - Ok(()) - } - pub fn add_new_utxo_outputs(&mut self, utxos: Vec) -> Result<()> { - Ok(self.utxo_tree.insert_items(utxos)?) + for utxo in utxos { + if self.utxos.contains_key(&utxo.hash) { + return Err(anyhow::anyhow!("UTXO already exists")); + } + self.utxos.insert(utxo.hash, utxo); + } + Ok(()) } pub fn update_public_balance(&mut self, new_balance: u64) { @@ -114,16 +163,14 @@ impl Account { amount: u128, privacy_flag: bool, ) -> Result<()> { - let payload_with_asset = UTXOPayload { - owner: self.address, - asset: serde_json::to_vec(&asset)?, + let asset_utxo = UTXO::new( + self.address, + serde_json::to_vec(&asset)?, amount, privacy_flag, - }; + ); - let asset_utxo = UTXO::create_utxo_from_payload(payload_with_asset)?; - - self.utxo_tree.insert_item(asset_utxo)?; + self.utxos.insert(asset_utxo.hash, asset_utxo); Ok(()) } @@ -159,18 +206,8 @@ impl Default for Account { mod tests { use super::*; - fn generate_dummy_utxo_nullifier() -> UTXONullifier { - UTXONullifier::default() - } - - fn generate_dummy_utxo(address: TreeHashType, amount: u128) -> anyhow::Result { - let payload = UTXOPayload { - owner: address, - asset: vec![], - amount, - privacy_flag: false, - }; - UTXO::create_utxo_from_payload(payload) + fn generate_dummy_utxo(address: TreeHashType, amount: u128) -> UTXO { + UTXO::new(address, vec![], amount, false) } #[test] @@ -181,31 +218,16 @@ mod tests { assert!(account.key_holder.address != [0u8; 32]); // Check if the address is not empty } - #[test] - fn test_mark_spent_utxo() { - let mut account = Account::new(); - let utxo = generate_dummy_utxo(account.address, 100).unwrap(); - account.add_new_utxo_outputs(vec![utxo]).unwrap(); - - let mut utxo_nullifier_map = HashMap::new(); - utxo_nullifier_map.insert(account.address, generate_dummy_utxo_nullifier()); - - let result = account.mark_spent_utxo(utxo_nullifier_map); - - assert!(result.is_ok()); - assert!(account.utxo_tree.store.get(&account.address).is_none()); - } - #[test] fn test_add_new_utxo_outputs() { let mut account = Account::new(); - let utxo1 = generate_dummy_utxo(account.address, 100).unwrap(); - let utxo2 = generate_dummy_utxo(account.address, 200).unwrap(); + let utxo1 = generate_dummy_utxo(account.address, 100); + let utxo2 = generate_dummy_utxo(account.address, 200); let result = account.add_new_utxo_outputs(vec![utxo1.clone(), utxo2.clone()]); assert!(result.is_ok()); - assert_eq!(account.utxo_tree.store.len(), 2); + assert_eq!(account.utxos.len(), 2); } #[test] @@ -225,6 +247,6 @@ mod tests { let result = account.add_asset(asset, amount, false); assert!(result.is_ok()); - assert_eq!(account.utxo_tree.store.len(), 1); + assert_eq!(account.utxos.len(), 1); } } diff --git a/accounts/src/key_management/ephemeral_key_holder.rs b/accounts/src/key_management/ephemeral_key_holder.rs index 9e3a9b1..ecfb09e 100644 --- a/accounts/src/key_management/ephemeral_key_holder.rs +++ b/accounts/src/key_management/ephemeral_key_holder.rs @@ -1,4 +1,5 @@ -use aes_gcm::{aead::Aead, AeadCore, Aes256Gcm, Key, KeyInit}; +use aes_gcm::{aead::Aead, AeadCore, Aes256Gcm, KeyInit}; +use elliptic_curve::point::AffineCoordinates; use elliptic_curve::PrimeField; use k256::{AffinePoint, FieldBytes, Scalar}; use log::info; @@ -39,14 +40,8 @@ impl EphemeralKeyHolder { viewing_public_key_receiver: AffinePoint, data: &[u8], ) -> (CipherText, Nonce) { - let key_point = self.calculate_shared_secret_sender(viewing_public_key_receiver); - let binding = serde_json::to_vec(&key_point).unwrap(); - let key_raw = &binding.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw.try_into().unwrap(); - - let key: Key = key_raw_adjust.into(); - - let cipher = Aes256Gcm::new(&key); + let shared_secret = self.calculate_shared_secret_sender(viewing_public_key_receiver); + let cipher = Aes256Gcm::new(&shared_secret.x()); let nonce = Aes256Gcm::generate_nonce(&mut OsRng); (cipher.encrypt(&nonce, data).unwrap(), nonce) diff --git a/accounts/src/key_management/mod.rs b/accounts/src/key_management/mod.rs index 25673f6..69b8ce0 100644 --- a/accounts/src/key_management/mod.rs +++ b/accounts/src/key_management/mod.rs @@ -1,10 +1,12 @@ -use aes_gcm::{aead::Aead, Aes256Gcm, Key, KeyInit}; +use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit}; use common::merkle_tree_public::TreeHashType; use constants_types::{CipherText, Nonce}; +use elliptic_curve::point::AffineCoordinates; use ephemeral_key_holder::EphemeralKeyHolder; use k256::AffinePoint; use log::info; use secret_holders::{SeedHolder, TopSecretKeyHolder, UTXOSecretKeyHolder}; +use serde::{Deserialize, Serialize}; use crate::account_core::PublicKey; @@ -12,7 +14,7 @@ pub mod constants_types; pub mod ephemeral_key_holder; pub mod secret_holders; -#[derive(Clone)] +#[derive(Serialize, Deserialize, Clone)] ///Entrypoint to key management pub struct AddressKeyHolder { //Will be useful in future @@ -63,14 +65,8 @@ impl AddressKeyHolder { ciphertext: CipherText, nonce: Nonce, ) -> Result, aes_gcm::Error> { - let key_point = self.calculate_shared_secret_receiver(ephemeral_public_key_sender); - let binding = serde_json::to_vec(&key_point).unwrap(); - let key_raw = &binding.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw.try_into().unwrap(); - - let key: Key = key_raw_adjust.into(); - - let cipher = Aes256Gcm::new(&key); + let shared_secret = self.calculate_shared_secret_receiver(ephemeral_public_key_sender); + let cipher = Aes256Gcm::new(&shared_secret.x()); cipher.decrypt(&nonce, ciphertext.as_slice()) } @@ -115,6 +111,7 @@ mod tests { use constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; use elliptic_curve::ff::Field; use elliptic_curve::group::prime::PrimeCurveAffine; + use elliptic_curve::point::AffineCoordinates; use k256::{AffinePoint, ProjectivePoint, Scalar}; use super::*; @@ -154,22 +151,14 @@ mod tests { let address_key_holder = AddressKeyHolder::new_os_random(); // Generate an ephemeral key and shared secret - let scalar = Scalar::random(OsRng); let ephemeral_public_key_sender = address_key_holder .produce_ephemeral_key_holder() .generate_ephemeral_public_key(); let shared_secret = address_key_holder.calculate_shared_secret_receiver(ephemeral_public_key_sender); - // Prepare the encryption key from shared secret - let key_raw = serde_json::to_vec(&shared_secret).unwrap(); - let key_raw_adjust_pre = &key_raw.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw_adjust_pre.try_into().unwrap(); - let key: Key = key_raw_adjust.into(); - - let cipher = Aes256Gcm::new(&key); - // Encrypt sample data + let cipher = Aes256Gcm::new(&shared_secret.x()); let nonce = Nonce::from_slice(b"unique nonce"); let plaintext = b"Sensitive data"; let ciphertext = cipher @@ -225,19 +214,12 @@ mod tests { // Generate ephemeral public key and shared secret let scalar = Scalar::random(OsRng); - let ephemeral_public_key_sender = (ProjectivePoint::generator() * scalar).to_affine(); + let ephemeral_public_key_sender = (ProjectivePoint::GENERATOR * scalar).to_affine(); let shared_secret = address_key_holder.calculate_shared_secret_receiver(ephemeral_public_key_sender); - // Prepare the encryption key from shared secret - let key_raw = serde_json::to_vec(&shared_secret).unwrap(); - let key_raw_adjust_pre = &key_raw.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw_adjust_pre.try_into().unwrap(); - let key: Key = key_raw_adjust.into(); - - let cipher = Aes256Gcm::new(&key); - // Encrypt sample data with a specific nonce + let cipher = Aes256Gcm::new(&shared_secret.x()); let nonce = Nonce::from_slice(b"unique nonce"); let plaintext = b"Sensitive data"; let ciphertext = cipher @@ -265,19 +247,12 @@ mod tests { // Generate ephemeral public key and shared secret let scalar = Scalar::random(OsRng); - let ephemeral_public_key_sender = (ProjectivePoint::generator() * scalar).to_affine(); + let ephemeral_public_key_sender = (ProjectivePoint::GENERATOR * scalar).to_affine(); let shared_secret = address_key_holder.calculate_shared_secret_receiver(ephemeral_public_key_sender); - // Prepare the encryption key from shared secret - let key_raw = serde_json::to_vec(&shared_secret).unwrap(); - let key_raw_adjust_pre = &key_raw.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw_adjust_pre.try_into().unwrap(); - let key: Key = key_raw_adjust.into(); - - let cipher = Aes256Gcm::new(&key); - // Encrypt sample data + let cipher = Aes256Gcm::new(&shared_secret.x()); let nonce = Nonce::from_slice(b"unique nonce"); let plaintext = b"Sensitive data"; let ciphertext = cipher @@ -307,7 +282,7 @@ mod tests { // Generate ephemeral key and shared secret let scalar = Scalar::random(OsRng); - let ephemeral_public_key_sender = (ProjectivePoint::generator() * scalar).to_affine(); + let ephemeral_public_key_sender = (ProjectivePoint::GENERATOR * scalar).to_affine(); // Encrypt sample data let plaintext = b"Round-trip test data"; @@ -315,12 +290,7 @@ mod tests { let shared_secret = address_key_holder.calculate_shared_secret_receiver(ephemeral_public_key_sender); - // Prepare the encryption key from shared secret - let key_raw = serde_json::to_vec(&shared_secret).unwrap(); - let key_raw_adjust_pre = &key_raw.as_slice()[..32]; - let key_raw_adjust: [u8; 32] = key_raw_adjust_pre.try_into().unwrap(); - let key: Key = key_raw_adjust.into(); - let cipher = Aes256Gcm::new(&key); + let cipher = Aes256Gcm::new(&shared_secret.x()); let ciphertext = cipher .encrypt(nonce, plaintext.as_ref()) diff --git a/accounts/src/key_management/secret_holders.rs b/accounts/src/key_management/secret_holders.rs index 399ef44..45fd792 100644 --- a/accounts/src/key_management/secret_holders.rs +++ b/accounts/src/key_management/secret_holders.rs @@ -2,6 +2,7 @@ use common::merkle_tree_public::TreeHashType; use elliptic_curve::PrimeField; use k256::{AffinePoint, FieldBytes, Scalar}; use rand::{rngs::OsRng, RngCore}; +use serde::{Deserialize, Serialize}; use sha2::{digest::FixedOutput, Digest}; use super::constants_types::{NULLIFIER_SECRET_CONST, VIEWING_SECRET_CONST}; @@ -13,13 +14,13 @@ pub struct SeedHolder { seed: Scalar, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] ///Secret spending key holder. Produces `UTXOSecretKeyHolder` objects. pub struct TopSecretKeyHolder { pub secret_spending_key: Scalar, } -#[derive(Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone)] ///Nullifier secret key and viewing secret key holder. Produces public keys. Can produce address. Can produce shared secret for recepient. pub struct UTXOSecretKeyHolder { pub nullifier_secret_key: Scalar, diff --git a/common/Cargo.toml b/common/Cargo.toml index f3327ea..2b51d66 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -9,8 +9,7 @@ thiserror.workspace = true serde_json.workspace = true serde.workspace = true reqwest.workspace = true -monotree.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } rs_merkle.workspace = true sha2.workspace = true diff --git a/common/src/commitments_sparse_merkle_tree.rs b/common/src/commitments_sparse_merkle_tree.rs deleted file mode 100644 index 3182275..0000000 --- a/common/src/commitments_sparse_merkle_tree.rs +++ /dev/null @@ -1,283 +0,0 @@ -use monotree::database::MemoryDB; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree, Proof}; - -use crate::commitment::Commitment; -use crate::merkle_tree_public::CommitmentHashType; - -pub struct CommitmentsSparseMerkleTree { - pub curr_root: Option, - pub tree: Monotree, - pub hasher: Blake3, -} - -impl CommitmentsSparseMerkleTree { - pub fn new() -> Self { - CommitmentsSparseMerkleTree { - curr_root: None, - tree: Monotree::default(), - hasher: Blake3::new(), - } - } - - pub fn insert_item(&mut self, commitment: Commitment) -> Result<(), monotree::Errors> { - let root = self - .curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()); - - let new_root = self.tree.insert( - root, - &commitment.commitment_hash[0..32].try_into().unwrap(), - &commitment.commitment_hash[0..32].try_into().unwrap(), - )?; - - self.curr_root = new_root.map(|val| val.to_vec()); - - Ok(()) - } - - pub fn insert_items(&mut self, commitments: Vec) -> Result<(), monotree::Errors> { - let root = self - .curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()); - - let hashes: Vec<_> = commitments - .iter() - .map(|val| val.commitment_hash[0..32].try_into().unwrap()) - .collect::>(); - - let new_root = self.tree.inserts(root, &hashes, &hashes)?; - - self.curr_root = new_root.map(|val| val[0..32].try_into().unwrap()); - - Ok(()) - } - - pub fn search_item_inclusion( - &mut self, - commitment_hash: CommitmentHashType, - ) -> Result { - self.tree - .get( - self.curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()), - &commitment_hash[0..32].try_into().unwrap(), - ) - .map(|data| data.is_some()) - } - - pub fn search_item_inclusions( - &mut self, - commitment_hashes: &[CommitmentHashType], - ) -> Result, monotree::Errors> { - let mut inclusions = vec![]; - - for nullifier_hash in commitment_hashes { - let is_included = self - .tree - .get( - self.curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()), - nullifier_hash[0..32].try_into().unwrap(), - ) - .map(|data| data.is_some())?; - - inclusions.push(is_included); - } - - Ok(inclusions) - } - - pub fn get_non_membership_proof( - &mut self, - commitment_hash: CommitmentHashType, - ) -> Result<(Option, Option), monotree::Errors> { - let is_member = self.search_item_inclusion(commitment_hash.clone())?; - - if is_member { - Err(monotree::Errors::new("Is a member")) - } else { - Ok(( - self.tree.get_merkle_proof( - self.curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()), - &commitment_hash, - )?, - self.curr_root.clone(), - )) - } - } - - #[allow(clippy::type_complexity)] - pub fn get_non_membership_proofs( - &mut self, - commitment_hashes: &[CommitmentHashType], - ) -> Result, Option)>, monotree::Errors> { - let mut non_membership_proofs = vec![]; - - for commitment_hash in commitment_hashes { - let is_member = self.search_item_inclusion(commitment_hash.clone())?; - - if is_member { - return Err(monotree::Errors::new( - format!("{commitment_hash:?} Is a member").as_str(), - )); - } else { - non_membership_proofs.push(( - self.tree.get_merkle_proof( - self.curr_root - .as_ref() - .map(|val| val[0..32].try_into().unwrap()), - commitment_hash, - )?, - self.curr_root.clone(), - )) - }; - } - - Ok(non_membership_proofs) - } -} - -impl Default for CommitmentsSparseMerkleTree { - fn default() -> Self { - Self::new() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::nullifier::UTXONullifier; - use monotree::database::MemoryDB; - use monotree::hasher::Blake3; - use monotree::Monotree; - - fn create_nullifier(hash: CommitmentHashType) -> Commitment { - Commitment { - commitment_hash: hash, - } - } - - #[test] - fn test_new_tree_initialization() { - let tree = CommitmentsSparseMerkleTree::new(); - assert!(tree.curr_root.is_none()); - } - - #[test] - fn test_insert_single_item() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32].to_vec()); // Sample 32-byte hash - - let result = tree.insert_item(nullifier); - assert!(result.is_ok()); - assert!(tree.curr_root.is_some()); - } - - #[test] - fn test_insert_multiple_items() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifiers = vec![ - create_nullifier([1u8; 32].to_vec()), - create_nullifier([2u8; 32].to_vec()), - create_nullifier([3u8; 32].to_vec()), - ]; - - let result = tree.insert_items(nullifiers); - assert!(result.is_ok()); - assert!(tree.curr_root.is_some()); - } - - #[test] - fn test_search_item_inclusion() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32].to_vec()); - - tree.insert_item(nullifier.clone()).unwrap(); - - let result = tree.search_item_inclusion([1u8; 32].to_vec()); - assert!(result.is_ok()); - assert_eq!(result.unwrap(), true); - - let non_existing = tree.search_item_inclusion([99u8; 32].to_vec()); - assert!(non_existing.is_ok()); - assert_eq!(non_existing.unwrap(), false); - } - - #[test] - fn test_search_multiple_item_inclusions() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifiers = vec![ - create_nullifier([1u8; 32].to_vec()), - create_nullifier([2u8; 32].to_vec()), - create_nullifier([3u8; 32].to_vec()), - ]; - - tree.insert_items(nullifiers).unwrap(); - - let search_hashes = vec![[1u8; 32].to_vec(), [2u8; 32].to_vec(), [99u8; 32].to_vec()]; - let result = tree.search_item_inclusions(&search_hashes); - assert!(result.is_ok()); - - let expected_results = vec![true, true, false]; - assert_eq!(result.unwrap(), expected_results); - } - - #[test] - fn test_non_membership_proof() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let non_member_hash = [5u8; 32].to_vec(); - - let result = tree.get_non_membership_proof(non_member_hash); - assert!(result.is_ok()); - - let (proof, root) = result.unwrap(); - assert!(root.is_none()); - } - - #[test] - fn test_non_membership_proofs_multiple() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let non_member_hashes = vec![[5u8; 32].to_vec(), [6u8; 32].to_vec(), [7u8; 32].to_vec()]; - - let result = tree.get_non_membership_proofs(&non_member_hashes); - assert!(result.is_ok()); - - let proofs = result.unwrap(); - for (proof, root) in proofs { - assert!(root.is_none()); - } - } - - #[test] - fn test_insert_and_get_proof_of_existing_item() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32].to_vec()); - - tree.insert_item(nullifier.clone()).unwrap(); - - let proof_result = tree.get_non_membership_proof([1u8; 32].to_vec()); - assert!(proof_result.is_err()); - } - - #[test] - fn test_insert_and_get_proofs_of_existing_items() { - let mut tree = CommitmentsSparseMerkleTree::new(); - let nullifiers = vec![ - create_nullifier([1u8; 32].to_vec()), - create_nullifier([2u8; 32].to_vec()), - ]; - - tree.insert_items(nullifiers).unwrap(); - - let proof_result = - tree.get_non_membership_proofs(&[[1u8; 32].to_vec(), [2u8; 32].to_vec()]); - assert!(proof_result.is_err()); - } -} diff --git a/common/src/lib.rs b/common/src/lib.rs index a13fdd4..46868d9 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -3,10 +3,8 @@ use serde::Deserialize; pub mod block; pub mod commitment; -pub mod commitments_sparse_merkle_tree; pub mod merkle_tree_public; pub mod nullifier; -pub mod nullifier_sparse_merkle_tree; pub mod rpc_primitives; pub mod transaction; pub mod utxo_commitment; @@ -67,8 +65,6 @@ pub enum ExecutionFailureKind { AmountMismatchError, #[error("Sequencer client error: {0:?}")] SequencerClientError(#[from] SequencerClientError), - #[error("Datebase returned error : {0:?}")] - MonoTreeError(#[from] monotree::Errors), #[error("Insufficient gas for operation")] InsufficientGasError, #[error("Can not pay for operation")] diff --git a/common/src/merkle_tree_public/merkle_tree.rs b/common/src/merkle_tree_public/merkle_tree.rs index 16d185e..3540b06 100644 --- a/common/src/merkle_tree_public/merkle_tree.rs +++ b/common/src/merkle_tree_public/merkle_tree.rs @@ -1,6 +1,11 @@ -use std::collections::HashMap; +use std::{collections::HashMap, fmt, marker::PhantomData}; use rs_merkle::{MerkleProof, MerkleTree}; +use serde::{ + de::{SeqAccess, Visitor}, + ser::SerializeSeq, + Deserialize, Deserializer, Serialize, +}; use crate::{transaction::Transaction, utxo_commitment::UTXOCommitment}; @@ -12,6 +17,70 @@ pub struct HashStorageMerkleTree { tree: MerkleTree, } +impl Serialize for HashStorageMerkleTree { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let mut vector = self.leaves.iter().collect::>(); + vector.sort_by(|a, b| a.0.cmp(b.0)); + + let mut seq = serializer.serialize_seq(Some(self.leaves.len()))?; + for element in vector.iter() { + seq.serialize_element(element.1)?; + } + seq.end() + } +} + +struct HashStorageMerkleTreeDeserializer { + marker: PhantomData HashStorageMerkleTree>, +} + +impl HashStorageMerkleTreeDeserializer { + fn new() -> Self { + HashStorageMerkleTreeDeserializer { + marker: PhantomData, + } + } +} + +impl<'de, Leav: TreeLeavItem + Clone + Deserialize<'de>> Visitor<'de> + for HashStorageMerkleTreeDeserializer +{ + type Value = HashStorageMerkleTree; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("HashStorageMerkleTree key value sequence.") + } + + fn visit_seq(self, mut seq: A) -> Result + where + A: SeqAccess<'de>, + { + let mut vector = vec![]; + + loop { + let opt_key = seq.next_element::()?; + if let Some(value) = opt_key { + vector.push(value); + } else { + break; + } + } + + Ok(HashStorageMerkleTree::new(vector)) + } +} + +impl<'de, Leav: TreeLeavItem + Clone + Deserialize<'de>> serde::Deserialize<'de> + for HashStorageMerkleTree +{ + fn deserialize>(deserializer: D) -> Result { + deserializer.deserialize_seq(HashStorageMerkleTreeDeserializer::new()) + } +} + pub type PublicTransactionMerkleTree = HashStorageMerkleTree; pub type UTXOCommitmentsMerkleTree = HashStorageMerkleTree; @@ -101,7 +170,7 @@ mod tests { use super::*; // Mock implementation of TreeLeavItem trait for testing - #[derive(Debug, Clone, PartialEq, Eq, Hash)] + #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] struct MockTransaction { pub hash: TreeHashType, } @@ -136,6 +205,26 @@ mod tests { assert!(tree.get_root().is_some()); } + #[test] + fn test_new_merkle_tree_serialize() { + let tx1 = MockTransaction { + hash: get_first_32_bytes("tx1"), + }; + let tx2 = MockTransaction { + hash: get_first_32_bytes("tx2"), + }; + + let tree = HashStorageMerkleTree::new(vec![tx1.clone(), tx2.clone()]); + + let binding = serde_json::to_vec(&tree).unwrap(); + + let obj: HashStorageMerkleTree = serde_json::from_slice(&binding).unwrap(); + + assert_eq!(tree.leaves, obj.leaves); + assert_eq!(tree.hash_to_id_map, obj.hash_to_id_map); + assert_eq!(tree.tree.root(), obj.tree.root()); + } + #[test] fn test_get_tx() { let tx1 = MockTransaction { diff --git a/common/src/nullifier.rs b/common/src/nullifier.rs index 5033fa6..2c95741 100644 --- a/common/src/nullifier.rs +++ b/common/src/nullifier.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use crate::merkle_tree_public::TreeHashType; //ToDo: Update Nullifier model, when it is clear -#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq)] +#[derive(Debug, Serialize, Deserialize, Clone, Default, PartialEq, Eq, Hash)] ///General nullifier object pub struct UTXONullifier { pub utxo_hash: TreeHashType, diff --git a/common/src/nullifier_sparse_merkle_tree.rs b/common/src/nullifier_sparse_merkle_tree.rs deleted file mode 100644 index 282fccc..0000000 --- a/common/src/nullifier_sparse_merkle_tree.rs +++ /dev/null @@ -1,245 +0,0 @@ -use monotree::database::MemoryDB; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree, Proof}; - -use crate::merkle_tree_public::TreeHashType; -use crate::nullifier::UTXONullifier; - -pub struct NullifierSparseMerkleTree { - pub curr_root: Option, - pub tree: Monotree, - pub hasher: Blake3, -} - -impl NullifierSparseMerkleTree { - pub fn new() -> Self { - NullifierSparseMerkleTree { - curr_root: None, - tree: Monotree::default(), - hasher: Blake3::new(), - } - } - - pub fn insert_item(&mut self, nullifier: UTXONullifier) -> Result<(), monotree::Errors> { - let root = self.curr_root.as_ref(); - - let new_root = self - .tree - .insert(root, &nullifier.utxo_hash, &nullifier.utxo_hash)?; - - self.curr_root = new_root; - - Ok(()) - } - - pub fn insert_items(&mut self, nullifiers: Vec) -> Result<(), monotree::Errors> { - let root = self.curr_root.as_ref(); - - let hashes: Vec = nullifiers.iter().map(|nu| nu.utxo_hash).collect(); - - let new_root = self.tree.inserts(root, &hashes, &hashes)?; - - self.curr_root = new_root; - - Ok(()) - } - - pub fn search_item_inclusion( - &mut self, - nullifier_hash: TreeHashType, - ) -> Result { - self.tree - .get(self.curr_root.as_ref(), &nullifier_hash) - .map(|data| data.is_some()) - } - - pub fn search_item_inclusions( - &mut self, - nullifier_hashes: &[TreeHashType], - ) -> Result, monotree::Errors> { - let mut inclusions = vec![]; - - for nullifier_hash in nullifier_hashes { - let is_included = self - .tree - .get(self.curr_root.as_ref(), nullifier_hash) - .map(|data| data.is_some())?; - - inclusions.push(is_included); - } - - Ok(inclusions) - } - - pub fn get_non_membership_proof( - &mut self, - nullifier_hash: TreeHashType, - ) -> Result<(Option, Option), monotree::Errors> { - let is_member = self.search_item_inclusion(nullifier_hash)?; - - if is_member { - Err(monotree::Errors::new("Is a member")) - } else { - Ok(( - self.tree - .get_merkle_proof(self.curr_root.as_ref(), &nullifier_hash)?, - self.curr_root, - )) - } - } - - #[allow(clippy::type_complexity)] - pub fn get_non_membership_proofs( - &mut self, - nullifier_hashes: &[TreeHashType], - ) -> Result, Option)>, monotree::Errors> { - let mut non_membership_proofs = vec![]; - - for nullifier_hash in nullifier_hashes { - let is_member = self.search_item_inclusion(*nullifier_hash)?; - - if is_member { - return Err(monotree::Errors::new( - format!("{nullifier_hash:?} Is a member").as_str(), - )); - } else { - non_membership_proofs.push(( - self.tree - .get_merkle_proof(self.curr_root.as_ref(), nullifier_hash)?, - self.curr_root, - )) - }; - } - - Ok(non_membership_proofs) - } -} - -impl Default for NullifierSparseMerkleTree { - fn default() -> Self { - Self::new() - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::nullifier::UTXONullifier; - - fn create_nullifier(hash: TreeHashType) -> UTXONullifier { - UTXONullifier { utxo_hash: hash } - } - - #[test] - fn test_new_tree_initialization() { - let tree = NullifierSparseMerkleTree::new(); - assert!(tree.curr_root.is_none()); - } - - #[test] - fn test_insert_single_item() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32]); // Sample 32-byte hash - - let result = tree.insert_item(nullifier); - assert!(result.is_ok()); - assert!(tree.curr_root.is_some()); - } - - #[test] - fn test_insert_multiple_items() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifiers = vec![ - create_nullifier([1u8; 32]), - create_nullifier([2u8; 32]), - create_nullifier([3u8; 32]), - ]; - - let result = tree.insert_items(nullifiers); - assert!(result.is_ok()); - assert!(tree.curr_root.is_some()); - } - - #[test] - fn test_search_item_inclusion() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32]); - - tree.insert_item(nullifier.clone()).unwrap(); - - let result = tree.search_item_inclusion([1u8; 32]); - assert!(result.is_ok()); - assert_eq!(result.unwrap(), true); - - let non_existing = tree.search_item_inclusion([99u8; 32]); - assert!(non_existing.is_ok()); - assert_eq!(non_existing.unwrap(), false); - } - - #[test] - fn test_search_multiple_item_inclusions() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifiers = vec![ - create_nullifier([1u8; 32]), - create_nullifier([2u8; 32]), - create_nullifier([3u8; 32]), - ]; - - tree.insert_items(nullifiers).unwrap(); - - let search_hashes = vec![[1u8; 32], [2u8; 32], [99u8; 32]]; - let result = tree.search_item_inclusions(&search_hashes); - assert!(result.is_ok()); - - let expected_results = vec![true, true, false]; - assert_eq!(result.unwrap(), expected_results); - } - - #[test] - fn test_non_membership_proof() { - let mut tree = NullifierSparseMerkleTree::new(); - let non_member_hash = [5u8; 32]; - - let result = tree.get_non_membership_proof(non_member_hash); - assert!(result.is_ok()); - - let (proof, root) = result.unwrap(); - assert!(root.is_none()); - } - - #[test] - fn test_non_membership_proofs_multiple() { - let mut tree = NullifierSparseMerkleTree::new(); - let non_member_hashes = vec![[5u8; 32], [6u8; 32], [7u8; 32]]; - - let result = tree.get_non_membership_proofs(&non_member_hashes); - assert!(result.is_ok()); - - let proofs = result.unwrap(); - for (proof, root) in proofs { - assert!(root.is_none()); - } - } - - #[test] - fn test_insert_and_get_proof_of_existing_item() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifier = create_nullifier([1u8; 32]); - - tree.insert_item(nullifier.clone()).unwrap(); - - let proof_result = tree.get_non_membership_proof([1u8; 32]); - assert!(proof_result.is_err()); - } - - #[test] - fn test_insert_and_get_proofs_of_existing_items() { - let mut tree = NullifierSparseMerkleTree::new(); - let nullifiers = vec![create_nullifier([1u8; 32]), create_nullifier([2u8; 32])]; - - tree.insert_items(nullifiers).unwrap(); - - let proof_result = tree.get_non_membership_proofs(&[[1u8; 32], [2u8; 32]]); - assert!(proof_result.is_err()); - } -} diff --git a/common/src/rpc_primitives/requests.rs b/common/src/rpc_primitives/requests.rs index 92e0abe..6cad01d 100644 --- a/common/src/rpc_primitives/requests.rs +++ b/common/src/rpc_primitives/requests.rs @@ -21,8 +21,8 @@ pub struct RegisterAccountRequest { #[derive(Serialize, Deserialize, Debug)] pub struct SendTxRequest { pub transaction: Transaction, - ///Nullifier Root, UTXO Commitment Root, Pub Tx Root - pub tx_roots: [[u8; 32]; 3], + ///UTXO Commitment Root, Pub Tx Root + pub tx_roots: [[u8; 32]; 2], } #[derive(Serialize, Deserialize, Debug)] diff --git a/node_core/Cargo.toml b/node_core/Cargo.toml index d948e79..109a96a 100644 --- a/node_core/Cargo.toml +++ b/node_core/Cargo.toml @@ -12,14 +12,13 @@ serde.workspace = true rand.workspace = true k256.workspace = true sha2.workspace = true -monotree.workspace = true bincode.workspace = true elliptic-curve.workspace = true reqwest.workspace = true thiserror.workspace = true tokio.workspace = true tempfile.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } hex.workspace = true actix-rt.workspace = true diff --git a/node_core/src/chain_storage/block_store.rs b/node_core/src/chain_storage/block_store.rs index 2956381..677f426 100644 --- a/node_core/src/chain_storage/block_store.rs +++ b/node_core/src/chain_storage/block_store.rs @@ -1,10 +1,19 @@ +use std::collections::{HashMap, HashSet}; use std::path::Path; +use accounts::account_core::Account; use anyhow::{anyhow, Result}; use common::block::Block; +use common::merkle_tree_public::merkle_tree::HashStorageMerkleTree; +use common::nullifier::UTXONullifier; +use common::transaction::Transaction; +use common::utxo_commitment::UTXOCommitment; +use log::error; use storage::sc_db_utils::{DataBlob, DataBlobChangeVariant}; use storage::RocksDBIO; +use crate::chain_storage::AccMap; + pub struct NodeBlockStore { dbio: RocksDBIO, } @@ -21,9 +30,9 @@ impl NodeBlockStore { } ///Reopening existing database - pub fn open_db_restart(location: &Path) -> Result { + pub fn open_db_restart(location: &Path, genesis_block: Block) -> Result { NodeBlockStore::db_destroy(location)?; - NodeBlockStore::open_db_with_genesis(location, None) + NodeBlockStore::open_db_with_genesis(location, Some(genesis_block)) } ///Reloading existing database @@ -56,6 +65,65 @@ impl NodeBlockStore { pub fn get_sc_sc_state(&self, sc_addr: &str) -> Result> { Ok(self.dbio.get_sc_sc_state(sc_addr)?) } + + pub fn get_snapshot_block_id(&self) -> Result { + Ok(self.dbio.get_snapshot_block_id()?) + } + + pub fn get_snapshot_account(&self) -> Result> { + let temp: AccMap = serde_json::from_slice(&self.dbio.get_snapshot_account()?)?; + Ok(temp.into()) + } + + pub fn get_snapshot_commitment(&self) -> Result> { + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_commitment()?, + )?) + } + + pub fn get_snapshot_nullifier(&self) -> Result> { + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_nullifier()?, + )?) + } + + pub fn get_snapshot_transaction(&self) -> Result> { + Ok(serde_json::from_slice( + &self.dbio.get_snapshot_transaction()?, + )?) + } + + pub fn put_snapshot_at_block_id( + &self, + id: u64, + accounts_ser: Vec, + comm_ser: Vec, + txs_ser: Vec, + nullifiers_ser: Vec, + ) -> Result<()> { + //Error notification for writing into DB error + self.dbio + .put_snapshot_block_id_db(id) + .inspect_err(|err| error!("Failed to store snapshot block id with error {err:#?}"))?; + self.dbio + .put_snapshot_account_db(accounts_ser) + .inspect_err(|err| error!("Failed to store snapshot accounts with error {err:#?}"))?; + self.dbio + .put_snapshot_commitement_db(comm_ser) + .inspect_err(|err| { + error!("Failed to store snapshot commitments with error {err:#?}") + })?; + self.dbio + .put_snapshot_transaction_db(txs_ser) + .inspect_err(|err| { + error!("Failed to store snapshot transactions with error {err:#?}") + })?; + self.dbio + .put_snapshot_nullifier_db(nullifiers_ser) + .inspect_err(|err| error!("Failed to store snapshot nullifiers with error {err:#?}"))?; + + Ok(()) + } } #[cfg(test)] @@ -107,13 +175,26 @@ mod tests { let path = temp_dir.path(); let genesis_block = create_genesis_block(); - let _ = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block)).unwrap(); + { + let node_store_old = + NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())).unwrap(); + + let block = create_sample_block(1, 0); + node_store_old.put_block_at_id(block.clone()).unwrap(); + } + + // Check that the first block is still in the old database + { + let node_store_old = NodeBlockStore::open_db_reload(path).unwrap(); + let result = node_store_old.get_block_at_id(1); + assert!(result.is_ok()); + } // Restart the database - let node_store = NodeBlockStore::open_db_restart(path).unwrap(); + let node_store = NodeBlockStore::open_db_restart(path, genesis_block).unwrap(); - // The block should no longer be available since no genesis block is set on restart - let result = node_store.get_block_at_id(0); + // The block should no longer be available since no first block is set on restart + let result = node_store.get_block_at_id(1); assert!(result.is_err()); } @@ -150,13 +231,39 @@ mod tests { } #[test] - fn test_get_block_not_found() { + fn test_put_snapshot_at_block_id() { let temp_dir = tempdir().unwrap(); let path = temp_dir.path(); - let node_store = NodeBlockStore::open_db_with_genesis(path, None).unwrap(); + let genesis_block = create_genesis_block(); + let node_store = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block)).unwrap(); - let result = node_store.get_block_at_id(42); - assert!(result.is_err()); + let id = 3; + let accounts_ser = vec![1, 2, 3, 4]; + let comm_ser = vec![5, 6, 7, 8]; + let txs_ser = vec![9, 10, 11, 12]; + let nullifiers_ser = vec![13, 14, 15, 16]; + + node_store + .put_snapshot_at_block_id( + id, + accounts_ser.clone(), + comm_ser.clone(), + txs_ser.clone(), + nullifiers_ser.clone(), + ) + .unwrap(); + + assert_eq!(node_store.dbio.get_snapshot_block_id().unwrap(), id); + assert_eq!( + node_store.dbio.get_snapshot_account().unwrap(), + accounts_ser + ); + assert_eq!(node_store.dbio.get_snapshot_commitment().unwrap(), comm_ser); + assert_eq!(node_store.dbio.get_snapshot_transaction().unwrap(), txs_ser); + assert_eq!( + node_store.dbio.get_snapshot_nullifier().unwrap(), + nullifiers_ser + ); } } diff --git a/node_core/src/chain_storage/mod.rs b/node_core/src/chain_storage/mod.rs index f8bcf4e..f6b1343 100644 --- a/node_core/src/chain_storage/mod.rs +++ b/node_core/src/chain_storage/mod.rs @@ -1,7 +1,4 @@ -use std::{ - collections::{BTreeMap, HashMap}, - path::Path, -}; +use std::collections::{BTreeMap, HashMap, HashSet}; use accounts::account_core::{Account, AccountAddress}; use anyhow::Result; @@ -10,50 +7,125 @@ use common::{ block::Block, merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, nullifier::UTXONullifier, - nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, utxo_commitment::UTXOCommitment, }; use k256::AffinePoint; +use log::{info, warn}; use public_context::PublicSCContext; +use serde::{Deserialize, Serialize}; use utxo::utxo_core::UTXO; -use crate::ActionData; +use crate::{config::NodeConfig, ActionData}; pub mod accounts_store; pub mod block_store; pub mod public_context; +#[derive(Deserialize, Serialize)] +pub struct AccMap { + pub acc_map: HashMap, +} + +impl From> for AccMap { + fn from(value: HashMap<[u8; 32], Account>) -> Self { + AccMap { + acc_map: value + .into_iter() + .map(|(key, val)| (hex::encode(key), val)) + .collect(), + } + } +} + +impl From for HashMap<[u8; 32], Account> { + fn from(value: AccMap) -> Self { + value + .acc_map + .into_iter() + .map(|(key, val)| (hex::decode(key).unwrap().try_into().unwrap(), val)) + .collect() + } +} + pub struct NodeChainStore { pub acc_map: HashMap, pub block_store: NodeBlockStore, - pub nullifier_store: NullifierSparseMerkleTree, + pub nullifier_store: HashSet, pub utxo_commitments_store: UTXOCommitmentsMerkleTree, pub pub_tx_store: PublicTransactionMerkleTree, + pub node_config: NodeConfig, } impl NodeChainStore { - pub fn new_with_genesis(home_dir: &Path, genesis_block: Block) -> Self { - let acc_map = HashMap::new(); - let nullifier_store = NullifierSparseMerkleTree::default(); - let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); - let pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + pub fn new(config: NodeConfig, genesis_block: Block) -> Result<(Self, u64)> { + let mut acc_map = HashMap::new(); + let mut nullifier_store = HashSet::new(); + let mut utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); + let mut pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + let mut block_id = genesis_block.block_id; //Sequencer should panic if unable to open db, //as fixing this issue may require actions non-native to program scope let block_store = - NodeBlockStore::open_db_with_genesis(&home_dir.join("rocksdb"), Some(genesis_block)) + NodeBlockStore::open_db_with_genesis(&config.home.join("rocksdb"), Some(genesis_block)) .unwrap(); - Self { - acc_map, - block_store, - nullifier_store, - utxo_commitments_store, - pub_tx_store, + if let Ok(temp_block_id) = block_store.get_snapshot_block_id() { + utxo_commitments_store = block_store.get_snapshot_commitment()?; + nullifier_store = block_store.get_snapshot_nullifier()?; + acc_map = block_store.get_snapshot_account()?; + pub_tx_store = block_store.get_snapshot_transaction()?; + block_id = temp_block_id; } + + Ok(( + Self { + acc_map: From::from(acc_map), + block_store, + nullifier_store, + utxo_commitments_store, + pub_tx_store, + node_config: config, + }, + block_id, + )) + } + + pub fn new_after_restart(config: NodeConfig, genesis_block: Block) -> Result<(Self, u64)> { + let mut acc_map = HashMap::new(); + let mut nullifier_store = HashSet::new(); + let mut utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); + let mut pub_tx_store = PublicTransactionMerkleTree::new(vec![]); + let mut block_id = genesis_block.block_id; + + //Sequencer should panic if unable to open db, + //as fixing this issue may require actions non-native to program scope + let block_store = NodeBlockStore::open_db_reload(&config.home.join("rocksdb")).unwrap(); + + if let Ok(temp_block_id) = block_store.get_snapshot_block_id() { + utxo_commitments_store = block_store.get_snapshot_commitment()?; + nullifier_store = block_store.get_snapshot_nullifier()?; + acc_map = block_store.get_snapshot_account()?; + pub_tx_store = block_store.get_snapshot_transaction()?; + block_id = temp_block_id; + } + + Ok(( + Self { + acc_map, + block_store, + nullifier_store, + utxo_commitments_store, + pub_tx_store, + node_config: config, + }, + block_id, + )) } pub fn dissect_insert_block(&mut self, block: Block) -> Result<()> { + let block_id = block.block_id; + for tx in &block.transactions { if !tx.execution_input.is_empty() { let public_action = serde_json::from_slice::(&tx.execution_input); @@ -97,13 +169,11 @@ impl NodeChainStore { .collect(), ); - self.nullifier_store.insert_items( - tx.nullifier_created_hashes - .clone() - .into_iter() - .map(|hash| UTXONullifier { utxo_hash: hash }) - .collect(), - )?; + for nullifier in tx.nullifier_created_hashes.iter() { + self.nullifier_store.insert(UTXONullifier { + utxo_hash: *nullifier, + }); + } if !tx.encoded_data.is_empty() { let ephemeral_public_key_sender = @@ -114,7 +184,7 @@ impl NodeChainStore { let nonce = accounts::key_management::constants_types::Nonce::clone_from_slice(slice); for (acc_id, acc) in self.acc_map.iter_mut() { - if acc_id[0] == tag { + if hex::decode(acc_id).unwrap()[0] == tag { let decoded_data_curr_acc = acc.decrypt_data( ephemeral_public_key_sender, ciphertext.clone(), @@ -125,7 +195,7 @@ impl NodeChainStore { serde_json::from_slice::(&decoded_data_curr_acc); if let Ok(utxo) = decoded_utxo_try { if &utxo.owner == acc_id { - acc.utxo_tree.insert_item(utxo)?; + acc.utxos.insert(utxo.hash, utxo); } } } @@ -139,6 +209,48 @@ impl NodeChainStore { self.block_store.put_block_at_id(block)?; + //Snapshot + if block_id % self.node_config.shapshot_frequency_in_blocks == 0 { + //Serializing all important data structures + + //If we fail serialization, it is not the reason to stop running + //Logging on warn level in this cases + let acc_map: AccMap = self.acc_map.clone().into(); + + if let Ok(accounts_ser) = serde_json::to_vec(&acc_map).inspect_err(|err| { + warn!("Failed to serialize accounts data {err:#?}"); + }) { + if let Ok(comm_ser) = + serde_json::to_vec(&self.utxo_commitments_store).inspect_err(|err| { + warn!("Failed to serialize commitments {err:#?}"); + }) + { + if let Ok(txs_ser) = serde_json::to_vec(&self.pub_tx_store).inspect_err(|err| { + warn!("Failed to serialize transactions {err:#?}"); + }) { + if let Ok(nullifiers_ser) = serde_json::to_vec(&self.nullifier_store) + .inspect_err(|err| { + warn!("Failed to serialize nullifiers {err:#?}"); + }) + { + let snapshot_trace = self.block_store.put_snapshot_at_block_id( + block_id, + accounts_ser, + comm_ser, + txs_ser, + nullifiers_ser, + ); + + info!( + "Snapshot executed at {:?} with results {snapshot_trace:#?}", + block_id + ); + } + } + } + } + } + Ok(()) } @@ -153,9 +265,178 @@ impl NodeChainStore { caller_address: caller, caller_balance: self.acc_map.get(&caller).unwrap().balance, account_masks, - nullifier_store_root: self.nullifier_store.curr_root.unwrap_or([0; 32]), comitment_store_root: self.utxo_commitments_store.get_root().unwrap_or([0; 32]), pub_tx_store_root: self.pub_tx_store.get_root().unwrap_or([0; 32]), } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::config::GasConfig; + use accounts::account_core::Account; + use common::block::{Block, Data}; + use common::merkle_tree_public::TreeHashType; + use common::transaction::{Transaction, TxKind}; + use secp256k1_zkp::Tweak; + use std::path::PathBuf; + use tempfile::tempdir; + + fn create_genesis_block() -> Block { + Block { + block_id: 0, + prev_block_id: 0, + prev_block_hash: [0; 32], + hash: [1; 32], + transactions: vec![], + data: Data::default(), + } + } + + fn create_dummy_transaction( + hash: TreeHashType, + // execution_input: Vec, + nullifier_created_hashes: Vec<[u8; 32]>, + utxo_commitments_spent_hashes: Vec<[u8; 32]>, + utxo_commitments_created_hashes: Vec<[u8; 32]>, + ) -> Transaction { + let mut rng = rand::thread_rng(); + + Transaction { + hash, + tx_kind: TxKind::Private, + execution_input: vec![], + execution_output: vec![], + utxo_commitments_spent_hashes, + utxo_commitments_created_hashes, + nullifier_created_hashes, + execution_proof_private: "dummy_proof".to_string(), + encoded_data: vec![], + ephemeral_pub_key: vec![10, 11, 12], + commitment: vec![], + tweak: Tweak::new(&mut rng), + secret_r: [0; 32], + sc_addr: "sc_addr".to_string(), + state_changes: (serde_json::Value::Null, 0), + } + } + + fn create_sample_block(block_id: u64, prev_block_id: u64) -> Block { + Block { + block_id: block_id, + prev_block_id: prev_block_id, + prev_block_hash: [0; 32], + hash: [1; 32], + transactions: vec![], + data: Data::default(), + } + } + + fn create_sample_node_config(home: PathBuf) -> NodeConfig { + NodeConfig { + home, + override_rust_log: None, + sequencer_addr: "http://127.0.0.1".to_string(), + seq_poll_timeout_secs: 1, + port: 8000, + gas_config: create_sample_gas_config(), + shapshot_frequency_in_blocks: 1, + } + } + + fn create_sample_gas_config() -> GasConfig { + GasConfig { + gas_fee_per_byte_deploy: 0, + gas_fee_per_input_buffer_runtime: 0, + gas_fee_per_byte_runtime: 0, + gas_cost_runtime: 0, + gas_cost_deploy: 0, + gas_limit_deploy: 0, + gas_limit_runtime: 0, + } + } + + fn generate_dummy_utxo(address: TreeHashType, amount: u128) -> UTXO { + UTXO::new(address, vec![], amount, false) + } + + #[test] + fn test_new_initializes_correctly() { + let temp_dir = tempdir().unwrap(); + let path = temp_dir.path(); + + let config = create_sample_node_config(path.to_path_buf()); + + let genesis_block = create_genesis_block(); + + let (store, block_id) = NodeChainStore::new(config.clone(), genesis_block.clone()).unwrap(); + + assert_eq!(block_id, 0); + assert!(store.acc_map.is_empty()); + assert!(store.nullifier_store.is_empty()); + assert_eq!( + store.utxo_commitments_store.get_root().unwrap_or([0; 32]), + [0; 32] + ); + } + + #[test] + fn test_new_recovers_from_snapshot() { + let temp_dir = tempdir().unwrap(); + let path = temp_dir.path().to_path_buf(); + + let config = create_sample_node_config(path); + + let nullifier_secret_const = + "261d61d294ac4bdc24f91b6f490efa263757a4a95f65871cd4f16b2ea23c3b5d"; + std::env::set_var("NULLIFIER_SECRET_CONST", nullifier_secret_const); + + let viewing_secret_const = + "6117af750b30d7a296672ec3b3b25d3489beca3cfe5770fa39f275cec395d5ce"; + std::env::set_var("VIEWING_SECRET_CONST", viewing_secret_const); + + let genesis_block = create_genesis_block(); + + // Initialize once to create DB and store fake snapshot + { + let (mut store, _) = + NodeChainStore::new(config.clone(), genesis_block.clone()).unwrap(); + + // Insert state + let mut account = Account::new(); + account + .add_new_utxo_outputs(vec![generate_dummy_utxo(account.address, 100)]) + .unwrap(); + store.acc_map.insert(account.address, account); + store.nullifier_store.insert(UTXONullifier { + utxo_hash: [2u8; 32], + }); + store + .utxo_commitments_store + .add_tx_multiple(vec![UTXOCommitment { hash: [3u8; 32] }]); + store.pub_tx_store.add_tx(create_dummy_transaction( + [12; 32], + vec![[9; 32]], + vec![[7; 32]], + vec![[8; 32]], + )); + + // Put block snapshot to trigger snapshot recovery on next load + let dummy_block = create_sample_block(1, 0); + + store.dissect_insert_block(dummy_block).unwrap(); + } + + // Now reload and verify snapshot is used + let (recovered_store, block_id) = + NodeChainStore::new_after_restart(config.clone(), genesis_block).unwrap(); + + assert_eq!(block_id, 1); + assert_eq!(recovered_store.acc_map.len(), 1); + assert_eq!( + recovered_store.utxo_commitments_store.get_root().is_some(), + true + ); + } +} diff --git a/node_core/src/chain_storage/public_context.rs b/node_core/src/chain_storage/public_context.rs index 5d5ceb6..438fa50 100644 --- a/node_core/src/chain_storage/public_context.rs +++ b/node_core/src/chain_storage/public_context.rs @@ -9,7 +9,6 @@ pub const CALLER_ADDRESS: &str = "caller_address"; pub const CALLER_BALANCE: &str = "caller_balance"; pub const ACCOUNT_MASKS_KEYS_SORTED: &str = "account_masks_keys_sorted"; pub const ACCOUNT_MASKS_VALUES_SORTED: &str = "account_masks_values_sorted"; -pub const NULLIFIER_STORE_ROOT: &str = "nullifier_store_root"; pub const COMMITMENT_STORE_ROOT: &str = "commitment_store_root"; pub const PUT_TX_STORE_ROOT: &str = "put_tx_store_root"; @@ -18,7 +17,6 @@ pub struct PublicSCContext { pub caller_address: AccountAddress, pub caller_balance: u64, pub account_masks: BTreeMap, - pub nullifier_store_root: TreeHashType, pub comitment_store_root: TreeHashType, pub pub_tx_store_root: TreeHashType, } @@ -41,7 +39,6 @@ impl Serialize for PublicSCContext { s.serialize_field(CALLER_BALANCE, &self.caller_balance)?; s.serialize_field(ACCOUNT_MASKS_KEYS_SORTED, &account_masks_keys)?; s.serialize_field(ACCOUNT_MASKS_VALUES_SORTED, &account_mask_values)?; - s.serialize_field(NULLIFIER_STORE_ROOT, &self.nullifier_store_root)?; s.serialize_field(COMMITMENT_STORE_ROOT, &self.comitment_store_root)?; s.serialize_field(PUT_TX_STORE_ROOT, &self.pub_tx_store_root)?; @@ -100,7 +97,6 @@ mod tests { fn create_test_context() -> PublicSCContext { let caller_address = [1; 32]; - let nullifier_store_root = [2; 32]; let comitment_store_root = [3; 32]; let pub_tx_store_root = [4; 32]; @@ -118,7 +114,6 @@ mod tests { caller_address, caller_balance: 100, account_masks, - nullifier_store_root, comitment_store_root, pub_tx_store_root, } diff --git a/node_core/src/config.rs b/node_core/src/config.rs index d92e358..935a803 100644 --- a/node_core/src/config.rs +++ b/node_core/src/config.rs @@ -49,4 +49,6 @@ pub struct NodeConfig { pub port: u16, ///Gas config pub gas_config: GasConfig, + ///Frequency of snapshots + pub shapshot_frequency_in_blocks: u64, } diff --git a/node_core/src/executions/de.rs b/node_core/src/executions/de.rs deleted file mode 100644 index f73ba85..0000000 --- a/node_core/src/executions/de.rs +++ /dev/null @@ -1,232 +0,0 @@ -use bincode; -use common::{ - commitment::Commitment, commitments_sparse_merkle_tree::CommitmentsSparseMerkleTree, - nullifier::UTXONullifier, nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, -}; -use k256::Scalar; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree}; -use rand::thread_rng; -use secp256k1_zkp::{CommitmentSecrets, Generator, PedersenCommitment, Tag, Tweak, SECP256K1}; -use sha2::{Digest, Sha256}; -use utxo::utxo_core::UTXO; - -#[allow(unused)] -fn commitment_secrets_random(value: u64) -> CommitmentSecrets { - CommitmentSecrets { - value, - value_blinding_factor: Tweak::new(&mut thread_rng()), - generator_blinding_factor: Tweak::new(&mut thread_rng()), - } -} - -pub fn tag_random() -> Tag { - use rand::thread_rng; - use rand::RngCore; - - let mut bytes = [0u8; 32]; - thread_rng().fill_bytes(&mut bytes); - - Tag::from(bytes) -} - -pub fn commit(comm: &CommitmentSecrets, tag: Tag) -> PedersenCommitment { - let generator = Generator::new_blinded(SECP256K1, tag, comm.generator_blinding_factor); - - PedersenCommitment::new(SECP256K1, comm.value, comm.value_blinding_factor, generator) -} - -fn hash(input: &[u8]) -> Vec { - Sha256::digest(input).to_vec() -} - -// Generate nullifiers - -// takes the input_utxo and nsk -// returns the nullifiers[i], where the nullifier[i] = hash(in_commitments[i] || nsk) where the hash function -pub fn generate_nullifiers(input_utxo: &UTXO, nsk: &[u8]) -> Vec { - let mut input = bincode::serialize(input_utxo).unwrap().to_vec(); - input.extend_from_slice(nsk); - hash(&input) -} - -// Generate commitments for output UTXOs - -// uses the list of input_utxos[] -// returns in_commitments[] where each in_commitments[i] = Commitment(in_utxos[i]) where the commitment -pub fn generate_commitments(input_utxos: &[UTXO]) -> Vec> { - input_utxos - .iter() - .map(|utxo| { - let serialized = bincode::serialize(utxo).unwrap(); // Serialize UTXO. - hash(&serialized) - }) - .collect() -} - -// Validate inclusion proof for in_commitments - -// takes the in_commitments[i] as a leaf, the root hash root_commitment and the path in_commitments_proofs[i][], -// returns True if the in_commitments[i] is in the tree with root hash root_commitment otherwise returns False, as membership proof. -pub fn validate_in_commitments_proof( - in_commitment: &Vec, - root_commitment: Vec, - in_commitments_proof: &[Vec], -) -> bool { - // Placeholder implementation. - // Replace with Merkle proof verification logic. - // hash(&[pedersen_commitment.serialize().to_vec(), in_commitments_proof.concat()].concat()) == root_commitment - - let mut nsmt = CommitmentsSparseMerkleTree { - curr_root: Option::Some(root_commitment), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let commitments: Vec<_> = in_commitments_proof - .into_iter() - .map(|n_p| Commitment { - commitment_hash: n_p.clone(), - }) - .collect(); - nsmt.insert_items(commitments).unwrap(); - - nsmt.get_non_membership_proof(in_commitment.clone()) - .unwrap() - .1 - .is_some() -} - -// Validate non-membership proof for nullifiers - -// takes the nullifiers[i], path nullifiers_proof[i][] and the root hash root_nullifier, -// returns True if the nullifiers[i] is not in the tree with root hash root_nullifier otherwise returns False, as non-membership proof. -pub fn validate_nullifiers_proof( - nullifier: [u8; 32], - root_nullifier: [u8; 32], - nullifiers_proof: &[[u8; 32]], -) -> bool { - let mut nsmt = NullifierSparseMerkleTree { - curr_root: Option::Some(root_nullifier), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let nullifiers: Vec<_> = nullifiers_proof - .into_iter() - .map(|n_p| UTXONullifier { utxo_hash: *n_p }) - .collect(); - nsmt.insert_items(nullifiers).unwrap(); - - nsmt.get_non_membership_proof(nullifier) - .unwrap() - .1 - .is_none() -} - -// Check balances - -// takes the public_info and output_utxos[], -// returns the True if the token amount in public_info matches the sum of all output_utxos[], otherwise return False. -pub fn check_balances(public_info: u128, output_utxos: &[UTXO]) -> bool { - let total_output: u128 = output_utxos.iter().map(|utxo| utxo.amount).sum(); - public_info == total_output -} - -// Verify Pedersen commitment - -// takes the public_info, secret_r and pedersen_commitment and -// checks that commitment(public_info,secret_r) is equal pedersen_commitment where the commitment is pedersen commitment. -pub fn verify_commitment( - public_info: u64, - secret_r: &[u8], - pedersen_commitment: &PedersenCommitment, -) -> bool { - let commitment_secrets = CommitmentSecrets { - value: public_info, - value_blinding_factor: Tweak::from_slice(secret_r).unwrap(), - generator_blinding_factor: Tweak::new(&mut thread_rng()), - }; - - let tag = tag_random(); - let commitment = commit(&commitment_secrets, tag); - - commitment == *pedersen_commitment -} - -// new_commitment -pub fn new_commitment(public_info: u64, secret_r: &[u8]) -> (Tweak, &[u8], PedersenCommitment) { - let generator_blinding_factor = Tweak::new(&mut thread_rng()); - let commitment_secrets = CommitmentSecrets { - value: public_info, - value_blinding_factor: Tweak::from_slice(secret_r).unwrap(), - generator_blinding_factor, - }; - - let tag = tag_random(); - let commitment = commit(&commitment_secrets, tag); - - (generator_blinding_factor, secret_r, commitment) -} - -// new_commitment for a Vec of values -pub fn new_commitment_vec( - public_info_vec: Vec, - secret_r: &[u8], -) -> (Tweak, &[u8], Vec) { - let generator_blinding_factor = Tweak::new(&mut thread_rng()); - let tag = tag_random(); - - let vec_commitments = public_info_vec - .into_iter() - .map(|public_info| { - let commitment_secrets = CommitmentSecrets { - value: public_info, - value_blinding_factor: Tweak::from_slice(secret_r).unwrap(), - generator_blinding_factor, - }; - - commit(&commitment_secrets, tag) - }) - .collect(); - - (generator_blinding_factor, secret_r, vec_commitments) -} - -#[allow(unused)] -fn de_kernel( - root_commitment: &[u8], - root_nullifier: [u8; 32], - public_info: u64, - input_utxos: &[UTXO], - in_commitments_proof: &[Vec], - nullifiers_proof: &[[u8; 32]], - nullifier_secret_key: Scalar, -) -> (Vec, Vec>) { - check_balances(public_info as u128, input_utxos); - - let nullifiers: Vec<_> = input_utxos - .into_iter() - .map(|utxo| generate_nullifiers(&utxo, &nullifier_secret_key.to_bytes())) - .collect(); - - let in_commitments = generate_commitments(&input_utxos); - - for in_commitment in in_commitments { - validate_in_commitments_proof( - &in_commitment, - root_commitment.to_vec(), - in_commitments_proof, - ); - } - - for nullifier in nullifiers.iter() { - validate_nullifiers_proof( - nullifier[0..32].try_into().unwrap(), - root_nullifier, - nullifiers_proof, - ); - } - - (vec![], nullifiers) -} diff --git a/node_core/src/executions/mod.rs b/node_core/src/executions/mod.rs deleted file mode 100644 index 7c9d33e..0000000 --- a/node_core/src/executions/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod de; -pub mod private_exec; -pub mod se; diff --git a/node_core/src/executions/private_exec.rs b/node_core/src/executions/private_exec.rs deleted file mode 100644 index 2e06c86..0000000 --- a/node_core/src/executions/private_exec.rs +++ /dev/null @@ -1,133 +0,0 @@ -use bincode; -use common::{ - commitment::Commitment, commitments_sparse_merkle_tree::CommitmentsSparseMerkleTree, - nullifier::UTXONullifier, nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, -}; -use k256::Scalar; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree}; -use sha2::{Digest, Sha256}; -use utxo::utxo_core::UTXO; - -fn hash(input: &[u8]) -> Vec { - Sha256::digest(input).to_vec() -} - -// Generate nullifiers - -// takes the input_utxo and nsk -// returns the nullifiers[i], where the nullifier[i] = hash(in_commitments[i] || nsk) where the hash function -pub fn generate_nullifiers(input_utxo: &UTXO, nsk: &[u8]) -> Vec { - let mut input = bincode::serialize(input_utxo).unwrap().to_vec(); - input.extend_from_slice(nsk); - hash(&input) -} - -// Generate commitments for output UTXOs - -// uses the list of input_utxos[] -// returns in_commitments[] where each in_commitments[i] = Commitment(in_utxos[i]) where the commitment -pub fn generate_commitments(input_utxos: &[UTXO]) -> Vec> { - input_utxos - .iter() - .map(|utxo| { - let serialized = bincode::serialize(utxo).unwrap(); // Serialize UTXO. - hash(&serialized) - }) - .collect() -} - -// Validate inclusion proof for in_commitments - -// takes the in_commitments[i] as a leaf, the root hash root_commitment and the path in_commitments_proofs[i][], -// returns True if the in_commitments[i] is in the tree with root hash root_commitment otherwise returns False, as membership proof. -pub fn validate_in_commitments_proof( - in_commitment: &Vec, - root_commitment: Vec, - in_commitments_proof: &[Vec], -) -> bool { - // Placeholder implementation. - // Replace with Merkle proof verification logic. - // hash(&[pedersen_commitment.serialize().to_vec(), in_commitments_proof.concat()].concat()) == root_commitment - - let mut nsmt = CommitmentsSparseMerkleTree { - curr_root: Option::Some(root_commitment), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let commitments: Vec<_> = in_commitments_proof - .into_iter() - .map(|n_p| Commitment { - commitment_hash: n_p.clone(), - }) - .collect(); - nsmt.insert_items(commitments).unwrap(); - - nsmt.get_non_membership_proof(in_commitment.clone()) - .unwrap() - .1 - .is_some() -} - -// Validate non-membership proof for nullifiers - -// takes the nullifiers[i], path nullifiers_proof[i][] and the root hash root_nullifier, -// returns True if the nullifiers[i] is not in the tree with root hash root_nullifier otherwise returns False, as non-membership proof. -pub fn validate_nullifiers_proof( - nullifier: [u8; 32], - root_nullifier: [u8; 32], - nullifiers_proof: &[[u8; 32]], -) -> bool { - let mut nsmt = NullifierSparseMerkleTree { - curr_root: Option::Some(root_nullifier), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let nullifiers: Vec<_> = nullifiers_proof - .into_iter() - .map(|n_p| UTXONullifier { utxo_hash: *n_p }) - .collect(); - nsmt.insert_items(nullifiers).unwrap(); - - nsmt.get_non_membership_proof(nullifier) - .unwrap() - .1 - .is_none() -} - -#[allow(unused)] -fn private_kernel( - root_commitment: &[u8], - root_nullifier: [u8; 32], - input_utxos: &[UTXO], - in_commitments_proof: &[Vec], - nullifiers_proof: &[[u8; 32]], - nullifier_secret_key: Scalar, -) -> (Vec, Vec>) { - let nullifiers: Vec<_> = input_utxos - .into_iter() - .map(|utxo| generate_nullifiers(&utxo, &nullifier_secret_key.to_bytes())) - .collect(); - - let in_commitments = generate_commitments(&input_utxos); - - for in_commitment in in_commitments { - validate_in_commitments_proof( - &in_commitment, - root_commitment.to_vec(), - in_commitments_proof, - ); - } - - for nullifier in nullifiers.iter() { - validate_nullifiers_proof( - nullifier[0..32].try_into().unwrap(), - root_nullifier, - nullifiers_proof, - ); - } - - (vec![], nullifiers) -} diff --git a/node_core/src/executions/se.rs b/node_core/src/executions/se.rs deleted file mode 100644 index d37fee5..0000000 --- a/node_core/src/executions/se.rs +++ /dev/null @@ -1,186 +0,0 @@ -use bincode; -use common::{ - commitment::Commitment, commitments_sparse_merkle_tree::CommitmentsSparseMerkleTree, - nullifier::UTXONullifier, nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, -}; -use k256::Scalar; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree}; -use rand::thread_rng; -use secp256k1_zkp::{CommitmentSecrets, Generator, PedersenCommitment, Tag, Tweak, SECP256K1}; -use sha2::{Digest, Sha256}; -use utxo::utxo_core::UTXO; - -#[allow(unused)] -fn commitment_secrets_random(value: u64) -> CommitmentSecrets { - CommitmentSecrets { - value, - value_blinding_factor: Tweak::new(&mut thread_rng()), - generator_blinding_factor: Tweak::new(&mut thread_rng()), - } -} - -pub fn tag_random() -> Tag { - use rand::thread_rng; - use rand::RngCore; - - let mut bytes = [0u8; 32]; - thread_rng().fill_bytes(&mut bytes); - - Tag::from(bytes) -} - -pub fn commit(comm: &CommitmentSecrets, tag: Tag) -> PedersenCommitment { - let generator = Generator::new_blinded(SECP256K1, tag, comm.generator_blinding_factor); - - PedersenCommitment::new(SECP256K1, comm.value, comm.value_blinding_factor, generator) -} - -fn hash(input: &[u8]) -> Vec { - Sha256::digest(input).to_vec() -} - -// Generate nullifiers - -// takes the pedersen_commitment and nsk then -// returns a list of nullifiers, where the nullifier = hash(pedersen_commitment || nsk) where the hash function will be determined - -pub fn generate_nullifiers(pedersen_commitment: &PedersenCommitment, nsk: &[u8]) -> Vec { - let mut input = pedersen_commitment.serialize().to_vec(); - input.extend_from_slice(nsk); - hash(&input) -} - -// Generate commitments for output UTXOs - -// uses the list of output_utxos[] and -// returns out_commitments[] where each out_commitments[i] = Commitment(output_utxos[i]) -// where the commitment will be determined -pub fn generate_commitments(output_utxos: &[UTXO]) -> Vec> { - output_utxos - .iter() - .map(|utxo| { - let serialized = bincode::serialize(utxo).unwrap(); // Serialize UTXO. - hash(&serialized) - }) - .collect() -} - -// Validate inclusion proof for in_commitments - -// takes the pedersen_commitment as a leaf, the root hash root_commitment and the path in_commitments_proof[], -// returns True if the pedersen_commitment is in the tree with root hash root_commitment -// otherwise -// returns False, as membership proof. -pub fn validate_in_commitments_proof( - pedersen_commitment: &PedersenCommitment, - root_commitment: Vec, - in_commitments_proof: &[Vec], -) -> bool { - let mut nsmt = CommitmentsSparseMerkleTree { - curr_root: Option::Some(root_commitment), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let commitments: Vec<_> = in_commitments_proof - .into_iter() - .map(|n_p| Commitment { - commitment_hash: n_p.clone(), - }) - .collect(); - nsmt.insert_items(commitments).unwrap(); - - nsmt.get_non_membership_proof(pedersen_commitment.serialize().to_vec()) - .unwrap() - .1 - .is_some() -} - -// Validate non-membership proof for nullifiers - -// takes the nullifier, path nullifiers_proof[] and the root hash root_nullifier, -// returns True if the nullifier is not in the tree with root hash root_nullifier -// otherwise -// returns False, as non-membership proof. -pub fn validate_nullifiers_proof( - nullifier: [u8; 32], - root_nullifier: [u8; 32], - nullifiers_proof: &[[u8; 32]], -) -> bool { - let mut nsmt = NullifierSparseMerkleTree { - curr_root: Option::Some(root_nullifier), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let nullifiers: Vec<_> = nullifiers_proof - .into_iter() - .map(|n_p| UTXONullifier { utxo_hash: *n_p }) - .collect(); - nsmt.insert_items(nullifiers).unwrap(); - - nsmt.get_non_membership_proof(nullifier) - .unwrap() - .1 - .is_none() -} - -// Check balances - -// takes the public_info and output_utxos[], -// returns the True if the token amount in public_info matches the sum of all output_utxos[], otherwise return False. -pub fn check_balances(public_info: u128, output_utxos: &[UTXO]) -> bool { - let total_output: u128 = output_utxos.iter().map(|utxo| utxo.amount).sum(); - public_info == total_output -} - -// Verify Pedersen commitment - -// takes the public_info, secret_r and pedersen_commitment and -// checks that commitment(public_info,secret_r) is equal pedersen_commitment where the commitment is pedersen commitment. -pub fn verify_commitment( - public_info: u64, - secret_r: &[u8], - pedersen_commitment: &PedersenCommitment, -) -> bool { - let commitment_secrets = CommitmentSecrets { - value: public_info, - value_blinding_factor: Tweak::from_slice(secret_r).unwrap(), - generator_blinding_factor: Tweak::new(&mut thread_rng()), - }; - - let tag = tag_random(); - let commitment = commit(&commitment_secrets, tag); - - commitment == *pedersen_commitment -} - -#[allow(unused)] -fn se_kernel( - root_commitment: &[u8], - root_nullifier: [u8; 32], - public_info: u64, - pedersen_commitment: PedersenCommitment, - secret_r: &[u8], - output_utxos: &[UTXO], - in_commitments_proof: &[Vec], - nullifiers_proof: &[[u8; 32]], - nullifier_secret_key: Scalar, -) -> (Vec, Vec>, Vec) { - check_balances(public_info as u128, output_utxos); - - let out_commitments = generate_commitments(output_utxos); - - let nullifier = generate_nullifiers(&pedersen_commitment, &nullifier_secret_key.to_bytes()); - - validate_in_commitments_proof( - &pedersen_commitment, - root_commitment.to_vec(), - in_commitments_proof, - ); - - verify_commitment(public_info, secret_r, &pedersen_commitment); - - (vec![], out_commitments, nullifier) -} diff --git a/node_core/src/lib.rs b/node_core/src/lib.rs index c0a97e5..49f1285 100644 --- a/node_core/src/lib.rs +++ b/node_core/src/lib.rs @@ -10,9 +10,10 @@ use anyhow::Result; use chain_storage::NodeChainStore; use common::transaction::{Transaction, TransactionPayload, TxKind}; use config::NodeConfig; -use executions::private_exec::{generate_commitments, generate_nullifiers}; use log::info; -use sc_core::proofs_circuits::pedersen_commitment_vec; +use sc_core::proofs_circuits::{ + generate_commitments, generate_nullifiers, generate_nullifiers_se, pedersen_commitment_vec, +}; use sequencer_client::{json::SendTxResponse, SequencerClient}; use serde::{Deserialize, Serialize}; use storage::sc_db_utils::DataBlobChangeVariant; @@ -28,7 +29,6 @@ pub const BLOCK_GEN_DELAY_SECS: u64 = 20; pub mod chain_storage; pub mod config; -pub mod executions; ///Module, which includes pre start setup helperfunctions pub mod pre_start; pub mod sequencer_client; @@ -94,16 +94,14 @@ impl NodeCore { let client = Arc::new(SequencerClient::new(config.clone())?); let genesis_id = client.get_genesis_id().await?; - info!("Gesesis id is {genesis_id:?}"); + info!("Genesis id is {genesis_id:?}"); let genesis_block = client.get_block(genesis_id.genesis_id).await?.block; - let mut storage = NodeChainStore::new_with_genesis(&config.home, genesis_block); + let (mut storage, mut chain_height) = NodeChainStore::new(config.clone(), genesis_block)?; pre_start::setup_empty_sc_states(&storage).await?; - let mut chain_height = genesis_id.genesis_id; - //Chain update loop loop { let next_block = chain_height + 1; @@ -164,10 +162,9 @@ impl NodeCore { }) } - pub async fn get_roots(&self) -> [[u8; 32]; 3] { + pub async fn get_roots(&self) -> [[u8; 32]; 2] { let storage = self.storage.read().await; [ - storage.nullifier_store.curr_root.unwrap_or([0; 32]), storage.utxo_commitments_store.get_root().unwrap_or([0; 32]), storage.pub_tx_store.get_root().unwrap_or([0; 32]), ] @@ -651,7 +648,7 @@ impl NodeCore { ) .unwrap(); - let nullifier = executions::se::generate_nullifiers( + let nullifier = generate_nullifiers_se( &commitment, &account .key_holder @@ -1062,7 +1059,7 @@ impl NodeCore { let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap(); - acc.utxo_tree.get_item(new_utxo_hash)?.unwrap().clone() + acc.utxos.get(&new_utxo_hash).unwrap().clone() }; new_utxo.log(); @@ -1101,12 +1098,7 @@ impl NodeCore { .map(|new_utxo_hash| { let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap(); - let new_utxo = acc - .utxo_tree - .get_item(new_utxo_hash) - .unwrap() - .unwrap() - .clone(); + let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone(); new_utxo.log(); info!( @@ -1238,7 +1230,7 @@ impl NodeCore { let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap(); acc.log(); - acc.utxo_tree.get_item(new_utxo_hash)?.unwrap().clone() + acc.utxos.get(&new_utxo_hash).unwrap().clone() }; new_utxo.log(); info!( @@ -1278,7 +1270,7 @@ impl NodeCore { let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap(); acc.log(); - acc.utxo_tree.get_item(new_utxo_hash)?.unwrap().clone() + acc.utxos.get(&new_utxo_hash).unwrap().clone() }; new_utxo.log(); info!( @@ -1323,7 +1315,7 @@ impl NodeCore { let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap(); acc.log(); - let new_utxo = acc.utxo_tree.get_item(new_utxo_hash)?.unwrap().clone(); + let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone(); new_utxo.log(); info!( @@ -1343,7 +1335,7 @@ impl NodeCore { let acc = write_guard.acc_map.get_mut(&acc_addr).unwrap(); acc.log(); - let new_utxo = acc.utxo_tree.get_item(new_utxo_hash)?.unwrap().clone(); + let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone(); new_utxo.log(); info!( @@ -1556,12 +1548,7 @@ impl NodeCore { .map(|(acc_addr_rec, new_utxo_hash)| { let acc = write_guard.acc_map.get_mut(&acc_addr_rec).unwrap(); - let new_utxo = acc - .utxo_tree - .get_item(new_utxo_hash) - .unwrap() - .unwrap() - .clone(); + let new_utxo = acc.utxos.get(&new_utxo_hash).unwrap().clone(); new_utxo.log(); info!( diff --git a/node_core/src/sequencer_client/json.rs b/node_core/src/sequencer_client/json.rs index 0c5373b..df94ca2 100644 --- a/node_core/src/sequencer_client/json.rs +++ b/node_core/src/sequencer_client/json.rs @@ -6,8 +6,8 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct SendTxRequest { pub transaction: Transaction, - ///Nullifier Root, UTXO Commitment Root, Pub Tx Root - pub tx_roots: [[u8; 32]; 3], + ///UTXO Commitment Root, Pub Tx Root + pub tx_roots: [[u8; 32]; 2], } //Responses diff --git a/node_core/src/sequencer_client/mod.rs b/node_core/src/sequencer_client/mod.rs index bc40a3a..7accd5f 100644 --- a/node_core/src/sequencer_client/mod.rs +++ b/node_core/src/sequencer_client/mod.rs @@ -73,7 +73,7 @@ impl SequencerClient { pub async fn send_tx( &self, transaction: Transaction, - tx_roots: [[u8; 32]; 3], + tx_roots: [[u8; 32]; 2], ) -> Result { let tx_req = SendTxRequest { transaction, diff --git a/node_rpc/src/process.rs b/node_rpc/src/process.rs index 38621ba..f4937e9 100644 --- a/node_rpc/src/process.rs +++ b/node_rpc/src/process.rs @@ -268,11 +268,8 @@ impl JsonHandler { .ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?; let utxo = acc - .utxo_tree - .get_item(utxo_hash) - .map_err(|err| { - RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}")) - })? + .utxos + .get(&utxo_hash) .ok_or(RpcError::new_internal_error( None, "UTXO does not exist in the tree", @@ -512,11 +509,8 @@ impl JsonHandler { .get_mut(&acc_addr_sender) .ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?; - acc.utxo_tree - .get_item(utxo_hash) - .map_err(|err| { - RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}")) - })? + acc.utxos + .get(&utxo_hash) .ok_or(RpcError::new_internal_error( None, "UTXO does not exist in tree", @@ -647,11 +641,8 @@ impl JsonHandler { .get_mut(&acc_addr_sender) .ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?; - acc.utxo_tree - .get_item(utxo_hash) - .map_err(|err| { - RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}")) - })? + acc.utxos + .get(&utxo_hash) .ok_or(RpcError::new_internal_error( None, "UTXO does not exist in tree", @@ -735,11 +726,8 @@ impl JsonHandler { .get_mut(&acc_addr_sender) .ok_or(RpcError::new_internal_error(None, ACCOUNT_NOT_FOUND))?; - acc.utxo_tree - .get_item(utxo_hash) - .map_err(|err| { - RpcError::new_internal_error(None, &format!("DB fetch failure {err:?}")) - })? + acc.utxos + .get(&utxo_hash) .ok_or(RpcError::new_internal_error( None, "UTXO does not exist in tree", diff --git a/node_rpc/src/types/err_rpc.rs b/node_rpc/src/types/err_rpc.rs index e1ace1f..0e75f7a 100644 --- a/node_rpc/src/types/err_rpc.rs +++ b/node_rpc/src/types/err_rpc.rs @@ -81,6 +81,5 @@ pub fn cast_common_execution_error_into_rpc_error(comm_exec_err: ExecutionFailur ExecutionFailureKind::SequencerClientError(seq_cli_err) => { cast_seq_client_error_into_rpc_error(seq_cli_err) } - ExecutionFailureKind::MonoTreeError(_) => RpcError::new_internal_error(None, &error_string), } } diff --git a/node_runner/configs/debug/node_config.json b/node_runner/configs/debug/node_config.json index f8c064e..c948b82 100644 --- a/node_runner/configs/debug/node_config.json +++ b/node_runner/configs/debug/node_config.json @@ -12,5 +12,6 @@ "gas_cost_deploy": 1000, "gas_limit_deploy": 30000000, "gas_limit_runtime": 30000000 - } + }, + "shapshot_frequency_in_blocks": 10 } \ No newline at end of file diff --git a/sc_core/Cargo.toml b/sc_core/Cargo.toml index 55ba888..ea580d6 100644 --- a/sc_core/Cargo.toml +++ b/sc_core/Cargo.toml @@ -12,7 +12,6 @@ serde.workspace = true rand.workspace = true k256.workspace = true sha2.workspace = true -monotree.workspace = true bincode.workspace = true elliptic-curve.workspace = true hex.workspace = true @@ -20,7 +19,7 @@ light-poseidon.workspace = true ark-bn254.workspace = true ark-ff.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } [dependencies.accounts] path = "../accounts" diff --git a/sc_core/src/lib.rs b/sc_core/src/lib.rs index 769813d..a41ab82 100644 --- a/sc_core/src/lib.rs +++ b/sc_core/src/lib.rs @@ -1,4 +1,3 @@ pub mod cryptography; pub mod proofs_circuits; pub mod transaction_payloads_tools; -pub mod utxo_manipulator; diff --git a/sc_core/src/proofs_circuits.rs b/sc_core/src/proofs_circuits.rs index 2072e55..cbebe3e 100644 --- a/sc_core/src/proofs_circuits.rs +++ b/sc_core/src/proofs_circuits.rs @@ -1,11 +1,5 @@ use bincode; -use common::{ - commitment::Commitment, commitments_sparse_merkle_tree::CommitmentsSparseMerkleTree, - nullifier::UTXONullifier, nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, -}; use k256::Scalar; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree}; use rand::{thread_rng, RngCore}; use secp256k1_zkp::{CommitmentSecrets, Generator, PedersenCommitment, Tag, Tweak, SECP256K1}; use sha2::{Digest, Sha256}; @@ -44,59 +38,21 @@ pub fn generate_commitments(input_utxos: &[UTXO]) -> Vec> { // takes the in_commitments[i] as a leaf, the root hash root_commitment and the path in_commitments_proofs[i][], // returns True if the in_commitments[i] is in the tree with root hash root_commitment otherwise returns False, as membership proof. pub fn validate_in_commitments_proof( - in_commitment: &Vec, - root_commitment: Vec, - in_commitments_proof: &[Vec], + _in_commitment: &Vec, + _root_commitment: Vec, + _in_commitments_proof: &[Vec], ) -> bool { - // Placeholder implementation. - // Replace with Merkle proof verification logic. - // hash(&[pedersen_commitment.serialize().to_vec(), in_commitments_proof.concat()].concat()) == root_commitment + // ToDo: Implement correct check - let mut nsmt = CommitmentsSparseMerkleTree { - curr_root: Option::Some(root_commitment), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let commitments: Vec<_> = in_commitments_proof - .into_iter() - .map(|n_p| Commitment { - commitment_hash: n_p.clone(), - }) - .collect(); - nsmt.insert_items(commitments).unwrap(); - - nsmt.get_non_membership_proof(in_commitment.clone()) - .unwrap() - .1 - .is_some() + todo!() } -// Validate non-membership proof for nullifiers - -// takes the nullifiers[i], path nullifiers_proof[i][] and the root hash root_nullifier, -// returns True if the nullifiers[i] is not in the tree with root hash root_nullifier otherwise returns False, as non-membership proof. -pub fn validate_nullifiers_proof( +// Validate that `nullifier` has not been present in set items before +pub fn validate_nullifier_not_present_in_set_items( nullifier: [u8; 32], - root_nullifier: [u8; 32], - nullifiers_proof: &[[u8; 32]], + nullifiers_items: &[[u8; 32]], ) -> bool { - let mut nsmt = NullifierSparseMerkleTree { - curr_root: Option::Some(root_nullifier), - tree: Monotree::default(), - hasher: Blake3::new(), - }; - - let nullifiers: Vec<_> = nullifiers_proof - .into_iter() - .map(|n_p| UTXONullifier { utxo_hash: *n_p }) - .collect(); - nsmt.insert_items(nullifiers).unwrap(); - - nsmt.get_non_membership_proof(nullifier) - .unwrap() - .1 - .is_none() + !nullifiers_items.contains(&nullifier) } #[allow(unused)] @@ -124,9 +80,8 @@ fn private_kernel( } for nullifier in nullifiers.iter() { - validate_nullifiers_proof( + validate_nullifier_not_present_in_set_items( nullifier[0..32].try_into().unwrap(), - root_nullifier, nullifiers_proof, ); } @@ -243,9 +198,8 @@ fn de_kernel( } for nullifier in nullifiers.iter() { - validate_nullifiers_proof( + validate_nullifier_not_present_in_set_items( nullifier[0..32].try_into().unwrap(), - root_nullifier, nullifiers_proof, ); } @@ -260,28 +214,13 @@ fn de_kernel( // otherwise // returns False, as membership proof. pub fn validate_in_commitments_proof_se( - pedersen_commitment: &PedersenCommitment, - root_commitment: Vec, - in_commitments_proof: &[Vec], + _pedersen_commitment: &PedersenCommitment, + _root_commitment: Vec, + _in_commitments_proof: &[Vec], ) -> bool { - let mut nsmt = CommitmentsSparseMerkleTree { - curr_root: Option::Some(root_commitment), - tree: Monotree::default(), - hasher: Blake3::new(), - }; + // ToDo: Implement correct check - let commitments: Vec<_> = in_commitments_proof - .into_iter() - .map(|n_p| Commitment { - commitment_hash: n_p.clone(), - }) - .collect(); - nsmt.insert_items(commitments).unwrap(); - - nsmt.get_non_membership_proof(pedersen_commitment.serialize().to_vec()) - .unwrap() - .1 - .is_some() + todo!() } // Generate nullifiers SE diff --git a/sc_core/src/utxo_manipulator.rs b/sc_core/src/utxo_manipulator.rs deleted file mode 100644 index 8bc0e32..0000000 --- a/sc_core/src/utxo_manipulator.rs +++ /dev/null @@ -1,110 +0,0 @@ -use anyhow::Result; -use common::nullifier::UTXONullifier; -use utxo::utxo_core::{UTXOPayload, UTXO}; - -pub fn utxo_change_owner( - utxo: &mut UTXO, - nullifier: UTXONullifier, - new_owner: [u8; 32], -) -> Result { - let new_payload = UTXOPayload { - owner: new_owner, - asset: utxo.asset.clone(), - amount: utxo.amount, - privacy_flag: utxo.privacy_flag, - }; - - utxo.consume_utxo(nullifier)?; - - Ok(UTXO::create_utxo_from_payload(new_payload)?) -} - -pub fn utxo_substact_part_another_owner( - utxo: &mut UTXO, - nullifier: UTXONullifier, - amount: u128, - new_owner: [u8; 32], -) -> Result<(UTXO, UTXO)> { - if amount > utxo.amount { - anyhow::bail!("Amount too big"); - } - - let diff = utxo.amount - amount; - - let new_payload1 = UTXOPayload { - owner: utxo.owner, - asset: utxo.asset.clone(), - amount: diff, - privacy_flag: utxo.privacy_flag, - }; - - let new_payload2 = UTXOPayload { - owner: new_owner, - asset: utxo.asset.clone(), - amount, - privacy_flag: utxo.privacy_flag, - }; - - utxo.consume_utxo(nullifier)?; - - Ok(( - UTXO::create_utxo_from_payload(new_payload1)?, - UTXO::create_utxo_from_payload(new_payload2)?, - )) -} - -pub fn utxo_substract_part( - utxo: &mut UTXO, - nullifier: UTXONullifier, - amount: u128, -) -> Result<(UTXO, UTXO)> { - let new_owner = utxo.owner; - - utxo_substact_part_another_owner(utxo, nullifier, amount, new_owner) -} - -pub fn utxo_split_n_users( - utxo: &mut UTXO, - nullifier: UTXONullifier, - users_amounts: Vec<([u8; 32], u128)>, -) -> Result> { - let cumulative_diff = users_amounts - .iter() - .fold(0, |acc, (_, amount)| acc + *amount); - - if cumulative_diff > utxo.amount { - anyhow::bail!("Amount too big"); - } - - let mut utxo_res = vec![]; - - for (new_owner, amount) in users_amounts { - let new_payload = UTXOPayload { - owner: new_owner, - asset: utxo.asset.clone(), - amount, - privacy_flag: utxo.privacy_flag, - }; - - let new_utxo = UTXO::create_utxo_from_payload(new_payload)?; - - utxo_res.push(new_utxo); - } - - if cumulative_diff != utxo.amount { - let new_payload = UTXOPayload { - owner: utxo.owner, - asset: utxo.asset.clone(), - amount: utxo.amount - cumulative_diff, - privacy_flag: utxo.privacy_flag, - }; - - let new_utxo = UTXO::create_utxo_from_payload(new_payload)?; - - utxo_res.push(new_utxo); - } - - utxo.consume_utxo(nullifier)?; - - Ok(utxo_res) -} diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index d073ffb..7a083f1 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -59,9 +59,8 @@ impl SequencerCore { } } - pub fn get_tree_roots(&self) -> [[u8; 32]; 3] { + pub fn get_tree_roots(&self) -> [[u8; 32]; 2] { [ - self.store.nullifier_store.curr_root.unwrap_or([0; 32]), self.store .utxo_commitments_store .get_root() @@ -73,7 +72,7 @@ impl SequencerCore { pub fn transaction_pre_check( &mut self, tx: &Transaction, - tx_roots: [[u8; 32]; 3], + tx_roots: [[u8; 32]; 2], ) -> Result<(), TransactionMalformationErrorKind> { let Transaction { hash, @@ -135,10 +134,9 @@ impl SequencerCore { let nullifier_tree_check = nullifier_created_hashes .iter() .map(|nullifier_hash| { - self.store - .nullifier_store - .search_item_inclusion(*nullifier_hash) - .unwrap_or(false) + self.store.nullifier_store.contains(&UTXONullifier { + utxo_hash: *nullifier_hash, + }) }) .any(|check| check); let utxo_commitments_check = utxo_commitments_created_hashes @@ -173,7 +171,7 @@ impl SequencerCore { pub fn push_tx_into_mempool_pre_check( &mut self, item: TransactionMempool, - tx_roots: [[u8; 32]; 3], + tx_roots: [[u8; 32]; 2], ) -> Result<(), TransactionMalformationErrorKind> { self.transaction_pre_check(&item.tx, tx_roots)?; @@ -187,7 +185,8 @@ impl SequencerCore { tx: TransactionMempool, ) -> Result<(), TransactionMalformationErrorKind> { let Transaction { - hash, + // ToDo: remove hashing of transactions on node side [Issue #66] + hash: _, ref utxo_commitments_created_hashes, ref nullifier_created_hashes, .. @@ -199,16 +198,10 @@ impl SequencerCore { .add_tx(UTXOCommitment { hash: *utxo_comm }); } - for nullifier in nullifier_created_hashes { - self.store - .nullifier_store - .insert_item(UTXONullifier { - utxo_hash: *nullifier, - }) - .map_err(|err| TransactionMalformationErrorKind::FailedToInsert { - tx: hash, - details: format!("{err:?}"), - })?; + for nullifier in nullifier_created_hashes.iter() { + self.store.nullifier_store.insert(UTXONullifier { + utxo_hash: *nullifier, + }); } self.store.pub_tx_store.add_tx(tx.tx); @@ -225,12 +218,14 @@ impl SequencerCore { ///Produces new block from transactions in mempool pub fn produce_new_block_with_mempool_transactions(&mut self) -> Result { + let new_block_height = self.chain_height + 1; + let transactions = self .mempool .pop_size(self.sequencer_config.max_num_tx_in_block); - for tx in transactions.clone() { - self.execute_check_transaction_on_state(tx)?; + for tx in &transactions { + self.execute_check_transaction_on_state(tx.clone())?; } let prev_block_hash = self @@ -240,7 +235,7 @@ impl SequencerCore { .hash; let hashable_data = HashableBlockData { - block_id: self.chain_height + 1, + block_id: new_block_height, prev_block_id: self.chain_height, transactions: transactions.into_iter().map(|tx_mem| tx_mem.tx).collect(), data: vec![], @@ -337,7 +332,7 @@ mod tests { common_setup(&mut sequencer); let roots = sequencer.get_tree_roots(); - assert_eq!(roots.len(), 3); // Should return three roots + assert_eq!(roots.len(), 2); // Should return two roots } #[test] diff --git a/sequencer_core/src/sequencer_store/mod.rs b/sequencer_core/src/sequencer_store/mod.rs index fd09d93..322c99d 100644 --- a/sequencer_core/src/sequencer_store/mod.rs +++ b/sequencer_core/src/sequencer_store/mod.rs @@ -1,11 +1,11 @@ -use std::path::Path; +use std::{collections::HashSet, path::Path}; use accounts_store::SequencerAccountsStore; use block_store::SequecerBlockStore; use common::{ block::{Block, HashableBlockData}, merkle_tree_public::merkle_tree::{PublicTransactionMerkleTree, UTXOCommitmentsMerkleTree}, - nullifier_sparse_merkle_tree::NullifierSparseMerkleTree, + nullifier::UTXONullifier, }; use rand::{rngs::OsRng, RngCore}; @@ -15,7 +15,7 @@ pub mod block_store; pub struct SequecerChainStore { pub acc_store: SequencerAccountsStore, pub block_store: SequecerBlockStore, - pub nullifier_store: NullifierSparseMerkleTree, + pub nullifier_store: HashSet, pub utxo_commitments_store: UTXOCommitmentsMerkleTree, pub pub_tx_store: PublicTransactionMerkleTree, } @@ -23,7 +23,7 @@ pub struct SequecerChainStore { impl SequecerChainStore { pub fn new_with_genesis(home_dir: &Path, genesis_id: u64, is_genesis_random: bool) -> Self { let acc_store = SequencerAccountsStore::default(); - let nullifier_store = NullifierSparseMerkleTree::default(); + let nullifier_store = HashSet::new(); let utxo_commitments_store = UTXOCommitmentsMerkleTree::new(vec![]); let pub_tx_store = PublicTransactionMerkleTree::new(vec![]); diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 753cac3..7616842 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -2,7 +2,6 @@ use std::{path::Path, sync::Arc}; use common::block::Block; use error::DbError; -use log::warn; use rocksdb::{ BoundColumnFamily, ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, }; @@ -35,12 +34,25 @@ pub const DB_META_FIRST_BLOCK_SET_KEY: &str = "first_block_set"; ///Key to list of all known smart contract addresses pub const DB_META_SC_LIST: &str = "sc_list"; +///Key base for storing snapshot which describe block id +pub const DB_SNAPSHOT_BLOCK_ID_KEY: &str = "block_id"; +///Key base for storing snapshot which describe commitment +pub const DB_SNAPSHOT_COMMITMENT_KEY: &str = "commitment"; +///Key base for storing snapshot which describe transaction +pub const DB_SNAPSHOT_TRANSACTION_KEY: &str = "transaction"; +///Key base for storing snapshot which describe nullifier +pub const DB_SNAPSHOT_NULLIFIER_KEY: &str = "nullifier"; +///Key base for storing snapshot which describe account +pub const DB_SNAPSHOT_ACCOUNT_KEY: &str = "account"; + ///Name of block column family pub const CF_BLOCK_NAME: &str = "cf_block"; ///Name of meta column family pub const CF_META_NAME: &str = "cf_meta"; ///Name of smart contract column family pub const CF_SC_NAME: &str = "cf_sc"; +///Name of snapshot column family +pub const CF_SNAPSHOT_NAME: &str = "cf_snapshot"; ///Suffix, used to mark field, which contain length of smart contract pub const SC_LEN_SUFFIX: &str = "sc_len"; @@ -59,6 +71,7 @@ impl RocksDBIO { let cfb = ColumnFamilyDescriptor::new(CF_BLOCK_NAME, cf_opts.clone()); let cfmeta = ColumnFamilyDescriptor::new(CF_META_NAME, cf_opts.clone()); let cfsc = ColumnFamilyDescriptor::new(CF_SC_NAME, cf_opts.clone()); + let cfsnapshot = ColumnFamilyDescriptor::new(CF_SNAPSHOT_NAME, cf_opts.clone()); let mut db_opts = Options::default(); db_opts.create_missing_column_families(true); @@ -66,7 +79,7 @@ impl RocksDBIO { let db = DBWithThreadMode::::open_cf_descriptors( &db_opts, path, - vec![cfb, cfmeta, cfsc], + vec![cfb, cfmeta, cfsc, cfsnapshot], ); let dbio = Self { @@ -89,9 +102,8 @@ impl RocksDBIO { Ok(dbio) } else { - warn!("Starting db in unset mode, will have to set starting block manually"); - - Ok(dbio) + // Here we are trying to start a DB without a block, one should not do it. + unreachable!() } } @@ -101,6 +113,7 @@ impl RocksDBIO { //ToDo: Add more column families for different data let _cfb = ColumnFamilyDescriptor::new(CF_BLOCK_NAME, cf_opts.clone()); let _cfmeta = ColumnFamilyDescriptor::new(CF_META_NAME, cf_opts.clone()); + let _cfsnapshot = ColumnFamilyDescriptor::new(CF_SNAPSHOT_NAME, cf_opts.clone()); let mut db_opts = Options::default(); db_opts.create_missing_column_families(true); @@ -109,18 +122,22 @@ impl RocksDBIO { .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None)) } - pub fn meta_column(&self) -> Arc { + pub fn meta_column(&self) -> Arc> { self.db.cf_handle(CF_META_NAME).unwrap() } - pub fn block_column(&self) -> Arc { + pub fn block_column(&self) -> Arc> { self.db.cf_handle(CF_BLOCK_NAME).unwrap() } - pub fn sc_column(&self) -> Arc { + pub fn sc_column(&self) -> Arc> { self.db.cf_handle(CF_SC_NAME).unwrap() } + pub fn snapshot_column(&self) -> Arc> { + self.db.cf_handle(CF_SNAPSHOT_NAME).unwrap() + } + pub fn get_meta_first_block_in_db(&self) -> DbResult { let cf_meta = self.meta_column(); let res = self @@ -384,6 +401,142 @@ impl RocksDBIO { Ok(data_blob_list) } + + pub fn get_snapshot_block_id(&self) -> DbResult { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_BLOCK_ID_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(u64::from_be_bytes(data.try_into().unwrap())) + } else { + Err(DbError::db_interaction_error( + "Snapshot block ID not found".to_string(), + )) + } + } + + pub fn get_snapshot_commitment(&self) -> DbResult> { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_COMMITMENT_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(data) + } else { + Err(DbError::db_interaction_error( + "Snapshot commitment not found".to_string(), + )) + } + } + + pub fn get_snapshot_transaction(&self) -> DbResult> { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_TRANSACTION_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(data) + } else { + Err(DbError::db_interaction_error( + "Snapshot transaction not found".to_string(), + )) + } + } + + pub fn get_snapshot_nullifier(&self) -> DbResult> { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_NULLIFIER_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(data) + } else { + Err(DbError::db_interaction_error( + "Snapshot nullifier not found".to_string(), + )) + } + } + + pub fn get_snapshot_account(&self) -> DbResult> { + let cf_snapshot = self.snapshot_column(); + let res = self + .db + .get_cf(&cf_snapshot, DB_SNAPSHOT_ACCOUNT_KEY) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + + if let Some(data) = res { + Ok(data) + } else { + Err(DbError::db_interaction_error( + "Snapshot account not found".to_string(), + )) + } + } + + pub fn put_snapshot_block_id_db(&self, block_id: u64) -> DbResult<()> { + let cf_snapshot = self.snapshot_column(); + self.db + .put_cf( + &cf_snapshot, + DB_SNAPSHOT_BLOCK_ID_KEY.as_bytes(), + block_id.to_be_bytes(), + ) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } + + pub fn put_snapshot_commitement_db(&self, commitment: Vec) -> DbResult<()> { + let cf_snapshot = self.snapshot_column(); + self.db + .put_cf( + &cf_snapshot, + DB_SNAPSHOT_COMMITMENT_KEY.as_bytes(), + commitment, + ) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } + + pub fn put_snapshot_transaction_db(&self, transaction: Vec) -> DbResult<()> { + let cf_snapshot = self.snapshot_column(); + self.db + .put_cf( + &cf_snapshot, + DB_SNAPSHOT_TRANSACTION_KEY.as_bytes(), + transaction, + ) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } + + pub fn put_snapshot_nullifier_db(&self, nullifier: Vec) -> DbResult<()> { + let cf_snapshot = self.snapshot_column(); + self.db + .put_cf( + &cf_snapshot, + DB_SNAPSHOT_NULLIFIER_KEY.as_bytes(), + nullifier, + ) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } + + pub fn put_snapshot_account_db(&self, account: Vec) -> DbResult<()> { + let cf_snapshot = self.snapshot_column(); + self.db + .put_cf(&cf_snapshot, DB_SNAPSHOT_ACCOUNT_KEY.as_bytes(), account) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } } ///Creates address for sc data blob at corresponding id diff --git a/utxo/Cargo.toml b/utxo/Cargo.toml index 9b99cf9..02b9ed8 100644 --- a/utxo/Cargo.toml +++ b/utxo/Cargo.toml @@ -9,9 +9,9 @@ serde_json.workspace = true env_logger.workspace = true log.workspace = true serde.workspace = true -monotree.workspace = true sha2.workspace = true hex.workspace = true +rand.workspace = true [dependencies.common] path = "../common" diff --git a/utxo/src/lib.rs b/utxo/src/lib.rs index 1b7e30c..7baf984 100644 --- a/utxo/src/lib.rs +++ b/utxo/src/lib.rs @@ -1,2 +1 @@ pub mod utxo_core; -pub mod utxo_tree; diff --git a/utxo/src/utxo_core.rs b/utxo/src/utxo_core.rs index a4777b3..4e40ce3 100644 --- a/utxo/src/utxo_core.rs +++ b/utxo/src/utxo_core.rs @@ -1,22 +1,24 @@ use anyhow::Result; -use common::{merkle_tree_public::TreeHashType, nullifier::UTXONullifier, AccountId}; +use common::{merkle_tree_public::TreeHashType, AccountId}; use log::info; +use rand::{rngs::OsRng, RngCore}; use serde::{Deserialize, Serialize}; use sha2::{digest::FixedOutput, Digest}; ///Raw asset data pub type Asset = Vec; +pub type Randomness = [u8; 32]; #[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] ///Container for raw utxo payload pub struct UTXO { pub hash: TreeHashType, pub owner: AccountId, - pub nullifier: Option, pub asset: Asset, // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: Randomness, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -26,36 +28,47 @@ pub struct UTXOPayload { // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: Randomness, +} + +impl UTXOPayload { + fn to_bytes(&self) -> Vec { + let mut result = Vec::new(); + result.extend_from_slice(&self.owner); + result.extend_from_slice(&self.asset); + result.extend_from_slice(&self.amount.to_be_bytes()); + result.push(self.privacy_flag as u8); + result.extend_from_slice(&self.randomness); + result + } } impl UTXO { - pub fn create_utxo_from_payload(payload_with_asset: UTXOPayload) -> anyhow::Result { - let raw_payload = serde_json::to_vec(&payload_with_asset)?; - + pub fn new(owner: AccountId, asset: Asset, amount: u128, privacy_flag: bool) -> Self { + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + let payload = UTXOPayload { + owner, + asset, + amount, + privacy_flag, + randomness, + }; + Self::create_utxo_from_payload(payload) + } + pub fn create_utxo_from_payload(payload_with_asset: UTXOPayload) -> Self { let mut hasher = sha2::Sha256::new(); - - hasher.update(&raw_payload); - + hasher.update(&payload_with_asset.to_bytes()); let hash = ::from(hasher.finalize_fixed()); - Ok(Self { + Self { hash, owner: payload_with_asset.owner, - nullifier: None, asset: payload_with_asset.asset, amount: payload_with_asset.amount, privacy_flag: payload_with_asset.privacy_flag, - }) - } - - pub fn consume_utxo(&mut self, nullifier: UTXONullifier) -> Result<()> { - if self.nullifier.is_some() { - anyhow::bail!("UTXO already consumed"); - } else { - self.nullifier = Some(nullifier); + randomness: payload_with_asset.randomness, } - - Ok(()) } pub fn interpret_asset<'de, ToInterpret: Deserialize<'de>>(&'de self) -> Result { @@ -68,16 +81,13 @@ impl UTXO { asset: self.asset.clone(), amount: self.amount, privacy_flag: self.privacy_flag, + randomness: self.randomness, } } pub fn log(&self) { info!("UTXO hash is {:?}", hex::encode(self.hash)); info!("UTXO owner is {:?}", hex::encode(self.owner)); - info!( - "UTXO nullifier is {:?}", - self.nullifier.clone().map(|val| hex::encode(val.utxo_hash)) - ); info!("UTXO asset is {:?}", hex::encode(self.asset.clone())); info!("UTXO amount is {:?}", self.amount); info!("UTXO privacy_flag is {:?}", self.privacy_flag); @@ -98,14 +108,6 @@ mod tests { AccountId::default() } - fn sample_nullifier() -> UTXONullifier { - UTXONullifier::default() - } - - fn sample_tree_hash() -> TreeHashType { - TreeHashType::default() - } - fn sample_payload() -> UTXOPayload { UTXOPayload { owner: sample_account(), @@ -116,40 +118,24 @@ mod tests { .unwrap(), amount: 10, privacy_flag: false, + randomness: Randomness::default(), } } #[test] fn test_create_utxo_from_payload() { let payload = sample_payload(); - let utxo = UTXO::create_utxo_from_payload(payload.clone()).unwrap(); + let utxo = UTXO::create_utxo_from_payload(payload.clone()); // Ensure hash is created and the UTXO fields are correctly assigned assert_eq!(utxo.owner, payload.owner); assert_eq!(utxo.asset, payload.asset); - assert!(utxo.nullifier.is_none()); - } - - #[test] - fn test_consume_utxo() { - let payload = sample_payload(); - let mut utxo = UTXO::create_utxo_from_payload(payload).unwrap(); - - let nullifier = sample_nullifier(); - - // First consumption should succeed - assert!(utxo.consume_utxo(nullifier.clone()).is_ok()); - assert_eq!(utxo.nullifier, Some(nullifier)); - - // Second consumption should fail - let result = utxo.consume_utxo(sample_nullifier()); - assert!(result.is_err()); } #[test] fn test_interpret_asset() { let payload = sample_payload(); - let utxo = UTXO::create_utxo_from_payload(payload).unwrap(); + let utxo = UTXO::create_utxo_from_payload(payload); // Interpret asset as TestAsset let interpreted: TestAsset = utxo.interpret_asset().unwrap(); @@ -167,7 +153,7 @@ mod tests { fn test_interpret_invalid_asset() { let mut payload = sample_payload(); payload.asset = vec![0, 1, 2, 3]; // Invalid data for deserialization - let utxo = UTXO::create_utxo_from_payload(payload).unwrap(); + let utxo = UTXO::create_utxo_from_payload(payload); // This should fail because the asset is not valid JSON for TestAsset let result: Result = utxo.interpret_asset(); diff --git a/utxo/src/utxo_tree.rs b/utxo/src/utxo_tree.rs deleted file mode 100644 index 3c0c603..0000000 --- a/utxo/src/utxo_tree.rs +++ /dev/null @@ -1,192 +0,0 @@ -use std::collections::HashMap; - -use common::merkle_tree_public::TreeHashType; -use monotree::database::MemoryDB; -use monotree::hasher::Blake3; -use monotree::{Hasher, Monotree, Proof}; - -use crate::utxo_core::UTXO; - -pub struct UTXOSparseMerkleTree { - pub curr_root: Option, - pub tree: Monotree, - pub hasher: Blake3, - pub store: HashMap, -} - -impl UTXOSparseMerkleTree { - pub fn new() -> Self { - UTXOSparseMerkleTree { - curr_root: None, - tree: Monotree::default(), - hasher: Blake3::new(), - store: HashMap::new(), - } - } - - pub fn insert_item(&mut self, utxo: UTXO) -> Result<(), monotree::Errors> { - let root = self.curr_root.as_ref(); - - let new_root = self.tree.insert(root, &utxo.hash, &utxo.hash)?; - - self.store.insert(utxo.hash, utxo); - - self.curr_root = new_root; - - Ok(()) - } - - pub fn insert_items(&mut self, utxos: Vec) -> Result<(), monotree::Errors> { - let root = self.curr_root.as_ref(); - - let hashes: Vec = utxos.iter().map(|item| item.hash).collect(); - - let new_root = self.tree.inserts(root, &hashes, &hashes)?; - - for utxo in utxos { - self.store.insert(utxo.hash, utxo); - } - - self.curr_root = new_root; - - Ok(()) - } - - pub fn get_item(&mut self, hash: TreeHashType) -> Result, monotree::Errors> { - let hash = self.tree.get(self.curr_root.as_ref(), &hash)?; - - Ok(hash.and_then(|hash| self.store.get(&hash))) - } - - pub fn get_membership_proof( - &mut self, - nullifier_hash: TreeHashType, - ) -> Result, monotree::Errors> { - self.tree - .get_merkle_proof(self.curr_root.as_ref(), &nullifier_hash) - } -} - -impl Default for UTXOSparseMerkleTree { - fn default() -> Self { - Self::new() - } -} - -#[cfg(test)] -mod tests { - use common::AccountId; - - use super::*; - use crate::utxo_core::{UTXOPayload, UTXO}; - - fn sample_utxo_payload() -> UTXOPayload { - UTXOPayload { - owner: AccountId::default(), - asset: vec![1, 2, 3], - amount: 10, - privacy_flag: false, - } - } - - fn sample_utxo() -> anyhow::Result { - UTXO::create_utxo_from_payload(sample_utxo_payload()) - } - - #[test] - fn test_utxo_sparse_merkle_tree_new() { - let smt = UTXOSparseMerkleTree::new(); - assert!(smt.curr_root.is_none()); - assert_eq!(smt.store.len(), 0); - } - - #[test] - fn test_insert_item() { - let mut smt = UTXOSparseMerkleTree::new(); - let utxo = sample_utxo().unwrap(); - - let result = smt.insert_item(utxo.clone()); - - // Test insertion is successful - assert!(result.is_ok()); - - // Test UTXO is now stored in the tree - assert_eq!(smt.store.get(&utxo.hash).unwrap().hash, utxo.hash); - - // Test curr_root is updated - assert!(smt.curr_root.is_some()); - } - - #[test] - fn test_insert_items() { - let mut smt = UTXOSparseMerkleTree::new(); - let utxo1 = sample_utxo().unwrap(); - let utxo2 = sample_utxo().unwrap(); - - let result = smt.insert_items(vec![utxo1.clone(), utxo2.clone()]); - - // Test insertion of multiple items is successful - assert!(result.is_ok()); - - // Test UTXOs are now stored in the tree - assert!(smt.store.get(&utxo1.hash).is_some()); - assert!(smt.store.get(&utxo2.hash).is_some()); - - // Test curr_root is updated - assert!(smt.curr_root.is_some()); - } - - #[test] - fn test_get_item_exists() { - let mut smt = UTXOSparseMerkleTree::new(); - let utxo = sample_utxo().unwrap(); - - smt.insert_item(utxo.clone()).unwrap(); - - // Test that the UTXO can be retrieved by hash - let retrieved_utxo = smt.get_item(utxo.hash).unwrap(); - assert!(retrieved_utxo.is_some()); - assert_eq!(retrieved_utxo.unwrap().hash, utxo.hash); - } - - #[test] - fn test_get_item_not_exists() { - let mut smt = UTXOSparseMerkleTree::new(); - let utxo = sample_utxo().unwrap(); - - // Insert one UTXO and try to fetch a different hash - smt.insert_item(utxo).unwrap(); - - let non_existent_hash = TreeHashType::default(); - let result = smt.get_item(non_existent_hash).unwrap(); - - // Test that retrieval for a non-existent UTXO returns None - assert!(result.is_none()); - } - - #[test] - fn test_get_membership_proof() { - let mut smt = UTXOSparseMerkleTree::new(); - let utxo = sample_utxo().unwrap(); - - smt.insert_item(utxo.clone()).unwrap(); - - // Fetch membership proof for the inserted UTXO - let proof = smt.get_membership_proof(utxo.hash).unwrap(); - - // Test proof is generated successfully - assert!(proof.is_some()); - } - - #[test] - fn test_get_membership_proof_not_exists() { - let mut smt = UTXOSparseMerkleTree::new(); - - // Try fetching proof for a non-existent UTXO hash - let non_existent_hash = TreeHashType::default(); - let proof = smt.get_membership_proof(non_existent_hash).unwrap(); - - // Test no proof is generated for a non-existent UTXO - assert!(proof.is_none()); - } -} diff --git a/zkvm/Cargo.toml b/zkvm/Cargo.toml index f384a56..1a64da4 100644 --- a/zkvm/Cargo.toml +++ b/zkvm/Cargo.toml @@ -10,8 +10,9 @@ env_logger.workspace = true log.workspace = true serde.workspace = true thiserror.workspace = true +rand.workspace = true -risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-zkvm = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } test-methods = { path = "test_methods" } [dependencies.accounts] diff --git a/zkvm/src/lib.rs b/zkvm/src/lib.rs index 510aee5..7ab1225 100644 --- a/zkvm/src/lib.rs +++ b/zkvm/src/lib.rs @@ -1,8 +1,9 @@ use accounts::account_core::AccountAddress; use common::ExecutionFailureKind; +use rand::{rngs::OsRng, RngCore}; use risc0_zkvm::{default_executor, default_prover, sha::Digest, ExecutorEnv, Receipt}; use serde::Serialize; -use utxo::utxo_core::{UTXOPayload, UTXO}; +use utxo::utxo_core::{Randomness, UTXOPayload, UTXO}; pub mod gas_calculator; @@ -43,6 +44,12 @@ pub fn prove_mint_utxo( .write(&owner) .map_err(ExecutionFailureKind::write_error)?; + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + builder + .write(&randomness) + .map_err(ExecutionFailureKind::write_error)?; + let env = builder .build() .map_err(ExecutionFailureKind::builder_error)?; @@ -56,10 +63,7 @@ pub fn prove_mint_utxo( let digest: UTXOPayload = receipt.journal.decode()?; - Ok(( - UTXO::create_utxo_from_payload(digest).map_err(ExecutionFailureKind::write_error)?, - receipt, - )) + Ok((UTXO::create_utxo_from_payload(digest), receipt)) } pub fn prove_send_utxo( @@ -78,8 +82,18 @@ pub fn prove_send_utxo( builder .write(&utxo_payload) .map_err(ExecutionFailureKind::write_error)?; + + let owners_parts_with_randomness = owners_parts + .into_iter() + .map(|(amount, addr)| { + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + (amount, addr, randomness) + }) + .collect::>(); + builder - .write(&owners_parts) + .write(&owners_parts_with_randomness) .map_err(ExecutionFailureKind::write_error)?; let env = builder @@ -98,9 +112,8 @@ pub fn prove_send_utxo( Ok(( digest .into_iter() - .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload).map(|sel| (sel, addr)))) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload), addr)) + .collect(), receipt, )) } @@ -148,14 +161,12 @@ pub fn prove_send_utxo_multiple_assets_one_receiver( .0 .into_iter() .map(|payload| UTXO::create_utxo_from_payload(payload)) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .collect(), digest .1 .into_iter() .map(|payload| UTXO::create_utxo_from_payload(payload)) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .collect(), receipt, )) } @@ -171,13 +182,7 @@ pub fn prove_send_utxo_shielded( return Err(ExecutionFailureKind::AmountMismatchError); } - let temp_utxo_to_spend = UTXO::create_utxo_from_payload(UTXOPayload { - owner, - asset: vec![], - amount, - privacy_flag: true, - }) - .map_err(ExecutionFailureKind::write_error)?; + let temp_utxo_to_spend = UTXO::new(owner, vec![], amount, true); let utxo_payload = temp_utxo_to_spend.into_payload(); let mut builder = ExecutorEnv::builder(); @@ -185,8 +190,18 @@ pub fn prove_send_utxo_shielded( builder .write(&utxo_payload) .map_err(ExecutionFailureKind::write_error)?; + + let owners_parts_with_randomness = owners_parts + .into_iter() + .map(|(amount, addr)| { + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + (amount, addr, randomness) + }) + .collect::>(); + builder - .write(&owners_parts) + .write(&owners_parts_with_randomness) .map_err(ExecutionFailureKind::write_error)?; let env = builder @@ -205,9 +220,8 @@ pub fn prove_send_utxo_shielded( Ok(( digest .into_iter() - .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload).map(|sel| (sel, addr)))) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload), addr)) + .collect(), receipt, )) } @@ -228,8 +242,18 @@ pub fn prove_send_utxo_deshielded( builder .write(&utxo_payload) .map_err(ExecutionFailureKind::write_error)?; + + let owners_parts_with_randomness = owners_parts + .into_iter() + .map(|(amount, addr)| { + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + (amount, addr, randomness) + }) + .collect::>(); + builder - .write(&owners_parts) + .write(&owners_parts_with_randomness) .map_err(ExecutionFailureKind::write_error)?; let env = builder @@ -288,8 +312,7 @@ pub fn prove_mint_utxo_multiple_assets( digest .into_iter() .map(UTXO::create_utxo_from_payload) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .collect(), receipt, )) } @@ -308,7 +331,7 @@ pub fn execute_mint_utxo(amount_to_mint: u128, owner: AccountAddress) -> anyhow: let digest: UTXOPayload = receipt.journal.decode()?; - UTXO::create_utxo_from_payload(digest) + Ok(UTXO::create_utxo_from_payload(digest)) } pub fn execute_send_utxo( @@ -320,7 +343,16 @@ pub fn execute_send_utxo( let utxo_payload = spent_utxo.into_payload(); builder.write(&utxo_payload)?; - builder.write(&owners_parts)?; + let owners_parts_with_randomness = owners_parts + .into_iter() + .map(|(amount, addr)| { + let mut randomness = Randomness::default(); + OsRng.fill_bytes(&mut randomness); + (amount, addr, randomness) + }) + .collect::>(); + + builder.write(&owners_parts_with_randomness)?; let env = builder.build()?; @@ -331,13 +363,12 @@ pub fn execute_send_utxo( let digest: (UTXOPayload, Vec<(UTXOPayload, AccountAddress)>) = receipt.journal.decode()?; Ok(( - UTXO::create_utxo_from_payload(digest.0)?, + UTXO::create_utxo_from_payload(digest.0), digest .1 .into_iter() - .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload).map(|sel| (sel, addr)))) - .collect::>>() - .map_err(ExecutionFailureKind::write_error)?, + .map(|(payload, addr)| (UTXO::create_utxo_from_payload(payload), addr)) + .collect(), )) } diff --git a/zkvm/test_methods/Cargo.toml b/zkvm/test_methods/Cargo.toml index 35dc8bd..70584d6 100644 --- a/zkvm/test_methods/Cargo.toml +++ b/zkvm/test_methods/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [build-dependencies] -risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.0" } +risc0-build = { git = "https://github.com/risc0/risc0.git", branch = "release-2.1" } [package.metadata.risc0] methods = ["guest"] diff --git a/zkvm/test_methods/guest/src/bin/mint_utxo.rs b/zkvm/test_methods/guest/src/bin/mint_utxo.rs index ad51311..5123643 100644 --- a/zkvm/test_methods/guest/src/bin/mint_utxo.rs +++ b/zkvm/test_methods/guest/src/bin/mint_utxo.rs @@ -12,17 +12,20 @@ pub struct UTXOPayload { // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: [u8; 32], } fn main() { let amount_to_mint: u128 = env::read(); let owner: AccountAddr = env::read(); + let randomness: [u8; 32] = env::read(); let payload = UTXOPayload { owner, asset: vec![], amount: amount_to_mint, privacy_flag: true, + randomness, }; env::commit(&(payload)); diff --git a/zkvm/test_methods/guest/src/bin/mint_utxo_multiple_assets.rs b/zkvm/test_methods/guest/src/bin/mint_utxo_multiple_assets.rs index 8ba50c4..47ad2ac 100644 --- a/zkvm/test_methods/guest/src/bin/mint_utxo_multiple_assets.rs +++ b/zkvm/test_methods/guest/src/bin/mint_utxo_multiple_assets.rs @@ -12,12 +12,14 @@ pub struct UTXOPayload { // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: [u8; 32], } fn main() { let amount_to_mint: u128 = env::read(); let number_of_assets: usize = env::read(); let owner: AccountAddr = env::read(); + let randomness: [u8; 32] = env::read(); let mut asseted_utxos = vec![]; @@ -27,6 +29,7 @@ fn main() { asset: vec![i as u8], amount: amount_to_mint, privacy_flag: true, + randomness }; asseted_utxos.push(payload); diff --git a/zkvm/test_methods/guest/src/bin/send_utxo.rs b/zkvm/test_methods/guest/src/bin/send_utxo.rs index d05995c..64035a9 100644 --- a/zkvm/test_methods/guest/src/bin/send_utxo.rs +++ b/zkvm/test_methods/guest/src/bin/send_utxo.rs @@ -12,18 +12,20 @@ pub struct UTXOPayload { // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: [u8; 32], } fn main() { let utxo_spent: UTXOPayload = env::read(); - let owners_parts: Vec<(u128, AccountAddr)> = env::read(); + let owners_parts: Vec<(u128, AccountAddr, [u8; 32])> = env::read(); - let res: Vec<(UTXOPayload, AccountAddr)> = owners_parts.into_iter().map(|(amount, addr)| ( + let res: Vec<(UTXOPayload, AccountAddr)> = owners_parts.into_iter().map(|(amount, addr, randomness)| ( UTXOPayload { owner: addr.clone(), asset: vec![], amount, privacy_flag: true, + randomness, }, addr )).collect(); diff --git a/zkvm/test_methods/guest/src/bin/send_utxo_multiple_assets.rs b/zkvm/test_methods/guest/src/bin/send_utxo_multiple_assets.rs index 2568da3..e73f844 100644 --- a/zkvm/test_methods/guest/src/bin/send_utxo_multiple_assets.rs +++ b/zkvm/test_methods/guest/src/bin/send_utxo_multiple_assets.rs @@ -12,6 +12,7 @@ pub struct UTXOPayload { // TODO: change to u256 pub amount: u128, pub privacy_flag: bool, + pub randomness: [u8; 32], } fn main() {