From 43a47042aad2e53ddf58f4a7f2d61122bb7faece Mon Sep 17 00:00:00 2001 From: Gus Date: Fri, 23 Aug 2024 07:12:26 -0400 Subject: [PATCH] feat: mnemonic & hotkey pair --- Cargo.lock | 2790 ++++++++++++++++++++++++++++++++++++++++----- Cargo.toml | 11 +- README.md | 20 + src/key.rs | 77 -- src/keypair.rs | 842 +++----------- src/lib.rs | 86 +- src/scalecodec.rs | 99 -- src/sr25519.rs | 97 -- 8 files changed, 2740 insertions(+), 1282 deletions(-) delete mode 100644 src/key.rs delete mode 100644 src/scalecodec.rs delete mode 100644 src/sr25519.rs diff --git a/Cargo.lock b/Cargo.lock index 5e880de..b533f44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,31 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aead" version = "0.5.2" @@ -12,6 +37,44 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.3" @@ -22,10 +85,181 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.86" +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "argon2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3610892ee6e0cbce8ae2700349fcf8f98adb0dbfbee85aec3c9179d29cc072" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures", + "password-hash", +] + +[[package]] +name = "ark-bls12-377" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb00293ba84f51ce3bd026bd0de55899c4e68f0a39a5728cebae3a73ffdc0a4f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[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.2", + "itertools 0.10.5", + "num-traits", + "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 0.10.7", + "itertools 0.10.5", + "num-bigint", + "num-traits", + "paste", + "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", + "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", + "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.2", +] + +[[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 0.10.7", + "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", + "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", +] + +[[package]] +name = "array-bytes" +version = "6.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "5d5dde061bd34119e902bbb2d9b90c5692635cf59fb91d582c2b68043f1b8293" [[package]] name = "arrayref" @@ -45,12 +279,90 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "base58" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bip39" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" +dependencies = [ + "bitcoin_hashes 0.11.0", + "serde", + "unicode-normalization", +] + +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + +[[package]] +name = "bitcoin_hashes" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "bitvec" version = "1.0.1" @@ -69,7 +381,27 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest", + "digest 0.10.7", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.7", ] [[package]] @@ -81,23 +413,50 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "bounded-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32385ecb91a31bddaf908e8dcf4a15aef1bcd3913cc03ebfad02ff6d568abc1" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + [[package]] name = "btwallet" version = "0.1.0" dependencies = [ + "aes-gcm", + "argon2", "base58", + "bip39", "blake2", "generic-array 1.1.0", "hex", - "hmac", - "pbkdf2 0.12.2", + "hmac 0.12.1", + "pbkdf2", "primitive-types", "pyo3", + "rand", "regex", "schnorrkel", - "secp256k1", - "sha2", - "tiny-bip39", + "secp256k1 0.29.0", + "serde", + "sha2 0.10.8", + "sp-core", + "sp-runtime", "uint", ] @@ -119,6 +478,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" + [[package]] name = "cc" version = "1.1.13" @@ -134,6 +499,58 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "constcat" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.13" @@ -149,6 +566,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 0.14.7", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -161,15 +590,34 @@ dependencies = [ ] [[package]] -name = "curve25519-dalek" -version = "4.1.3" +name = "crypto-mac" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "cfg-if", - "cpufeatures", + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[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", + "digest 0.10.7", "fiat-crypto", "rustc_version", "subtle", @@ -188,300 +636,1102 @@ dependencies = [ ] [[package]] -name = "digest" -version = "0.10.7" +name = "der" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ - "block-buffer", - "crypto-common", - "subtle", + "const-oid", + "zeroize", ] [[package]] -name = "equivalent" -version = "1.0.1" +name = "derivative" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] -name = "fiat-crypto" -version = "0.2.9" +name = "derive-syn-parse" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] [[package]] -name = "fixed-hash" -version = "0.8.0" +name = "derive_more" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ - "byteorder", - "rand", - "rustc-hex", - "static_assertions", + "proc-macro2", + "quote", + "syn 2.0.74", ] [[package]] -name = "funty" -version = "2.0.0" +name = "digest" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.7", +] [[package]] -name = "generic-array" -version = "0.14.7" +name = "digest" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "typenum", - "version_check", + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", ] [[package]] -name = "generic-array" -version = "1.1.0" +name = "docify" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" dependencies = [ - "typenum", + "docify_macros", ] [[package]] -name = "getrandom" -version = "0.2.15" +name = "docify_macros" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ - "cfg-if", - "libc", - "wasi", + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.74", + "termcolor", + "toml", + "walkdir", ] [[package]] -name = "getrandom_or_panic" -version = "0.0.3" +name = "dyn-clonable" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" dependencies = [ - "rand", - "rand_core", + "dyn-clonable-impl", + "dyn-clone", ] [[package]] -name = "hashbrown" -version = "0.14.5" +name = "dyn-clonable-impl" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] -name = "heck" -version = "0.5.0" +name = "dyn-clone" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] -name = "hex" -version = "0.4.3" +name = "ecdsa" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "serdect", + "signature", + "spki", +] [[package]] -name = "hmac" -version = "0.12.1" +name = "ed25519" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "digest", + "pkcs8", + "signature", ] [[package]] -name = "impl-codec" -version = "0.6.0" +name = "ed25519-dalek" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ - "parity-scale-codec", + "curve25519-dalek", + "ed25519", + "serde", + "sha2 0.10.8", + "subtle", + "zeroize", ] [[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" +name = "ed25519-zebra" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "curve25519-dalek", + "ed25519", + "hashbrown 0.14.5", + "hex", + "rand_core", + "sha2 0.10.8", + "zeroize", ] [[package]] -name = "indexmap" -version = "2.4.0" +name = "either" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ - "equivalent", - "hashbrown", + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array 0.14.7", + "group", + "pkcs8", + "rand_core", + "sec1", + "serdect", + "subtle", + "zeroize", ] [[package]] -name = "indoc" -version = "2.0.5" +name = "environmental" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] -name = "keccak" -version = "0.1.5" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "expander" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2c470c71d91ecbd179935b24170459e926382eaaa86b590b78814e180d8a8e2" dependencies = [ - "cpufeatures", + "blake2", + "file-guard", + "fs-err", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.74", ] [[package]] -name = "libc" -version = "0.2.156" +name = "ff" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] [[package]] -name = "log" -version = "0.4.22" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] -name = "memchr" -version = "2.7.4" +name = "file-guard" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "21ef72acf95ec3d7dbf61275be556299490a245f017cf084bd23b4f68cf9407c" +dependencies = [ + "libc", + "winapi", +] [[package]] -name = "memoffset" -version = "0.9.1" +name = "fixed-hash" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ - "autocfg", + "byteorder", + "rand", + "rustc-hex", + "static_assertions", ] [[package]] -name = "merlin" -version = "3.0.0" +name = "fs-err" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" dependencies = [ - "byteorder", - "keccak", - "rand_core", - "zeroize", + "autocfg", ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "funty" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] -name = "parity-scale-codec" -version = "3.6.12" +name = "futures" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ - "arrayvec", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", ] [[package]] -name = "parity-scale-codec-derive" -version = "3.6.12" +name = "futures-channel" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", + "futures-core", + "futures-sink", ] [[package]] -name = "pbkdf2" -version = "0.11.0" +name = "futures-core" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", -] +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] -name = "pbkdf2" -version = "0.12.2" +name = "futures-executor" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ - "digest", - "hmac", + "futures-core", + "futures-task", + "futures-util", + "num_cpus", ] [[package]] -name = "portable-atomic" -version = "1.7.0" +name = "futures-io" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] -name = "ppv-lite86" -version = "0.2.20" +name = "futures-macro" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "zerocopy", + "proc-macro2", + "quote", + "syn 2.0.74", ] [[package]] -name = "primitive-types" -version = "0.12.2" +name = "futures-sink" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "impl-codec", - "uint", -] +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] -name = "proc-macro-crate" -version = "3.1.0" +name = "futures-task" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" -dependencies = [ - "toml_edit", -] +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] -name = "proc-macro2" -version = "1.0.86" +name = "futures-util" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ - "unicode-ident", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", ] [[package]] -name = "pyo3" -version = "0.22.2" +name = "generic-array" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "cfg-if", - "indoc", + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "generic-array" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96512db27971c2c3eece70a1e106fbe6c87760234e31e8f7e5634912fe52794a" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom_or_panic" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" +dependencies = [ + "rand", + "rand_core", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[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 = "hash-db" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.7", + "hmac 0.8.1", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "js-sys" +version = "0.3.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "serdect", + "sha2 0.10.8", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.156" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5f43f184355eefb8d17fc948dbecf6c13be3c141f20d834ae842193a448c72a" + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory-db" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +dependencies = [ + "hash-db", +] + +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "parity-bip39" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e69bf016dc406eff7d53a7d3f7cf1c2e72c82b9088aac1118591e36dd2cd3e9" +dependencies = [ + "bitcoin_hashes 0.13.0", + "rand", + "rand_core", + "serde", + "unicode-normalization", +] + +[[package]] +name = "parity-scale-codec" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", + "password-hash", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "polkavm-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9428a5cfcc85c5d7b9fc4b6a18c4b802d0173d768182a51cc7751640f08b92" + +[[package]] +name = "polkavm-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" +dependencies = [ + "polkavm-derive-impl-macro", +] + +[[package]] +name = "polkavm-derive-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" +dependencies = [ + "polkavm-common", + "proc-macro2", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "polkavm-derive-impl-macro" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" +dependencies = [ + "polkavm-derive-impl", + "syn 2.0.74", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "portable-atomic" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.74", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "pyo3" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" +dependencies = [ + "cfg-if", + "indoc", "libc", "memoffset", "once_cell", @@ -493,233 +1743,837 @@ dependencies = [ ] [[package]] -name = "pyo3-build-config" -version = "0.22.2" +name = "pyo3-build-config" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" +dependencies = [ + "once_cell", + "target-lexicon", +] + +[[package]] +name = "pyo3-ffi" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" +dependencies = [ + "libc", + "pyo3-build-config", +] + +[[package]] +name = "pyo3-macros" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" +dependencies = [ + "proc-macro2", + "pyo3-macros-backend", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "pyo3-macros-backend" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" +dependencies = [ + "heck", + "proc-macro2", + "pyo3-build-config", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "ref-cast" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf0a6f84d5f1d581da8b41b47ec8600871962f2a528115b542b362d4b744931" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scale-info" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "schnellru" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9a8ef13a93c54d20580de1e5c413e624e53121d42fc7e2c11d10ef7f8b02367" +dependencies = [ + "ahash", + "cfg-if", + "hashbrown 0.13.2", +] + +[[package]] +name = "schnorrkel" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" +dependencies = [ + "aead", + "arrayref", + "arrayvec", + "curve25519-dalek", + "getrandom_or_panic", + "merlin", + "rand_core", + "serde_bytes", + "sha2 0.10.8", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "once_cell", - "target-lexicon", + "base16ct", + "der", + "generic-array 0.14.7", + "pkcs8", + "serdect", + "subtle", + "zeroize", ] [[package]] -name = "pyo3-ffi" -version = "0.22.2" +name = "secp256k1" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" +checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ - "libc", - "pyo3-build-config", + "secp256k1-sys 0.9.2", ] [[package]] -name = "pyo3-macros" -version = "0.22.2" +name = "secp256k1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ - "proc-macro2", - "pyo3-macros-backend", - "quote", - "syn 2.0.74", + "secp256k1-sys 0.10.0", ] [[package]] -name = "pyo3-macros-backend" -version = "0.22.2" +name = "secp256k1-sys" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" +checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.208" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ - "heck", "proc-macro2", - "pyo3-build-config", "quote", "syn 2.0.74", ] [[package]] -name = "quote" -version = "1.0.36" +name = "serde_json" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ - "proc-macro2", + "itoa", + "memchr", + "ryu", + "serde", ] [[package]] -name = "radium" -version = "0.7.0" +name = "serde_spanned" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] [[package]] -name = "rand" -version = "0.8.5" +name = "serdect" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" dependencies = [ - "libc", - "rand_chacha", - "rand_core", + "base16ct", + "serde", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "sha2" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ - "ppv-lite86", - "rand_core", + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "sha2" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ - "getrandom", + "cfg-if", + "cpufeatures", + "digest 0.10.7", ] [[package]] -name = "regex" -version = "1.10.6" +name = "sha3" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "digest 0.10.7", + "keccak", ] [[package]] -name = "regex-automata" -version = "0.4.7" +name = "sharded-slab" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "lazy_static", ] [[package]] -name = "regex-syntax" -version = "0.8.4" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] -name = "rustc-hash" -version = "1.1.0" +name = "signature" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core", +] [[package]] -name = "rustc-hex" -version = "2.1.0" +name = "simple-mermaid" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" +checksum = "620a1d43d70e142b1d46a929af51d44f383db9c7a2ec122de2cd992ccfcf3c18" [[package]] -name = "rustc_version" -version = "0.4.0" +name = "slab" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ - "semver", + "autocfg", ] [[package]] -name = "schnorrkel" -version = "0.11.4" +name = "smallvec" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "sp-application-crypto" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8133012faa5f75b2f0b1619d9f720c1424ac477152c143e5f7dbde2fe1a958" dependencies = [ - "aead", - "arrayref", - "arrayvec", - "curve25519-dalek", - "getrandom_or_panic", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", +] + +[[package]] +name = "sp-arithmetic" +version = "26.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46d0d0a4c591c421d3231ddd5e27d828618c24456d51445d21a1f79fcee97c23" +dependencies = [ + "docify", + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-core" +version = "34.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c961a5e33fb2962fa775c044ceba43df9c6f917e2c35d63bfe23738468fa76a7" +dependencies = [ + "array-bytes", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "itertools 0.11.0", + "k256", + "libsecp256k1", + "log", "merlin", - "rand_core", - "serde_bytes", - "sha2", - "subtle", + "parity-bip39", + "parity-scale-codec", + "parking_lot", + "paste", + "primitive-types", + "rand", + "scale-info", + "schnorrkel", + "secp256k1 0.28.2", + "secrecy", + "serde", + "sp-crypto-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tracing", + "w3f-bls", "zeroize", ] [[package]] -name = "secp256k1" -version = "0.29.0" +name = "sp-crypto-hashing" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc9927a7f81334ed5b8a98a4a978c81324d12bd9713ec76b5c68fd410174c5eb" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.8", + "sha3", + "twox-hash", +] + +[[package]] +name = "sp-debug-derive" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "sp-externalities" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a904407d61cb94228c71b55a9d3708e9d6558991f9e83bd42bd91df37a159d30" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-storage", +] + +[[package]] +name = "sp-io" +version = "38.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ef7eb561bb4839cc8424ce58c5ea236cbcca83f26fcc0426d8decfe8aa97d4" +dependencies = [ + "bytes", + "docify", + "ed25519-dalek", + "libsecp256k1", + "log", + "parity-scale-codec", + "polkavm-derive", + "rustversion", + "secp256k1 0.28.2", + "sp-core", + "sp-crypto-hashing", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-tracing", + "sp-trie", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0248b4d784cb4a01472276928977121fa39d977a5bb24793b6b15e64b046df42" +dependencies = [ + "parity-scale-codec", + "parking_lot", + "sp-core", + "sp-externalities", +] + +[[package]] +name = "sp-panic-handler" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8f5a17a0a11de029a8b811cb6e8b32ce7e02183cc04a3e965c383246798c416" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "39.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5641385c2cd8e2252aacf35e0aff2f236331dfaea8dc11c5a4ec6bb36544450" +dependencies = [ + "docify", + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "num-traits", + "parity-scale-codec", + "paste", + "rand", + "scale-info", + "serde", + "simple-mermaid", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-weights", + "tracing", +] + +[[package]] +name = "sp-runtime-interface" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985eb981f40c689c6a0012c937b68ed58dabb4341d06f2dfe4dfd5ed72fa4017" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "polkavm-derive", + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0195f32c628fee3ce1dfbbf2e7e52a30ea85f3589da9fe62a8b816d70fc06294" +dependencies = [ + "Inflector", + "expander", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "sp-state-machine" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +checksum = "930104d6ae882626e8880d9b1578da9300655d337a3ffb45e130c608b6c89660" dependencies = [ - "secp256k1-sys", + "hash-db", + "log", + "parity-scale-codec", + "parking_lot", + "rand", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-trie", + "thiserror", + "tracing", + "trie-db", ] [[package]] -name = "secp256k1-sys" -version = "0.10.0" +name = "sp-std" +version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +checksum = "12f8ee986414b0a9ad741776762f4083cd3a5128449b982a3919c4df36874834" + +[[package]] +name = "sp-storage" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99c82989b3a4979a7e1ad848aad9f5d0b4388f1f454cc131766526601ab9e8f8" dependencies = [ - "cc", + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", ] [[package]] -name = "semver" -version = "1.0.23" +name = "sp-tracing" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +checksum = "90b3decf116db9f1dfaf1f1597096b043d0e12c952d3bcdc018c6d6b77deec7e" +dependencies = [ + "parity-scale-codec", + "tracing", + "tracing-core", + "tracing-subscriber", +] [[package]] -name = "serde" -version = "1.0.208" +name = "sp-trie" +version = "37.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "6282aef9f4b6ecd95a67a45bcdb67a71f4a4155c09a53c10add4ffe823db18cd" dependencies = [ - "serde_derive", + "ahash", + "hash-db", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot", + "rand", + "scale-info", + "schnellru", + "sp-core", + "sp-externalities", + "thiserror", + "tracing", + "trie-db", + "trie-root", ] [[package]] -name = "serde_bytes" -version = "0.11.15" +name = "sp-wasm-interface" +version = "21.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +checksum = "3b04b919e150b4736d85089d49327eab65507deb1485eec929af69daa2278eb3" dependencies = [ - "serde", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", ] [[package]] -name = "serde_derive" -version = "1.0.208" +name = "sp-weights" +version = "31.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "93cdaf72a1dad537bbb130ba4d47307ebe5170405280ed1aa31fa712718a400e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.74", + "bounded-collections", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-debug-derive", ] [[package]] -name = "sha2" -version = "0.10.8" +name = "spki" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "base64ct", + "der", ] [[package]] -name = "shlex" -version = "1.3.0" +name = "ss58-registry" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "4743ce898933fbff7bbf414f497c459a782d496269644b3d650a398ae6a487ba" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] [[package]] name = "static_assertions" @@ -727,6 +2581,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "substrate-bip39" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca58ffd742f693dc13d69bdbb2e642ae239e0053f6aab3b104252892f856700a" +dependencies = [ + "hmac 0.12.1", + "pbkdf2", + "schnorrkel", + "sha2 0.10.8", + "zeroize", +] + [[package]] name = "subtle" version = "2.6.1" @@ -767,6 +2634,15 @@ version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.63" @@ -788,22 +2664,13 @@ dependencies = [ ] [[package]] -name = "tiny-bip39" -version = "1.0.0" +name = "thread_local" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" dependencies = [ - "anyhow", - "hmac", + "cfg-if", "once_cell", - "pbkdf2 0.11.0", - "rand", - "rustc-hash", - "sha2", - "thiserror", - "unicode-normalization", - "wasm-bindgen", - "zeroize", ] [[package]] @@ -821,11 +2688,26 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.20", +] + [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -835,7 +2717,129 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.6.18", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.74", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c992b4f40c234a074d48a757efeabb1a6be88af84c0c23f7ca158950cb0ae7f" +dependencies = [ + "hash-db", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" +dependencies = [ + "hash-db", +] + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.7", + "rand", + "static_assertions", ] [[package]] @@ -864,25 +2868,81 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" + [[package]] name = "unindent" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "w3f-bls" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5da5fa2c6afa2c9158eaa7cd9aee249765eb32b5fb0c63ad8b9e79336a47ec" +dependencies = [ + "ark-bls12-377", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-serialize-derive", + "arrayref", + "constcat", + "digest 0.10.7", + "rand", + "rand_chacha", + "rand_core", + "sha2 0.10.8", + "sha3", + "thiserror", + "zeroize", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -944,6 +3004,119 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "winnow" version = "0.5.40" @@ -953,6 +3126,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 91d0493..0212226 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,17 +9,24 @@ name = "btwallet" crate-type = ["cdylib"] [dependencies] +aes-gcm = "0.10.3" +argon2 = "0.5.3" base58 = "0.2.0" +bip39 = "2.0.0" blake2 = "0.10.6" generic-array = "1.1.0" hex = "0.4.3" hmac = "0.12.1" pbkdf2 = "0.12.2" primitive-types = "0.12.2" -pyo3 = "0.22.0" +pyo3 = { version = "0.22.0", features = ["extension-module"] } + +rand = "0.8.5" regex = "1.10.6" schnorrkel = "0.11.4" secp256k1 = "0.29.0" +serde = "1.0.208" sha2 = "0.10.8" -tiny-bip39 = "1.0.0" +sp-core = "34.0.0" +sp-runtime = "39.0.0" uint = "0.9.5" diff --git a/README.md b/README.md index 238348b..f7c28ea 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,23 @@ To use your own config, you can do it like this: from bittensor_wallet.config import Config config = Config() ``` + + +## Rust +# Rust Development + +To build and test the Rust components of the project, you can use the following commands: +* `maturin develop` - Builds the project. +* `cargo test` - Runs the tests. +* `cargo run` - Runs the project. +* `cargo doc --open` - Generates the documentation and opens it in the browser. +* `cargo fmt` - Formats the code. +* `cargo clippy` - Runs the linter. +* `cargo clippy --fix` - Fixes the code. + +## Using the Rust components in Python +* `import btwallet` + + + + diff --git a/src/key.rs b/src/key.rs deleted file mode 100644 index 94c49cb..0000000 --- a/src/key.rs +++ /dev/null @@ -1,77 +0,0 @@ -use pyo3::prelude::*; -use blake2::{Blake2b, Digest}; -use regex::Regex; - -const JUNCTION_ID_LEN: usize = 32; -const RE_JUNCTION: &str = r"(\/\/?)([^/]+)"; - -#[pyclass] -struct DeriveJunction { - #[pyo3(get, set)] - chain_code: Vec, - #[pyo3(get, set)] - is_hard: bool, -} - -#[pymethods] -impl DeriveJunction { - #[new] - fn new(chain_code: Vec, is_hard: bool) -> Self { - DeriveJunction { chain_code, is_hard } - } - - #[staticmethod] - fn from_derive_path(path: &str, is_hard: bool) -> PyResult { - if path.chars().all(char::is_numeric) { - let num = path.parse::().map_err(|e| PyErr::new::(e.to_string()))?; - let byte_length = ((num.bits() + 7) / 8) as usize; - let mut chain_code = num.to_le_bytes().to_vec(); - chain_code.resize(32, 0); - Ok(DeriveJunction { chain_code, is_hard }) - } else { - let mut hasher = Blake2b::new(); - hasher.update(path.as_bytes()); - let result = hasher.finalize(); - let chain_code = if path.len() > JUNCTION_ID_LEN { - result[..32].to_vec() - } else { - let mut padded = path.as_bytes().to_vec(); - padded.resize(32, 0); - padded - }; - Ok(DeriveJunction { chain_code, is_hard }) - } - } -} - -#[pyfunction] -fn extract_derive_path(derive_path: &str) -> PyResult> { - let re = Regex::new(RE_JUNCTION).unwrap(); - let mut junctions = Vec::new(); - let mut path_check = String::new(); - - for cap in re.captures_iter(derive_path) { - let path_separator = cap.get(1).unwrap().as_str(); - let path_value = cap.get(2).unwrap().as_str(); - path_check.push_str(path_separator); - path_check.push_str(path_value); - - let junction = DeriveJunction::from_derive_path(path_value, path_separator == "//")?; - junctions.push(junction); - } - - if path_check != derive_path { - return Err(PyErr::new::( - format!("Reconstructed path '{}' does not match input", path_check) - )); - } - - Ok(junctions) -} - -#[pymodule] -fn key(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_class::()?; - m.add_function(wrap_pyfunction!(extract_derive_path, m)?)?; - Ok(()) -} diff --git a/src/keypair.rs b/src/keypair.rs index 63123f8..ae84181 100644 --- a/src/keypair.rs +++ b/src/keypair.rs @@ -1,744 +1,260 @@ // External crates -use bip39::{Language, Mnemonic, MnemonicType}; -use hmac::Hmac; -use pbkdf2::pbkdf2; -use primitive_types::U256; -use pyo3::exceptions::PyValueError; -use pyo3::prelude::*; -use sha2::Sha512; - -// Internal modules -use crate::scalecodec::*; -use crate::sr25519::*; - -/// Represents a cryptographic keypair with associated metadata. -/// -/// This struct encapsulates various components of a cryptographic keypair, -/// including the public and private keys, as well as additional information -/// such as the cryptographic type, derivation path, and address format. -/// -/// # Fields -/// -/// * `crypto_type`: The type of cryptography used (e.g., 0 for Ed25519, 1 for SR25519). -/// * `seed_hex`: An optional hexadecimal representation of the seed used to generate the keypair. -/// * `derive_path`: An optional derivation path used to generate the keypair from a master key. -/// * `ss58_format`: An optional SS58 address format identifier. -/// * `public_key`: The public key as a vector of bytes. -/// * `ss58_address`: An optional SS58-encoded address derived from the public key. -/// * `private_key`: The private key as a vector of bytes. -/// * `mnemonic`: An optional mnemonic phrase used to generate the keypair. -#[pyclass] -pub struct Keypair { - #[pyo3(get, set)] - crypto_type: u8, - #[pyo3(get, set)] - seed_hex: Option, - #[pyo3(get, set)] - derive_path: Option, - #[pyo3(get, set)] - ss58_format: Option, - #[pyo3(get, set)] - public_key: Vec, - #[pyo3(get, set)] - ss58_address: Option, - #[pyo3(get, set)] - private_key: Vec, - #[pyo3(get, set)] - mnemonic: Option, -} - -/// Parses a derivation path string into a vector of u32 values. -/// -/// This function takes a BIP32 derivation path string and converts it into a vector of u32 values -/// that represent the path components. It supports both normal and hardened derivation. -/// -/// # Arguments -/// -/// * `str_derivation_path` - A string slice containing the derivation path. -/// -/// # Returns -/// -/// Returns a `PyResult>` containing the parsed derivation path components. -/// -/// # Errors -/// -/// This function will return an error if: -/// * The derivation path doesn't start with "m/". -/// * Any component of the path fails to parse as a u32. -/// -/// # Examples -/// -/// ``` -/// let path = "m/44'/60/0'/0"; -/// let parsed = parse_derivation_path(path).unwrap(); -/// assert_eq!(parsed, vec![2147483692, 60, 2147483648, 0]); -/// ``` -fn parse_derivation_path(str_derivation_path: &str) -> PyResult> { - if !str_derivation_path.starts_with("m/") { - return Err(PyErr::new::( - "Can't recognize derivation path. It should look like \"m/44'/60/0'/0\".", - )); - } +use bip39::{Language, Mnemonic}; +use rand::RngCore; +use schnorrkel::{ + derive::{ChainCode, Derivation}, + ExpansionMode, MiniSecretKey, +}; +use sp_core::{sr25519, Pair}; - let mut path = Vec::new(); - for component in str_derivation_path.trim_start_matches("m/").split('/') { - if component.ends_with('\'') { - let value = component.trim_end_matches('\'').parse::()?; - path.push(0x80000000 + value); // BIP32_PRIVDEV + int(i[:-1]) - } else { - path.push(component.parse::()?); - } - } - - Ok(path) -} - -/// Converts a BIP39 seed to a BIP32 master node. +/// Creates a new mnemonic phrase with the specified number of words. /// -/// This function takes a BIP39 seed and generates the master private key and chain code -/// for a BIP32 hierarchical deterministic wallet. +/// This function generates a random mnemonic phrase using the BIP39 standard. +/// The number of words in the mnemonic is determined by the `num_words` parameter. /// /// # Arguments /// -/// * `seed` - A byte slice containing the BIP39 seed. +/// * `num_words` - The number of words in the mnemonic phrase. Valid values are typically 12, 15, 18, 21, or 24. /// /// # Returns /// -/// A tuple containing two 32-byte arrays: -/// * The first array is the master private key. -/// * The second array is the master chain code. +/// * `Result` - A Result containing the generated Mnemonic if successful, or an error message if the operation fails. /// /// # Examples /// /// ``` -/// let seed = [0u8; 64]; // Example seed -/// let (master_key, master_chain_code) = bip39seed_to_bip32masternode(&seed); -/// assert_eq!(master_key.len(), 32); -/// assert_eq!(master_chain_code.len(), 32); +/// let mnemonic = create_mnemonic(12).expect("Failed to create mnemonic"); +/// println!("Generated mnemonic: {}", mnemonic.to_string()); /// ``` /// -/// # Note +/// # Errors /// -/// This function uses HMAC-SHA512 with the key "Bitcoin seed" as specified in the BIP32 standard. -fn bip39seed_to_bip32masternode(seed: &[u8]) -> ([u8; 32], [u8; 32]) { - use hmac::{Hmac, Mac}; - use sha2::Sha512; - - const BIP32_SEED_MODIFIER: &[u8] = b"Bitcoin seed"; - - let mut mac = - Hmac::::new_from_slice(BIP32_SEED_MODIFIER).expect("HMAC can take key of any size"); - mac.update(seed); - let result = mac.finalize().into_bytes(); - - let (key, chain_code) = result.split_at(32); - (key.try_into().unwrap(), chain_code.try_into().unwrap()) +/// This function will return an error if: +/// - The entropy generation fails +/// - The mnemonic creation from the generated entropy fails +pub fn create_mnemonic(num_words: u32) -> Result { + // Calculate the number of entropy bytes needed based on the number of words + let entropy_bytes = (num_words / 3) * 4; + let entropy_size = usize::try_from(entropy_bytes); + + // Generate random entropy + let mut entropy = vec![0u8; entropy_size.unwrap_or(0)]; + rand::thread_rng().fill_bytes(&mut entropy); + + // Create a new mnemonic from the generated entropy + let mnemonic = Mnemonic::from_entropy_in(Language::English, &entropy) + .map_err(|_| "Failed to create mnemonic")?; + + Ok(mnemonic) } -/// Derives a BIP32 child key from a parent key and chain code. -/// -/// This function implements the BIP32 key derivation algorithm to generate a child key -/// from a parent key and chain code. It supports both normal and hardened derivation. -/// -/// # Arguments -/// -/// * `parent_key` - A reference to a 32-byte array containing the parent private key. -/// * `parent_chain_code` - A reference to a 32-byte array containing the parent chain code. -/// * `i` - A 32-bit unsigned integer representing the child index. If the most significant bit -/// is set (i >= 2^31), it performs hardened derivation. -/// -/// # Returns -/// -/// A tuple containing two 32-byte arrays: -/// * The first array is the derived child private key. -/// * The second array is the derived child chain code. -/// -/// # Panics -/// -/// This function will panic if: -/// * The length of `parent_key` or `parent_chain_code` is not 32 bytes. -/// * The HMAC-SHA512 initialization fails (which should never happen with a 32-byte key). -/// -/// # Examples -/// -/// ``` -/// let parent_key = [0u8; 32]; -/// let parent_chain_code = [0u8; 32]; -/// let child_index = 0; -/// let (child_key, child_chain_code) = derive_bip32childkey(&parent_key, &parent_chain_code, child_index); -/// ``` -/// -/// # Note -/// -/// This function uses a loop to handle the edge case where the derived key is invalid. -/// In practice, this is extremely unlikely to occur, but the loop ensures compliance with the BIP32 specification. -fn derive_bip32childkey( - parent_key: &[u8; 32], - parent_chain_code: &[u8; 32], - i: u32, -) -> ([u8; 32], [u8; 32]) { - use hmac::{Hmac, Mac}; - use secp256k1::{PublicKey, Secp256k1}; - use sha2::Sha512; - - assert_eq!(parent_key.len(), 32); - assert_eq!(parent_chain_code.len(), 32); - - let k = parent_chain_code; - let key = if (i & 0x80000000) != 0 { - let mut key = [0u8; 33]; - key[1..].copy_from_slice(parent_key); - key - } else { - let secp = Secp256k1::new(); - let public_key = PublicKey::from_secret_key( - &secp, - &secp256k1::SecretKey::from_slice(parent_key).unwrap(), - ); - public_key.serialize() - }; - - let mut d = Vec::with_capacity(key.len() + 4); - d.extend_from_slice(&key); - d.extend_from_slice(&i.to_be_bytes()); - - loop { - let mut mac = Hmac::::new_from_slice(k).expect("HMAC can take key of any size"); - mac.update(&d); - let h = mac.finalize().into_bytes(); - - let (key, chain_code) = h.split_at(32); - let a = U256::from_big_endian(key); - let b = U256::from_big_endian(parent_key); - let key = (a + b) % U256::from(secp256k1::constants::CURVE_ORDER); - - if a < U256::from(secp256k1::constants::CURVE_ORDER) && key != U256::zero() { - let mut key_bytes = [0u8; 32]; - key.to_big_endian(&mut key_bytes); - return (key_bytes, chain_code.try_into().unwrap()); - } - - d = vec![0x01]; - d.extend_from_slice(&h[32..]); - d.extend_from_slice(&i.to_be_bytes()); +fn derive_sr25519_key(seed: &[u8], path: &[u8]) -> Result { + // Ensure the seed is the correct length + let seed_len = seed.len(); + if seed_len != 32 { + return Err(format!( + "Invalid seed length: expected 32, got {}", + seed_len + )); } -} - -/// Converts a mnemonic phrase to a BIP39 seed. -/// -/// This function takes a mnemonic phrase and an optional passphrase to generate -/// a 64-byte BIP39 seed using PBKDF2 with HMAC-SHA512. -/// -/// # Arguments -/// -/// * `mnemonic` - A string slice containing the mnemonic phrase. -/// * `passphrase` - A string slice containing an optional passphrase for additional security. -/// -/// # Returns -/// -/// A 64-byte array containing the generated BIP39 seed. -/// -/// # Examples -/// -/// ``` -/// let mnemonic = "toward also shift move pet nuclear strike book outdoor pilot afford allow"; -/// let passphrase = "some password"; -/// let seed = mnemonic_to_bip39seed(mnemonic, passphrase); -/// assert_eq!(seed.len(), 64); -/// ``` -fn mnemonic_to_bip39seed(mnemonic: &str, passphrase: &str) -> [u8; 64] { - const BIP39_SALT_MODIFIER: &str = "mnemonic"; - const BIP39_PBKDF2_ROUNDS: u32 = 2048; - - let mnemonic = mnemonic.as_bytes(); - let salt = format!("{}{}", BIP39_SALT_MODIFIER, passphrase); - - let mut seed = [0u8; 64]; - pbkdf2::>(mnemonic, salt.as_bytes(), BIP39_PBKDF2_ROUNDS, &mut seed); - - seed -} - -/// Converts a BIP39 mnemonic phrase to a mini secret key. -/// -/// This function takes a BIP39 mnemonic phrase, a password, and an optional language code, -/// and generates a 32-byte mini secret key. -/// -/// # Arguments -/// -/// * `phrase` - A string slice containing the BIP39 mnemonic phrase. -/// * `password` - A string slice containing the password (can be empty). -/// * `language_code` - An optional string slice specifying the language code of the mnemonic. -/// Defaults to "en" (English) if not provided. -/// -/// # Returns -/// -/// Returns a `PyResult>` containing the 32-byte mini secret key. -/// -/// # Errors -/// -/// This function will return an error if: -/// * An invalid language code is provided. -/// * The mnemonic phrase is invalid. -/// -/// # Examples -/// -/// ``` -/// let phrase = "toward also shift move pet nuclear strike book outdoor pilot afford allow"; -/// let password = ""; -/// let mini_secret = bip39_to_mini_secret(phrase, password, None).unwrap(); -/// assert_eq!(mini_secret.len(), 32); -/// ``` -pub fn bip39_to_mini_secret( - phrase: &str, - password: &str, - language_code: Option<&str>, -) -> PyResult> { - let salt = format!("mnemonic{}", password); - - let language = match Language::from_language_code(language_code.unwrap_or("en")) { - Some(language) => language, - None => return Err(PyValueError::new_err("Invalid language_code")), - }; - - let mnemonic = match Mnemonic::from_phrase(phrase, language) { - Ok(some_mnemomic) => some_mnemomic, - Err(err) => { - return Err(PyValueError::new_err(format!( - "Invalid mnemonic: {}", - err.to_string() - ))) - } - }; - let mut result = [0u8; 64]; - pbkdf2::>(mnemonic.entropy(), salt.as_bytes(), 2048, &mut result); + // Create the initial mini secret key from the seed + let mini_secret_key = + MiniSecretKey::from_bytes(seed).expect("Failed to create mini secret key"); + + // Convert to a secret key and derive the initial key pair + let mut secret_key = mini_secret_key.expand(ExpansionMode::Ed25519); + let mut pair = sr25519::Pair::from_seed_slice(&secret_key.to_bytes()[..32]) + .expect("Failed to derive sr25519 key"); + + // Initialize the chain code + let mut chain_code = ChainCode(seed.try_into().expect("Failed to create seed")); + + // Iteratively derive the key pair using the path + for junction in path { + let (derived_key, next_chain_code) = secret_key.derived_key_simple(chain_code, [*junction]); + secret_key = derived_key; + pair = sr25519::Pair::from_seed_slice(&secret_key.to_bytes()[..32]) + .expect("Failed to derive sr25519 key"); + chain_code = next_chain_code; + } - Ok(result[..32].to_vec()) + Ok(pair) } -/// Generates a new mnemonic phrase. +/// Creates a new hotkey pair from a mnemonic phrase and name. /// -/// This function creates a new mnemonic phrase with the specified number of words. -/// If no word count is provided, it defaults to 12 words. +/// This function generates a new sr25519 key pair (hotkey) using the provided mnemonic and +/// a name for derivation. /// /// # Arguments /// -/// * `words` - An optional `u32` specifying the number of words in the mnemonic. -/// Valid values are 12, 15, 18, 21, or 24. Defaults to 12 if not provided. +/// * `mnemonic` - A `Mnemonic` object representing the seed phrase. +/// * `name` - A string slice used to create the derivation path. /// /// # Returns /// -/// Returns a `PyResult` containing the generated mnemonic phrase. -/// -/// # Errors -/// -/// This function will return an error if: -/// * An invalid number of words is provided (not 12, 15, 18, 21, or 24). -/// -/// # Examples -/// -/// ``` -/// let mnemonic = generate_mnemonic(None).unwrap(); -/// assert_eq!(mnemonic.split_whitespace().count(), 12); +/// Returns an `sr25519::Pair` representing the derived hotkey pair. /// -/// let mnemonic = generate_mnemonic(Some(24)).unwrap(); -/// assert_eq!(mnemonic.split_whitespace().count(), 24); -/// ``` -fn generate_mnemonic(words: Option) -> PyResult { - let words = words.unwrap_or(12); - - let mnemonic_type = match words { - 12 => MnemonicType::Words12, - 15 => MnemonicType::Words15, - 18 => MnemonicType::Words18, - 21 => MnemonicType::Words21, - 24 => MnemonicType::Words24, - _ => { - return Err(PyErr::new::( - "Invalid number of words. Must be 12, 15, 18, 21, or 24.", - )) - } - }; - let mnemonic = Mnemonic::new(mnemonic_type, Language::English); - - Ok(mnemonic.to_string()) -} - -/// Validates a mnemonic phrase. -/// -/// # Arguments -/// -/// * `mnemonic` - A string slice containing the mnemonic phrase to validate. -/// * `language_code` - An optional `String` specifying the language code of the mnemonic. -/// Defaults to "en" (English) if not provided. -/// -/// # Returns -/// -/// Returns a `PyResult` indicating whether the mnemonic is valid. -/// -/// # Errors +/// # Panics /// -/// This function will return an error if: -/// * An unsupported language code is provided. +/// This function will panic if: +/// - The seed creation from the mnemonic fails. +/// - The key derivation process fails. /// /// # Examples /// /// ``` -/// let mnemonic = "toward also shift move pet nuclear strike book outdoor pilot afford allow"; -/// let is_valid = validate_mnemonic(mnemonic, None).unwrap(); -/// assert!(is_valid); +/// use bip39::Mnemonic; +/// let mnemonic = Mnemonic::from_phrase("your mnemonic phrase here", Language::English).unwrap(); +/// let hotkey = create_hotkey(mnemonic, "my_hotkey"); /// ``` -fn validate_mnemonic(mnemonic: &str, language_code: Option) -> PyResult { - let language_code = language_code.unwrap_or_else(|| String::from("en")); - - let language = match language_code.as_str() { - "en" => Language::English, - _ => { - return Err(PyErr::new::( - "Unsupported language code", - )) - } - }; +pub fn create_hotkey(mnemonic: Mnemonic, name: &str) -> sr25519::Pair { + let seed: [u8; 32] = mnemonic.to_seed("")[..32] + .try_into() + .expect("Failed to create seed"); - let is_valid = Mnemonic::from_phrase(mnemonic, language).is_ok(); - Ok(is_valid) -} + let derivation_path: Vec = format!("//{}", name).into_bytes(); -/// Creates a new `Keypair` from a mnemonic phrase. -/// -/// # Arguments -/// -/// * `mnemonic` - A string slice containing the mnemonic phrase. -/// * `ss58_format` - An optional SS58 format. Defaults to 42 if not provided. -/// * `crypto_type` - An optional crypto type. Defaults to 1 (SR25519) if not provided. -/// * `language_code` - An optional language code for the mnemonic. Defaults to "en" (English) if not provided. -/// -/// # Returns -/// -/// Returns a `PyResult` containing the created keypair if successful, or a Python error if an error occurs. -/// -/// # Errors -/// -/// This function will return an error if: -/// * The mnemonic is invalid. -/// * The seed generation fails. -/// * The keypair creation from the seed fails. -fn create_from_mnemonic( - mnemonic: &str, - ss58_format: Option, - crypto_type: Option, - language_code: Option, -) -> PyResult { - let ss58_format = ss58_format.unwrap_or(42); - let crypto_type = crypto_type.unwrap_or(1); // Default to SR25519 - - // Default to English if language_code is None - let language_code = language_code.as_deref().unwrap_or("en"); - - let seed_array = bip39_to_mini_secret(mnemonic, "", Some(language_code))?; - let seed_hex = hex::encode(&seed_array); - let mut keypair = create_from_seed(&seed_hex, Some(ss58_format), Some(crypto_type))?; - keypair.mnemonic = Some(mnemonic.to_string()); - Ok(keypair) -} + let hotkey_pair: sr25519::Pair = + derive_sr25519_key(&seed, &derivation_path).expect("Failed to derive sr25519 key"); -/// Creates a new `Keypair` from a seed. -/// -/// # Arguments -/// -/// * `seed_hex` - A hexadecimal string representing the seed. -/// * `ss58_format` - An optional SS58 format. Defaults to 42 if not provided. -/// * `crypto_type` - An optional crypto type. Defaults to 1 (SR25519) if not provided. -/// -/// # Returns -/// -/// Returns a `PyResult` containing the created keypair if successful, or a Python error if an error occurs. -/// -/// # Errors -/// -/// This function will return an error if: -/// * The seed hex is invalid. -/// * The seed bytes cannot be converted to a `Seed`. -/// * An unsupported crypto type is provided. -/// * ED25519 is requested (currently not implemented). -fn create_from_seed( - seed_hex: &str, - ss58_format: Option, - crypto_type: Option, -) -> PyResult { - let ss58_format = ss58_format.unwrap_or(42); - let crypto_type = crypto_type.unwrap_or(1); // Default to SR25519 - - let seed_bytes = hex::decode(seed_hex.trim_start_matches("0x")).map_err(|e| { - PyErr::new::(format!("Invalid hex in seed: {}", e)) - })?; - let seed = Seed::from_bytes(&seed_bytes).map_err(|e| PyValueError::new_err(e))?; - - let (public_key, private_key) = if crypto_type == 1 { - // SR25519 - let Keypair(public_key, private_key) = pair_from_seed(seed); - (public_key, private_key) - } else if crypto_type == 0 { - // ED25519 - // TODO: Implement ed25519_zebra.ed_from_seed - // Placeholder: return an error for now - return Err(PyErr::new::( - "ED25519 not yet implemented", - )); - } else { - return Err(PyErr::new::(format!( - "crypto_type '{}' not supported", - crypto_type - ))); - }; - - let pub_key = PubKey(public_key); - let ss58_address = ss58_encode(&pub_key, ss58_format); - - let keypair = Keypair { - ss58_address: Some(ss58_address), - public_key: pub_key.0.to_vec(), - private_key: private_key.to_vec(), - ss58_format: Some(ss58_format), - crypto_type, - seed_hex: Some(seed_hex.to_string()), - mnemonic: None, - derive_path: None, - }; - - Ok(keypair) + hotkey_pair } #[cfg(test)] mod tests { use super::*; - use hex_literal::hex; + use bip39::{Language, Mnemonic}; + use rand::Rng; #[test] - fn test_parse_derivation_path_valid() { - let path = "m/44'/60/0'/0"; - let result = parse_derivation_path(path).unwrap(); - assert_eq!(result, vec![2147483692, 60, 2147483648, 0]); + fn test_create_mnemonic_valid_word_counts() { + let valid_word_counts = [12, 15, 18, 21, 24]; + for &word_count in &valid_word_counts { + let result = create_mnemonic(word_count); + assert!( + result.is_ok(), + "Failed to create mnemonic with {} words", + word_count + ); + let mnemonic = result.unwrap(); + assert_eq!( + mnemonic.word_count(), + word_count as usize, + "Mnemonic word count doesn't match expected" + ); + } } #[test] - fn test_parse_derivation_path_invalid_start() { - let path = "44'/60/0'/0"; - let result = parse_derivation_path(path); - assert!(result.is_err()); + fn test_mnemonic_uniqueness() { + let mnemonic1 = create_mnemonic(12).unwrap(); + let mnemonic2 = create_mnemonic(12).unwrap(); + assert_ne!( + mnemonic1.to_string(), + mnemonic2.to_string(), + "Two generated mnemonics should not be identical" + ); } #[test] - fn test_parse_derivation_path_mixed() { - let path = "m/44'/60/0/1'"; - let result = parse_derivation_path(path).unwrap(); - assert_eq!(result, vec![2147483692, 60, 0, 2147483649]); + fn test_mnemonic_language() { + let mnemonic = create_mnemonic(12).unwrap(); + assert_eq!( + mnemonic.language(), + Language::English, + "Mnemonic should be in English" + ); } - #[test] - fn test_parse_derivation_path_invalid_component() { - let path = "m/44'/60/invalid/0"; - let result = parse_derivation_path(path); - assert!(result.is_err()); - } + fn test_create_hotkey() { + let mnemonic = Mnemonic::parse_in_normalized( + Language::English, + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" + ).unwrap(); + let name = "test_hotkey"; - #[test] - fn test_bip39seed_to_bip32masternode() { - // Test vector from BIP32 specification - let seed = hex!("000102030405060708090a0b0c0d0e0f"); - let expected_master_key = - hex!("e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35"); - let expected_chain_code = - hex!("873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508"); - - let (master_key, chain_code) = bip39seed_to_bip32masternode(&seed); - - assert_eq!(master_key, expected_master_key); - assert_eq!(chain_code, expected_chain_code); - } + let hotkey = create_hotkey(mnemonic.clone(), name); - #[test] - fn test_bip39seed_to_bip32masternode_different_seeds() { - let seed1 = [0u8; 64]; - let seed2 = [1u8; 64]; + // Check that the hotkey is not empty + assert!(!hotkey.public().0.is_empty()); - let (master_key1, chain_code1) = bip39seed_to_bip32masternode(&seed1); - let (master_key2, chain_code2) = bip39seed_to_bip32masternode(&seed2); + // Check that creating the same hotkey twice produces the same result + let hotkey2 = create_hotkey(mnemonic.clone(), name); + assert_eq!(hotkey.public(), hotkey2.public()); - assert_ne!(master_key1, master_key2); - assert_ne!(chain_code1, chain_code2); + // Check that different names produce different hotkeys + let hotkey3 = create_hotkey(mnemonic, "different_name"); + assert_ne!(hotkey.public(), hotkey3.public()); } #[test] - fn test_derive_bip32childkey_normal() { - let parent_key = [1u8; 32]; - let parent_chain_code = [2u8; 32]; - let child_index = 0; - - let (child_key, child_chain_code) = - derive_bip32childkey(&parent_key, &parent_chain_code, child_index); - - assert_eq!(child_key.len(), 32); - assert_eq!(child_chain_code.len(), 32); - assert_ne!(child_key, parent_key); - assert_ne!(child_chain_code, parent_chain_code); + fn test_create_hotkey_different_mnemonics() { + let mnemonic1 = Mnemonic::parse_in_normalized( + Language::English, + "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about", + ).unwrap(); + let mnemonic2 = Mnemonic::parse_in_normalized( + Language::English, + "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong", + ) + .expect("Invalid mnemonic phrase"); + let name = "test_hotkey"; + + let hotkey1 = create_hotkey(mnemonic1, name); + let hotkey2 = create_hotkey(mnemonic2, name); + + // Check that different mnemonics produce different hotkeys + assert_ne!(hotkey1.public(), hotkey2.public()); } #[test] - fn test_derive_bip32childkey_hardened() { - let parent_key = [3u8; 32]; - let parent_chain_code = [4u8; 32]; - let child_index = 0x80000000; // Hardened derivation - - let (child_key, child_chain_code) = - derive_bip32childkey(&parent_key, &parent_chain_code, child_index); - - assert_eq!(child_key.len(), 32); - assert_eq!(child_chain_code.len(), 32); - assert_ne!(child_key, parent_key); - assert_ne!(child_chain_code, parent_chain_code); - } + fn test_derive_sr25519_key_valid_input() { + let mut rng = rand::thread_rng(); + let seed: [u8; 32] = rng.gen(); + let path = b"/some/path"; - #[test] - fn test_derive_bip32childkey_different_indexes() { - let parent_key = [5u8; 32]; - let parent_chain_code = [6u8; 32]; - let child_index_1 = 1; - let child_index_2 = 2; - - let (child_key_1, child_chain_code_1) = - derive_bip32childkey(&parent_key, &parent_chain_code, child_index_1); - let (child_key_2, child_chain_code_2) = - derive_bip32childkey(&parent_key, &parent_chain_code, child_index_2); - - assert_ne!(child_key_1, child_key_2); - assert_ne!(child_chain_code_1, child_chain_code_2); + let result = derive_sr25519_key(&seed, path); + assert!(result.is_ok()); } #[test] - fn test_mnemonic_to_bip39seed() { - let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; - let passphrase = "TREZOR"; - - let expected_seed = [ - 0xc5, 0x52, 0x57, 0xc3, 0x60, 0xc0, 0x7c, 0x72, 0x55, 0x16, 0xc5, 0xba, 0x49, 0x8a, - 0xb8, 0x4a, 0xe8, 0xb6, 0x1e, 0xab, 0x45, 0x85, 0x97, 0x16, 0x4b, 0xf4, 0x42, 0x08, - 0x8c, 0x70, 0x32, 0x98, 0x1b, 0x9c, 0x5d, 0xb6, 0xc3, 0x9b, 0xbf, 0x0d, 0x75, 0x8d, - 0x6b, 0x68, 0x53, 0x3e, 0xc4, 0x10, 0x5d, 0x72, 0xc5, 0x18, 0x36, 0x83, 0xaf, 0x2c, - 0x0a, 0x5f, 0x67, 0x58, 0x9d, 0x13, 0xc8, 0x4e, - ]; - - let result = mnemonic_to_bip39seed(mnemonic, passphrase); - assert_eq!(result, expected_seed); - } - #[test] - fn test_bip39_to_mini_secret() { - let phrase = "toward also shift move pet nuclear strike book outdoor pilot afford allow"; - let password = ""; - let mini_secret = bip39_to_mini_secret(phrase, password, None).unwrap(); - assert_eq!(mini_secret.len(), 32); - - // Test with a different language - let phrase_fr = "abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser abaisser aboyer"; - let mini_secret_fr = bip39_to_mini_secret(phrase_fr, password, Some("fr")).unwrap(); - assert_eq!(mini_secret_fr.len(), 32); - - // Test with an invalid mnemonic - let invalid_phrase = "invalid mnemonic phrase"; - assert!(bip39_to_mini_secret(invalid_phrase, password, None).is_err()); - - // Test with an invalid language code - assert!(bip39_to_mini_secret(phrase, password, Some("invalid")).is_err()); - } - #[test] - fn test_generate_mnemonic() { - // Test default case (12 words) - let mnemonic = generate_mnemonic(None).unwrap(); - assert_eq!(mnemonic.split_whitespace().count(), 12); - - // Test all valid word counts - for &words in &[12, 15, 18, 21, 24] { - let mnemonic = generate_mnemonic(Some(words)).unwrap(); - assert_eq!(mnemonic.split_whitespace().count(), words as usize); - } + fn test_derive_sr25519_key_invalid_seed_length() { + let seed = [0u8; 16]; // Invalid length + let path = b"/some/path"; - // Test invalid word count - assert!(generate_mnemonic(Some(16)).is_err()); - } - #[test] - fn test_validate_mnemonic() { - let valid_mnemonic = - "toward also shift move pet nuclear strike book outdoor pilot afford allow"; - assert!(validate_mnemonic(valid_mnemonic, None).unwrap()); - - let invalid_mnemonic = "invalid mnemonic phrase"; - assert!(!validate_mnemonic(invalid_mnemonic, None).unwrap()); - - let valid_mnemonic_es = - "ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco ábaco abogado"; - assert!(validate_mnemonic(valid_mnemonic_es, Some("es".to_string())).is_err()); - - let result = validate_mnemonic(valid_mnemonic, Some("invalid_language".to_string())); + let result = derive_sr25519_key(&seed, path); assert!(result.is_err()); - } - #[test] - fn test_create_from_mnemonic() { - let mnemonic = "toward also shift move pet nuclear strike book outdoor pilot afford allow"; - let result = create_from_mnemonic(mnemonic, None, None, None); - assert!(result.is_ok()); - - let keypair = result.unwrap(); - assert_eq!(keypair.ss58_format, Some(42)); - assert_eq!(keypair.crypto_type, 1); - assert_eq!(keypair.mnemonic, Some(mnemonic.to_string())); - assert!(keypair.seed_hex.is_some()); - assert!(!keypair.public_key.is_empty()); - assert!(!keypair.private_key.is_empty()); - assert!(keypair.ss58_address.is_some()); - } - #[test] - fn test_create_from_seed_valid() { - let seed_hex = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; - let result = create_from_seed(seed_hex, None, None); - assert!(result.is_ok()); - let keypair = result.unwrap(); - assert_eq!(keypair.ss58_format, Some(42)); - assert_eq!(keypair.crypto_type, 1); - assert_eq!(keypair.seed_hex, Some(seed_hex.to_string())); + let err = result.err().unwrap(); + assert!(err + .to_string() + .contains("Invalid seed length: expected 32, got 16")); } #[test] - fn test_create_from_seed_invalid_hex() { - let seed_hex = "invalid_hex"; - let result = create_from_seed(seed_hex, None, None); - assert!(result.is_err()); - } + fn test_derive_sr25519_key_empty_path() { + let mut rng = rand::thread_rng(); + let seed: [u8; 32] = rng.gen(); + let path = b""; - #[test] - fn test_create_from_seed_custom_ss58_format() { - let seed_hex = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; - let result = create_from_seed(seed_hex, Some(2), None); + let result = derive_sr25519_key(&seed, path); assert!(result.is_ok()); - let keypair = result.unwrap(); - assert_eq!(keypair.ss58_format, Some(2)); } #[test] - fn test_create_from_seed_unsupported_crypto_type() { - let seed_hex = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; - let result = create_from_seed(seed_hex, None, Some(2)); - assert!(result.is_err()); - } - - #[test] - fn test_create_from_seed_ed25519() { - let seed_hex = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; - let result = create_from_seed(seed_hex, None, Some(0)); - assert!(result.is_err()); - assert!(result - .unwrap_err() - .to_string() - .contains("ED25519 not yet implemented")); + fn test_derive_sr25519_key_deterministic() { + let seed: [u8; 32] = [42u8; 32]; + let path = b"/test/path"; + + let result1 = derive_sr25519_key(&seed, path); + let result2 = derive_sr25519_key(&seed, path); + + assert!(result1.is_ok() && result2.is_ok()); + assert_eq!( + result1.unwrap().public(), + result2.unwrap().public(), + "Derived keys should be identical for the same seed and path" + ); } } diff --git a/src/lib.rs b/src/lib.rs index ccf13b0..9ffc6b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,54 +1,60 @@ -use bip39::{Language, Mnemonic, MnemonicType}; use pyo3::prelude::*; mod keypair; -pub mod scalecodec; -pub mod sr25519; use crate::keypair::*; - -#[pyfunction] -#[pyo3(signature = (mnemonic, language_code=None))] -fn validate_mnemonic(mnemonic: &str, language_code: Option) -> PyResult { - let language_code = language_code.unwrap_or_else(|| String::from("en")); - - let language = match language_code.as_str() { - "en" => Language::English, - _ => { - return Err(PyErr::new::( - "Unsupported language code", - )) - } - }; - - let is_valid = Mnemonic::from_phrase(mnemonic, language).is_ok(); - Ok(is_valid) -} - +use sp_core::Pair; + +/// Creates a new hotkey pair and demonstrates its functionality. +/// +/// This function performs the following steps: +/// 1. Generates a mnemonic phrase. +/// 2. Creates a new hotkey pair using the mnemonic. +/// 3. Signs a test message with the hotkey. +/// 4. Verifies the signature. +/// 5. Returns the public key of the hotkey as a string. +/// +/// # Returns +/// +/// Returns a `PyResult` containing the public key of the created hotkey. +/// +/// # Errors +/// +/// This function will return an error if: +/// - The mnemonic creation fails. +/// - Any of the cryptographic operations fail. #[pyfunction] -fn generate_mnemonic(num_words: u32) -> PyResult { - let mnemonic_type = match num_words { - 12 => MnemonicType::Words12, - 15 => MnemonicType::Words15, - 18 => MnemonicType::Words18, - 21 => MnemonicType::Words21, - 24 => MnemonicType::Words24, - _ => { - return Err(PyErr::new::( - "Invalid number of words. Must be 12, 15, 18, 21, or 24.", - )) - } - }; - let mnemonic = Mnemonic::new(mnemonic_type, Language::English); - Ok(mnemonic.to_string()) +fn create_hotkey_pub() -> PyResult { + // Create a new mnemonic with 12 words + let mnemonic = create_mnemonic(12).expect("Failed to create mnemonic"); + println!("mnemonic: {:?}", mnemonic.to_string()); + + // Create a hotkey pair using the mnemonic and a name. + let hotkey_pair = create_hotkey(mnemonic, "name"); + println!("Hotkey pair: {:?}", hotkey_pair.public()); + + // Test message + let message = b"Hello, Opentensor!"; + + // Sign the message using the hotkey pair + let signature = hotkey_pair.sign(message); + println!("Message: {:?}", String::from_utf8_lossy(message)); + println!("Signature: {:?}", signature); + + // Verify the signature + let is_valid = sp_core::sr25519::Pair::verify(&signature, message, &hotkey_pair.public()); + println!("Is signature valid? {}", is_valid); + + // Extract the public key from the hotkey pair + let pub_key = hotkey_pair.public(); + // Return the public key as a string + Ok(pub_key.to_string()) } /// A Python module implemented in Rust. #[pymodule] fn btwallet(m: &Bound<'_, PyModule>) -> PyResult<()> { - m.add_function(wrap_pyfunction!(generate_mnemonic, m)?)?; - m.add_function(wrap_pyfunction!(validate_mnemonic, m)?)?; - m.add_class::()?; + m.add_function(wrap_pyfunction!(create_hotkey_pub, m)?)?; Ok(()) } diff --git a/src/scalecodec.rs b/src/scalecodec.rs deleted file mode 100644 index d5599db..0000000 --- a/src/scalecodec.rs +++ /dev/null @@ -1,99 +0,0 @@ -use base58::ToBase58; -use blake2::{Blake2b, Digest}; -use generic_array::typenum::U64; -use generic_array::GenericArray; - -use crate::sr25519::PubKey; - -/// Encodes a public key into an SS58 address format. -/// -/// # Arguments -/// -/// * `address` - A reference to a `PubKey` containing the public key to encode. -/// * `ss58_format` - A u16 value representing the SS58 format to use. -/// -/// # Returns -/// -/// A `String` containing the SS58-encoded address. -/// -/// # Errors -/// -/// Returns an error string if: -/// - The `ss58_format` is invalid (> 16383 or == 46 or == 47) -/// - The address length is invalid -pub fn ss58_encode(address: &PubKey, ss58_format: u16) -> String { - let checksum_prefix = b"SS58PRE"; - - if ss58_format > 16383 || ss58_format == 46 || ss58_format == 47 { - return "Invalid value for ss58_format".to_string(); - } - - let address_bytes = address; - let checksum_length = match address_bytes.0.len() { - 32 | 33 => 2, - 1 | 2 | 4 | 8 => 1, - _ => return "Invalid length for address".to_string(), - }; - - let ss58_format_bytes = if ss58_format < 64 { - vec![ss58_format as u8] - } else { - vec![ - ((ss58_format & 0b0000_0000_1111_1100) >> 2) as u8 | 0b0100_0000, - ((ss58_format >> 8) | ((ss58_format & 0b0000_0000_0000_0011) << 6)) as u8, - ] - }; - - let mut input_bytes = ss58_format_bytes; - input_bytes.extend_from_slice(address.as_bytes()); - - let mut hasher = Blake2b::new(); - hasher.update(checksum_prefix); - hasher.update(&input_bytes); - let checksum: GenericArray = hasher.finalize(); - - input_bytes.extend_from_slice(&checksum[..checksum_length]); - - input_bytes.to_base58() -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_ss58_encode_valid() { - let pubkey = PubKey([1u8; 32]); - let ss58_format = 42; // Substrate - let result = ss58_encode(&pubkey, ss58_format); - assert!(!result.is_empty()); - assert_ne!(result, "Invalid value for ss58_format"); - assert_ne!(result, "Invalid length for address"); - } - - #[test] - fn test_ss58_encode_invalid_format() { - let pubkey = PubKey([1u8; 32]); - let ss58_format = 16384; // Invalid - let result = ss58_encode(&pubkey, ss58_format); - assert_eq!(result, "Invalid value for ss58_format"); - } - - #[test] - fn test_ss58_encode_invalid_address_length() { - let pubkey = PubKey([1u8; 31]); // Invalid length - let ss58_format = 42; - let result = ss58_encode(&pubkey, ss58_format); - assert_eq!(result, "Invalid length for address"); - } - - #[test] - fn test_ss58_encode_different_formats() { - let pubkey = PubKey([1u8; 32]); - let format1 = 0; - let format2 = 42; - let result1 = ss58_encode(&pubkey, format1); - let result2 = ss58_encode(&pubkey, format2); - assert_ne!(result1, result2); - } -} diff --git a/src/sr25519.rs b/src/sr25519.rs deleted file mode 100644 index 1289d5e..0000000 --- a/src/sr25519.rs +++ /dev/null @@ -1,97 +0,0 @@ -use schnorrkel::keys::{ExpansionMode, MiniSecretKey}; -use schnorrkel::{MINI_SECRET_KEY_LENGTH, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH}; - -/// Represents a keypair containing a public key and a secret key. -pub struct Keypair(pub [u8; PUBLIC_KEY_LENGTH], pub [u8; SECRET_KEY_LENGTH]); - -/// Represents a seed used for key generation. -pub struct Seed([u8; MINI_SECRET_KEY_LENGTH]); - -/// Represents a private key. -pub struct PrivKey(pub [u8; SECRET_KEY_LENGTH]); - -/// Represents a public key. -pub struct PubKey(pub [u8; PUBLIC_KEY_LENGTH]); - -impl Seed { - /// Creates a new Seed from a byte slice. - /// - /// # Arguments - /// - /// * `bytes` - A slice of bytes to create the seed from. - /// - /// # Returns - /// - /// * `Result` - A Result containing the Seed if successful, or an error message if the input is invalid. - pub fn from_bytes(bytes: &[u8]) -> Result { - if bytes.len() != MINI_SECRET_KEY_LENGTH { - return Err("Invalid seed length"); - } - let mut arr = [0u8; MINI_SECRET_KEY_LENGTH]; - arr.copy_from_slice(bytes); - Ok(Seed(arr)) - } -} - -impl PubKey { - /// Returns the public key as a byte slice. - /// - /// # Returns - /// - /// * `&[u8]` - A slice of bytes representing the public key. - pub fn as_bytes(&self) -> &[u8] { - &self.0 - } -} - -/// Generates a keypair from a seed. -/// -/// # Arguments -/// -/// * `seed` - A Seed struct to generate the keypair from. -/// -/// # Returns -/// -/// * `Keypair` - A Keypair struct containing the generated public and secret keys. -pub fn pair_from_seed(seed: Seed) -> Keypair { - let k = MiniSecretKey::from_bytes(&seed.0).expect("32 bytes can always build a key; qed"); - let kp = k.expand_to_keypair(ExpansionMode::Ed25519); - - Keypair(kp.public.to_bytes(), kp.secret.to_bytes()) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_seed_from_bytes() { - let valid_bytes = [0u8; MINI_SECRET_KEY_LENGTH]; - let result = Seed::from_bytes(&valid_bytes); - assert!(result.is_ok()); - - let invalid_bytes = [0u8; MINI_SECRET_KEY_LENGTH - 1]; - let result = Seed::from_bytes(&invalid_bytes); - assert!(result.is_err()); - assert_eq!(result.unwrap_err(), "Invalid seed length"); - } - - #[test] - fn test_pubkey_as_bytes() { - let pubkey_bytes = [1u8; PUBLIC_KEY_LENGTH]; - let pubkey = PubKey(pubkey_bytes); - assert_eq!(pubkey.as_bytes(), &pubkey_bytes); - } - - #[test] - fn test_pair_from_seed() { - let seed_bytes = [0u8; MINI_SECRET_KEY_LENGTH]; - let seed = Seed::from_bytes(&seed_bytes).unwrap(); - let keypair = pair_from_seed(seed); - - assert_eq!(keypair.0.len(), PUBLIC_KEY_LENGTH); - assert_eq!(keypair.1.len(), SECRET_KEY_LENGTH); - - assert_ne!(keypair.0, [0u8; PUBLIC_KEY_LENGTH]); - } -}