diff --git a/Cargo.lock b/Cargo.lock index 451bc28458..f22524be1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -173,6 +173,127 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.1", + "itertools 0.10.5", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote 1.0.35", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote 1.0.35", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.1", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand", + "rayon", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -193,7 +314,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -217,18 +338,36 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bech32" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "bincode" version = "1.3.3" @@ -256,7 +395,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -327,6 +466,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bnum" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" + [[package]] name = "bs58" version = "0.5.0" @@ -485,7 +630,7 @@ dependencies = [ "heck", "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -533,6 +678,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + [[package]] name = "constant_time_eq" version = "0.3.0" @@ -555,6 +706,71 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "cosmwasm-core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34c440d4d8e3ecec783d0f9c89d25565168b0f4cdb80a1f6a387cf2168c0740" + +[[package]] +name = "cosmwasm-crypto" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134e765161d60228cc27635032d2a466542ca83fd6c87f3c87f4963c0bd51008" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "cosmwasm-core", + "curve25519-dalek", + "digest", + "ecdsa", + "ed25519-zebra", + "k256", + "num-traits", + "p256", + "rand_core", + "rayon", + "sha2", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c94a4b93e722c91d2e58471cfe69480f4a656cfccacd8bfda5638f2a5d4512b" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.96", +] + +[[package]] +name = "cosmwasm-std" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434e556b0aebff34bf082e75d175b5d7edbcf1d90d4cedb59623a1249fff567" +dependencies = [ + "base64 0.22.1", + "bech32 0.11.0", + "bnum", + "cosmwasm-core", + "cosmwasm-crypto", + "cosmwasm-derive", + "derive_more", + "hex", + "rand_core", + "rmp-serde", + "schemars", + "serde", + "serde-json-wasm", + "sha2", + "static_assertions", + "thiserror", +] + [[package]] name = "cpufeatures" version = "0.2.12" @@ -649,6 +865,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -707,6 +935,33 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.96", +] + [[package]] name = "dashmap" version = "5.5.3" @@ -720,6 +975,16 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "der" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" +dependencies = [ + "const-oid", + "zeroize", +] + [[package]] name = "deranged" version = "0.3.11" @@ -729,6 +994,38 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.96", + "unicode-xid 0.2.6", +] + [[package]] name = "digest" version = "0.10.7" @@ -736,6 +1033,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", "subtle", ] @@ -772,12 +1070,73 @@ version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "hashbrown 0.14.3", + "hex", + "rand_core", + "sha2", + "zeroize", +] + [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encode_unicode" version = "0.3.6" @@ -874,7 +1233,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -944,6 +1303,22 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "fil-rustacuda" version = "0.1.4" @@ -1096,6 +1471,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -1132,6 +1508,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "h2" version = "0.3.24" @@ -1200,6 +1587,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + [[package]] name = "home" version = "0.5.9" @@ -1393,6 +1789,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1537,7 +1945,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a4c4718a371ddfb7806378f23617876eea8b82e5ff1324516bcd283249d9ea" dependencies = [ - "base64", + "base64 0.21.7", "hyper", "hyper-tls", "indexmap 1.9.3", @@ -1660,7 +2068,7 @@ checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -1685,9 +2093,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -1772,7 +2180,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -1799,6 +2207,18 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1911,14 +2331,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.48", + "syn 2.0.96", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", ] [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -2048,9 +2477,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2136,7 +2565,7 @@ version = "0.11.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" dependencies = [ - "base64", + "base64 0.21.7", "bytes", "encoding_rs", "futures-core", @@ -2168,6 +2597,16 @@ dependencies = [ "winreg", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + [[package]] name = "ring" version = "0.17.7" @@ -2182,6 +2621,28 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rmp" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + [[package]] name = "rocksdb" version = "0.21.0" @@ -2330,6 +2791,30 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "serde_derive_internals", + "syn 2.0.96", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2352,6 +2837,19 @@ dependencies = [ "untrusted", ] +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + [[package]] name = "security-framework" version = "2.9.2" @@ -2413,22 +2911,42 @@ checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.217" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.96", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -2490,7 +3008,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -2519,6 +3037,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + [[package]] name = "sketches-ddsketch" version = "0.2.1" @@ -2571,6 +3099,7 @@ dependencies = [ "snarkvm-algorithms", "snarkvm-circuit", "snarkvm-console", + "snarkvm-cosmwasm", "snarkvm-curves", "snarkvm-fields", "snarkvm-ledger", @@ -2915,7 +3444,7 @@ name = "snarkvm-console-network-environment" version = "1.1.0" dependencies = [ "anyhow", - "bech32", + "bech32 0.9.1", "itertools 0.11.0", "nom", "num-traits", @@ -3045,6 +3574,17 @@ dependencies = [ "snarkvm-console-types-integers", ] +[[package]] +name = "snarkvm-cosmwasm" +version = "1.1.0" +dependencies = [ + "getrandom", + "snarkvm-console-account", + "snarkvm-console-network", + "snarkvm-console-program", + "snarkvm-console-types", +] + [[package]] name = "snarkvm-curves" version = "1.1.0" @@ -3374,6 +3914,7 @@ dependencies = [ "colored", "curl", "encoding", + "getrandom", "hex", "indexmap 2.2.6", "itertools 0.11.0", @@ -3500,6 +4041,7 @@ dependencies = [ "aleo-std", "anyhow", "bincode", + "cosmwasm-std", "num-bigint", "num_cpus", "rand", @@ -3519,7 +4061,7 @@ version = "1.1.0" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3575,6 +4117,12 @@ dependencies = [ "which", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.10.0" @@ -3590,7 +4138,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta-derive", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3601,7 +4149,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3618,7 +4166,7 @@ checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" dependencies = [ "quote 0.3.15", "synom", - "unicode-xid", + "unicode-xid 0.0.4", ] [[package]] @@ -3634,9 +4182,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote 1.0.35", @@ -3649,7 +4197,7 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" dependencies = [ - "unicode-xid", + "unicode-xid 0.0.4", ] [[package]] @@ -3704,7 +4252,7 @@ dependencies = [ "proc-macro2", "quote 1.0.35", "structmeta", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3724,7 +4272,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3872,7 +4420,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -3988,6 +4536,12 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "unsafe-libyaml" version = "0.2.10" @@ -4006,7 +4560,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" dependencies = [ - "base64", + "base64 0.21.7", "flate2", "log", "once_cell", @@ -4114,7 +4668,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", "wasm-bindgen-shared", ] @@ -4148,7 +4702,7 @@ checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4401,7 +4955,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] [[package]] @@ -4421,5 +4975,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote 1.0.35", - "syn 2.0.48", + "syn 2.0.96", ] diff --git a/Cargo.toml b/Cargo.toml index d722810219..8adba97f4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ members = [ "console/types/group", "console/types/integers", "console/types/scalar", - "console/types/string", + "console/types/string", "cosmwasm", "curves", "fields", "ledger", @@ -149,6 +149,7 @@ parameters = [ "snarkvm-parameters" ] synthesizer = [ "snarkvm-synthesizer" ] utilities = [ "snarkvm-utilities" ] wasm = [ "snarkvm-wasm" ] +cosmwasm = [ "snarkvm-cosmwasm" ] test_targets = [ "snarkvm-console/test_targets" ] [dependencies.snarkvm-algorithms] @@ -207,6 +208,12 @@ path = "./wasm" version = "=1.1.0" optional = true +[dependencies.snarkvm-cosmwasm] +path = "./cosmwasm" +version = "=1.1.0" +optional = true + + [dependencies.anstyle] version = "1" diff --git a/algorithms/Cargo.toml b/algorithms/Cargo.toml index 3603cc1a4a..a17dde1450 100644 --- a/algorithms/Cargo.toml +++ b/algorithms/Cargo.toml @@ -196,6 +196,14 @@ wasm = [ "snark", "wasm-bindgen-futures" ] +cosmwasm = [ + "crypto_hash", + "fft", + "msm", + "polycommit_cosmwasm", + "r1cs", + "snark", +] cuda = [ "snarkvm-algorithms-cuda" ] profiler = [ "aleo-std/profiler" ] crypto_hash = [ ] @@ -204,6 +212,7 @@ msm = [ ] test = [ ] polycommit = [ "crypto_hash", "fft", "msm", "rand_core" ] polycommit_wasm = [ "polycommit", "snarkvm-parameters/wasm" ] +polycommit_cosmwasm = [ "polycommit", "snarkvm-parameters/cosmwasm" ] polycommit_full = [ "polycommit", "snarkvm-parameters/default" ] r1cs = [ "cfg-if", "fxhash", "indexmap" ] serial = [ diff --git a/console/network/Cargo.toml b/console/network/Cargo.toml index 34f970c636..3b7eac9fde 100644 --- a/console/network/Cargo.toml +++ b/console/network/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "snarkvm-console-network" version = "1.1.0" -authors = [ "The Aleo Team " ] +authors = ["The Aleo Team "] description = "Network console library for a decentralized virtual machine" homepage = "https://aleo.org" repository = "https://github.com/AleoNet/snarkVM" @@ -9,19 +9,17 @@ license = "Apache-2.0" edition = "2021" [features] -default = [ "snarkvm-algorithms/polycommit_full" ] -wasm = [ - "snarkvm-algorithms/polycommit_wasm", - "snarkvm-parameters/wasm" -] -test = [ ] -test_targets = [ ] +default = ["snarkvm-algorithms/polycommit_full"] +wasm = ["snarkvm-algorithms/polycommit_wasm", "snarkvm-parameters/wasm"] +test = [] +test_targets = [] +cosmwasm = ["snarkvm-parameters/cosmwasm", "snarkvm-utilities/cosmwasm"] [dependencies.snarkvm-algorithms] path = "../../algorithms" version = "=1.1.0" default-features = false -features = [ "snark" ] +features = ["snark"] [dependencies.snarkvm-console-algorithms] path = "../algorithms" @@ -39,7 +37,7 @@ version = "=1.1.0" path = "../types" version = "=1.1.0" default-features = false -features = [ "field", "group", "scalar" ] +features = ["field", "group", "scalar"] [dependencies.snarkvm-curves] path = "../../curves" diff --git a/cosmwasm/Cargo.toml b/cosmwasm/Cargo.toml new file mode 100644 index 0000000000..80f786a2da --- /dev/null +++ b/cosmwasm/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "snarkvm-cosmwasm" +version = "1.1.0" +edition = "2024" + +[lib] +crate-type = ["cdylib", "rlib"] + +[features] +default = [] +full = ["account", "network", "types", "program"] +account = ["snarkvm-console-account"] +network = ["snarkvm-console-network"] +types = ["snarkvm-console-types"] +program = ["snarkvm-console-program"] + +[dependencies.snarkvm-console-account] +path = "../console/account" +version = "=1.1.0" +optional = true + +[dependencies.snarkvm-console-network] +path = "../console/network" +version = "=1.1.0" +features = ["cosmwasm"] +optional = true + +[dependencies.snarkvm-console-types] +path = "../console/types" +version = "=1.1.0" +default-features = false +features = ["address"] +optional = true + +[dependencies.snarkvm-console-program] +path = "../console/program" +version = "=1.1.0" +optional = true + +[dependencies.getrandom] +version = "0.2" +features = ["custom"] diff --git a/cosmwasm/src/lib.rs b/cosmwasm/src/lib.rs new file mode 100644 index 0000000000..6b1e8996d6 --- /dev/null +++ b/cosmwasm/src/lib.rs @@ -0,0 +1,24 @@ +// Copyright 2024 Aleo Network Foundation +// This file is part of the snarkVM library. + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +#[cfg(feature = "account")] +pub use snarkvm_console_account as account; +#[cfg(feature = "network")] +pub use snarkvm_console_network as network; +#[cfg(feature = "types")] +pub use snarkvm_console_types as types; +#[cfg(feature = "program")] +pub use snarkvm_console_program as program; diff --git a/fields/src/macros.rs b/fields/src/macros.rs index 3b09e90f89..4765f02d12 100644 --- a/fields/src/macros.rs +++ b/fields/src/macros.rs @@ -95,7 +95,7 @@ macro_rules! sqrt_impl { let v = $self.pow($P::T_MINUS_ONE_DIV_TWO); let x = *$self * v.square(); - let k = ((n - 1) as f64).sqrt().floor() as u64; + let k = n.isqrt(); // It's important that k_2 results in a number which makes `l_minus_one_times_k` // divisible by `k`, because the native arithmetic will not match the field // arithmetic otherwise (native numbers will divide and round down, but field diff --git a/parameters/Cargo.toml b/parameters/Cargo.toml index c4e6f93496..571d60990b 100644 --- a/parameters/Cargo.toml +++ b/parameters/Cargo.toml @@ -28,6 +28,10 @@ default = [ "colored", "remote" ] no_std_out = [ ] remote = [ "curl" ] wasm = [ "encoding", "js-sys", "web-sys" ] +cosmwasm = [ "getrandom/custom" ] + +[dependencies.getrandom] +version = "0.2" [dependencies.snarkvm-curves] path = "../curves" diff --git a/parameters/src/canary/mod.rs b/parameters/src/canary/mod.rs index 9a35444aa0..37cb2441f3 100644 --- a/parameters/src/canary/mod.rs +++ b/parameters/src/canary/mod.rs @@ -19,6 +19,7 @@ pub use genesis::*; /// The restrictions list as a JSON-compatible string. pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json"); +#[cfg(not(feature = "cosmwasm"))] const REMOTE_URL: &str = "https://parameters.aleo.org/canary"; // BondPublic diff --git a/parameters/src/errors/parameter.rs b/parameters/src/errors/parameter.rs index 3584bbeae2..22c3caa22f 100644 --- a/parameters/src/errors/parameter.rs +++ b/parameters/src/errors/parameter.rs @@ -36,7 +36,7 @@ pub enum ParameterError { Wasm(String), } -#[cfg(not(feature = "wasm"))] +#[cfg(not(any(feature = "wasm", feature = "cosmwasm")))] impl From for ParameterError { fn from(error: curl::Error) -> Self { ParameterError::Crate("curl::error", format!("{error:?}")) diff --git a/parameters/src/macros.rs b/parameters/src/macros.rs index 14ec141d40..ac1dfb0abf 100644 --- a/parameters/src/macros.rs +++ b/parameters/src/macros.rs @@ -32,7 +32,7 @@ macro_rules! checksum_error { macro_rules! remove_file { ($filepath:expr) => { // Safely remove the corrupt file, if it exists. - #[cfg(not(feature = "wasm"))] + #[cfg(not(any(feature = "wasm", feature = "cosmwasm")))] if std::path::PathBuf::from(&$filepath).exists() { match std::fs::remove_file(&$filepath) { Ok(()) => println!("Removed {:?}. Please retry the command.", $filepath), @@ -44,7 +44,7 @@ macro_rules! remove_file { macro_rules! impl_store_and_remote_fetch { () => { - #[cfg(not(feature = "wasm"))] + #[cfg(not(any(feature = "wasm", feature = "cosmwasm")))] fn store_bytes(buffer: &[u8], file_path: &std::path::Path) -> Result<(), $crate::errors::ParameterError> { use snarkvm_utilities::Write; @@ -68,7 +68,7 @@ macro_rules! impl_store_and_remote_fetch { Ok(()) } - #[cfg(not(feature = "wasm"))] + #[cfg(not(any(feature = "wasm", feature = "cosmwasm")))] fn remote_fetch(buffer: &mut Vec, url: &str) -> Result<(), $crate::errors::ParameterError> { let mut easy = curl::easy::Easy::new(); easy.follow_location(true)?; @@ -167,6 +167,7 @@ macro_rules! impl_load_bytes_logic_local { }; } +#[cfg(not(feature = "cosmwasm"))] macro_rules! impl_load_bytes_logic_remote { ($remote_url: expr, $local_dir: expr, $filename: expr, $metadata: expr, $expected_checksum: expr, $expected_size: expr) => { // Compose the correct file path for the parameter file. @@ -194,7 +195,7 @@ macro_rules! impl_load_bytes_logic_remote { // Load remote file cfg_if::cfg_if! { - if #[cfg(not(feature = "wasm"))] { + if #[cfg(not(any(feature = "wasm", feature = "cosmwasm")))] { let mut buffer = vec![]; Self::remote_fetch(&mut buffer, &url)?; @@ -224,7 +225,7 @@ macro_rules! impl_load_bytes_logic_remote { } buffer - } else { + } else { return Err($crate::errors::ParameterError::RemoteFetchDisabled); } } @@ -321,27 +322,33 @@ macro_rules! impl_remote { impl_store_and_remote_fetch!(); pub fn load_bytes() -> Result, $crate::errors::ParameterError> { - let metadata: serde_json::Value = - serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted"); - let expected_checksum: String = - metadata["checksum"].as_str().expect("Failed to parse checksum").to_string(); - let expected_size: usize = - metadata["size"].to_string().parse().expect("Failed to retrieve the file size"); + #[cfg(not(feature = "cosmwasm"))] + { + let metadata: serde_json::Value = + serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted"); + let expected_checksum: String = + metadata["checksum"].as_str().expect("Failed to parse checksum").to_string(); + let expected_size: usize = + metadata["size"].to_string().parse().expect("Failed to retrieve the file size"); + + // Construct the versioned filename. + let filename = match expected_checksum.get(0..7) { + Some(sum) => format!("{}.{}.{}", $fname, "usrs", sum), + _ => format!("{}.{}", $fname, "usrs"), + }; + + impl_load_bytes_logic_remote!( + $remote_url, + $local_dir, + &filename, + metadata, + expected_checksum, + expected_size + ); + } - // Construct the versioned filename. - let filename = match expected_checksum.get(0..7) { - Some(sum) => format!("{}.{}.{}", $fname, "usrs", sum), - _ => format!("{}.{}", $fname, "usrs"), - }; - - impl_load_bytes_logic_remote!( - $remote_url, - $local_dir, - &filename, - metadata, - expected_checksum, - expected_size - ); + #[cfg(feature = "cosmwasm")] + unimplemented!() } } paste::item! { @@ -361,27 +368,35 @@ macro_rules! impl_remote { impl_store_and_remote_fetch!(); pub fn load_bytes() -> Result, $crate::errors::ParameterError> { - let metadata: serde_json::Value = - serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted"); - let expected_checksum: String = - metadata[concat!($ftype, "_checksum")].as_str().expect("Failed to parse checksum").to_string(); - let expected_size: usize = - metadata[concat!($ftype, "_size")].to_string().parse().expect("Failed to retrieve the file size"); + #[cfg(not(feature = "cosmwasm"))] + { + let metadata: serde_json::Value = + serde_json::from_str(Self::METADATA).expect("Metadata was not well-formatted"); + let expected_checksum: String = + metadata[concat!($ftype, "_checksum")].as_str().expect("Failed to parse checksum").to_string(); + let expected_size: usize = metadata[concat!($ftype, "_size")] + .to_string() + .parse() + .expect("Failed to retrieve the file size"); + + // Construct the versioned filename. + let filename = match expected_checksum.get(0..7) { + Some(sum) => format!("{}.{}.{}", $fname, $ftype, sum), + _ => format!("{}.{}", $fname, $ftype), + }; + + impl_load_bytes_logic_remote!( + $remote_url, + $local_dir, + &filename, + metadata, + expected_checksum, + expected_size + ); + } - // Construct the versioned filename. - let filename = match expected_checksum.get(0..7) { - Some(sum) => format!("{}.{}.{}", $fname, $ftype, sum), - _ => format!("{}.{}", $fname, $ftype), - }; - - impl_load_bytes_logic_remote!( - $remote_url, - $local_dir, - &filename, - metadata, - expected_checksum, - expected_size - ); + #[cfg(feature = "cosmwasm")] + unimplemented!() } } diff --git a/parameters/src/mainnet/mod.rs b/parameters/src/mainnet/mod.rs index 029e0922f5..5e1e070d4e 100644 --- a/parameters/src/mainnet/mod.rs +++ b/parameters/src/mainnet/mod.rs @@ -22,6 +22,7 @@ pub use powers::*; /// The restrictions list as a JSON-compatible string. pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json"); +#[cfg(not(feature = "cosmwasm"))] const REMOTE_URL: &str = "https://parameters.aleo.org/mainnet"; // Degrees diff --git a/parameters/src/testnet/mod.rs b/parameters/src/testnet/mod.rs index 84f3c76531..4f17dada1e 100644 --- a/parameters/src/testnet/mod.rs +++ b/parameters/src/testnet/mod.rs @@ -19,6 +19,7 @@ pub use genesis::*; /// The restrictions list as a JSON-compatible string. pub const RESTRICTIONS_LIST: &str = include_str!("./resources/restrictions.json"); +#[cfg(not(feature = "cosmwasm"))] const REMOTE_URL: &str = "https://parameters.aleo.org/testnet"; // BondPublic diff --git a/utilities/Cargo.toml b/utilities/Cargo.toml index 8d6ca632a4..e90546635a 100644 --- a/utilities/Cargo.toml +++ b/utilities/Cargo.toml @@ -45,6 +45,7 @@ optional = true [dependencies.num-bigint] version = "0.4" +optional = true [dependencies.rand] version = "0.8" @@ -76,9 +77,14 @@ default-features = false version = "1" features = [ "derive" ] +[dependencies.cosmwasm-std] +version = "2.1.4" +optional = true + [features] -default = [ "aleo-std/cpu", "derive", "num_cpus", "std" ] -derive = [ "snarkvm-utilities-derives" ] -serial = [ "derive" ] -std = [ ] -wasm = [ ] +default = [ "aleo-std/cpu", "derive", "num_cpus", "std", "num-bigint" ] +derive = [ "snarkvm-utilities-derives", "num-bigint" ] +serial = [ "derive", "num-bigint" ] +std = [ "num-bigint" ] +wasm = [ "num-bigint" ] +cosmwasm = [ "cosmwasm-std" ] diff --git a/utilities/src/biginteger/bigint_256.rs b/utilities/src/biginteger/bigint_256.rs index ac9f78d7db..ffa753d135 100644 --- a/utilities/src/biginteger/bigint_256.rs +++ b/utilities/src/biginteger/bigint_256.rs @@ -25,7 +25,6 @@ use crate::{ use anyhow::Result; use core::fmt::{Debug, Display}; -use num_bigint::BigUint; use rand::{ Rng, distributions::{Distribution, Standard}, @@ -199,11 +198,20 @@ impl crate::biginteger::BigInteger for BigInteger256 { } } + #[cfg(not(feature = "cosmwasm"))] #[inline] fn to_biguint(&self) -> num_bigint::BigUint { - BigUint::from_bytes_le(&self.to_bytes_le().unwrap()) + num_bigint::BigUint::from_bytes_le(&self.to_bytes_le().unwrap()) } + // #[cfg(feature = "cosmwasm")] + // #[inline] + // fn to_biguint(&self) -> cosmwasm_std::Uint256 { + // let bytes = self.to_bytes_le().unwrap().into(); + // + // cosmwasm_std::Uint256::new(bytes).into() + // } + #[inline] fn find_wnaf(&self) -> Vec { let mut res = crate::vec::Vec::new(); @@ -304,7 +312,17 @@ impl Debug for BigInteger256 { impl Display for BigInteger256 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.to_biguint()) + #[cfg(not(feature = "cosmwasm"))] + { + write!(f, "{}", self.to_biguint()) + } + + #[cfg(feature = "cosmwasm")] + { + let bytes = self.to_bytes_le().unwrap().try_into().unwrap(); + let num = cosmwasm_std::Uint256::from_le_bytes(bytes); + write!(f, "{}", num) + } } } diff --git a/utilities/src/biginteger/bigint_384.rs b/utilities/src/biginteger/bigint_384.rs index 4ee46574a5..acea3effa1 100644 --- a/utilities/src/biginteger/bigint_384.rs +++ b/utilities/src/biginteger/bigint_384.rs @@ -25,7 +25,6 @@ use crate::{ use anyhow::Result; use core::fmt::{Debug, Display}; -use num_bigint::BigUint; use rand::{ Rng, distributions::{Distribution, Standard}, @@ -206,11 +205,18 @@ impl BigInteger for BigInteger384 { } } + #[cfg(not(feature = "cosmwasm"))] #[inline] fn to_biguint(&self) -> num_bigint::BigUint { - BigUint::from_bytes_le(&self.to_bytes_le().unwrap()) + num_bigint::BigUint::from_bytes_le(&self.to_bytes_le().unwrap()) } + // #[cfg(feature = "cosmwasm")] + // #[inline] + // fn to_biguint(&self) -> num_bigint::BigUint { + // unimplemented!() + // } + #[inline] fn find_wnaf(&self) -> Vec { let mut res = crate::vec::Vec::new(); @@ -301,7 +307,17 @@ impl Debug for BigInteger384 { } impl Display for BigInteger384 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.to_biguint()) + #[cfg(not(feature = "cosmwasm"))] + { + write!(f, "{}", self.to_biguint()) + } + + #[cfg(feature = "cosmwasm")] + { + let bytes = self.to_bytes_le().unwrap().try_into().unwrap(); + let num = cosmwasm_std::Uint256::new(bytes); + write!(f, "{}", num) + } } } impl Ord for BigInteger384 { diff --git a/utilities/src/biginteger/mod.rs b/utilities/src/biginteger/mod.rs index e404bb1648..5eba9a29e4 100644 --- a/utilities/src/biginteger/mod.rs +++ b/utilities/src/biginteger/mod.rs @@ -15,7 +15,6 @@ use crate::{FromBits, FromBytes, ToBits, ToBytes, rand::Uniform}; -use num_bigint::BigUint; use std::fmt::{Debug, Display}; mod bigint_256; @@ -90,7 +89,11 @@ pub trait BigInteger: fn get_bit(&self, i: usize) -> bool; /// Returns the BigUint representation. - fn to_biguint(&self) -> BigUint; + #[cfg(not(feature = "cosmwasm"))] + fn to_biguint(&self) -> num_bigint::BigUint; + + // #[cfg(feature = "cosmwasm")] + // fn to_biguint(&self) -> Vec; /// Returns a vector for wnaf. fn find_wnaf(&self) -> Vec;