diff --git a/.gitignore b/.gitignore index e1defd64..5ac3cc02 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ **/*.toml.fmt **/Cargo.toml.fmt *.iml +Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 3ef98a43..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,1823 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "aes" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6fb1737cdc8da3db76e90ca817a194249a38fcb500c2e6ecec39b29448aa873" -dependencies = [ - "aes-soft 0.2.0", - "aesni 0.4.1", - "block-cipher-trait 0.5.3", -] - -[[package]] -name = "aes" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" -dependencies = [ - "aes-soft 0.3.3", - "aesni 0.6.0", - "block-cipher-trait 0.6.2", -] - -[[package]] -name = "aes-soft" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cc03b0a090a05cb01e96998a01905d7ceedce1bc23b756c0bb7faa0682ccb1" -dependencies = [ - "block-cipher-trait 0.5.3", - "byte-tools 0.2.0", - "opaque-debug 0.1.1", -] - -[[package]] -name = "aes-soft" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" -dependencies = [ - "block-cipher-trait 0.6.2", - "byteorder", - "opaque-debug 0.2.3", -] - -[[package]] -name = "aesni" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6810b7fb9f2bb4f76f05ac1c170b8dde285b6308955dc3afd89710268c958d9e" -dependencies = [ - "block-cipher-trait 0.5.3", - "opaque-debug 0.1.1", - "stream-cipher", -] - -[[package]] -name = "aesni" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -dependencies = [ - "block-cipher-trait 0.6.2", - "opaque-debug 0.2.3", -] - -[[package]] -name = "aho-corasick" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" -dependencies = [ - "memchr", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -dependencies = [ - "winapi", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" - -[[package]] -name = "async-stream" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22068c0c19514942eefcfd4daf8976ef1aad84e61539f95cd200c35202f80af5" -dependencies = [ - "async-stream-impl", - "futures-core", -] - -[[package]] -name = "async-stream-impl" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f9db3b38af870bf7e5cc649167533b493928e50744e2c30ae350230b414670" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", -] - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" - -[[package]] -name = "backtrace" -version = "0.3.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad235dabf00f36301792cfe82499880ba54c6486be094d1047b02bacb67c14e8" -dependencies = [ - "backtrace-sys", - "cfg-if", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca797db0057bae1a7aa2eef3283a874695455cecf08a43bfb8507ee0ebc1ed69" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "base58" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" - -[[package]] -name = "base58-monero" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06753f02479480272d4ffc2c850174e2c2e84c887ffa357bc0d8f61ff38791fc" -dependencies = [ - "async-stream", - "futures-util", - "tiny-keccak 2.0.1", - "tokio", -] - -[[package]] -name = "bech32" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58946044516aa9dc922182e0d6e9d124a31aafe6b421614654eb27cf90cec09c" - -[[package]] -name = "bellman" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be536193834affcd8a6d362963e66dec8c6bca4d2009f5bac55ec9002776ff2" -dependencies = [ - "bit-vec", - "blake2s_simd", - "byteorder", - "crossbeam", - "ff", - "futures", - "futures-cpupool", - "group", - "num_cpus", - "pairing", - "rand_core 0.5.1", -] - -[[package]] -name = "bit-vec" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bitvec" -version = "0.17.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" -dependencies = [ - "either", - "radium", -] - -[[package]] -name = "blake2b_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - -[[package]] -name = "blake2s_simd" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9e07352b829279624ceb7c64adb4f585dacdb81d35cafae81139ccd617cf44" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" -dependencies = [ - "arrayref", - "byte-tools 0.2.0", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools 0.3.1", - "byteorder", - "generic-array 0.12.3", -] - -[[package]] -name = "block-cipher-trait" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "370424437b9459f3dfd68428ed9376ddfe03d8b70ede29cc533b3557df186ab4" -dependencies = [ - "generic-array 0.9.0", -] - -[[package]] -name = "block-cipher-trait" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" -dependencies = [ - "generic-array 0.12.3", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools 0.3.1", -] - -[[package]] -name = "build_const" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" - -[[package]] -name = "byte-tools" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "byteorder" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" - -[[package]] -name = "bytes" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" - -[[package]] -name = "cc" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "clap" -version = "2.33.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "cmake" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56268c17a6248366d66d4a47a3381369d068cce8409bb1716ed77ea32163bb" -dependencies = [ - "cc", -] - -[[package]] -name = "colored" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59" -dependencies = [ - "atty", - "lazy_static", - "winapi", -] - -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" -dependencies = [ - "build_const", -] - -[[package]] -name = "crossbeam" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" -dependencies = [ - "cfg-if", - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-epoch", - "crossbeam-queue", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-channel" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cced8691919c02aac3cb0a1bc2e9b73d89e832bf9a06fc579d4e71b68a2da061" -dependencies = [ - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-deque" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", - "maybe-uninit", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "lazy_static", - "maybe-uninit", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -dependencies = [ - "autocfg", - "cfg-if", - "lazy_static", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-mac" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" -dependencies = [ - "generic-array 0.12.3", - "subtle 1.0.0", -] - -[[package]] -name = "crypto_api" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f855e87e75a4799e18b8529178adcde6fd4f97c1449ff4821e747ff728bb102" - -[[package]] -name = "crypto_api_chachapoly" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b2ad7cab08fd71addba81df5077c49df208effdfb3118a1519f9cdeac5aaf2" -dependencies = [ - "crypto_api", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d85653f070353a16313d0046f173f70d1aadd5b42600a14de626f0dfb3473a5" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core 0.5.1", - "subtle 2.2.2", - "zeroize", -] - -[[package]] -name = "digest" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90" -dependencies = [ - "generic-array 0.9.0", -] - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.3", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.2", -] - -[[package]] -name = "directories" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "either" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" - -[[package]] -name = "ethbloom" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e7abcddbdd5db30aeed4deb586adc4824e6c247e2f7238d1187f752893f096b" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-rlp", - "tiny-keccak 2.0.1", -] - -[[package]] -name = "ethereum-types" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-rlp", - "primitive-types", - "uint", -] - -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", - "synstructure", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "ff" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4b967a3ee6ae993f0094174257d404a5818f58be79d67a1aea1ec8996d28906" -dependencies = [ - "byteorder", - "ff_derive", - "rand_core 0.5.1", -] - -[[package]] -name = "ff_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3776aaf60a45037a9c3cabdd8542b38693acaa3e241ff957181b72579d29feb" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", -] - -[[package]] -name = "field-derive" -version = "0.6.1" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "proc-macro2 0.4.30", - "quote 0.6.13", - "syn 0.14.9", -] - -[[package]] -name = "fixed-hash" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32529fc42e86ec06e5047092082aab9ad459b070c5d2a76b14f4f5ce70bf2e84" -dependencies = [ - "byteorder", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "fpe" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce3371c82bfbd984f624cab093f55e7336f5a6e589f8518e1258f54f011b89ad" -dependencies = [ - "aes 0.2.0", - "byteorder", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "fpe" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21988a326139165b75e3196bc6962ca638e5fb0c95102fbf152a3743174b01e4" -dependencies = [ - "aes 0.3.2", - "byteorder", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - -[[package]] -name = "futures-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" - -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures", - "num_cpus", -] - -[[package]] -name = "futures-macro" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5081aa3de1f7542a794a397cde100ed903b0630152d0973479018fd85423a7" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", -] - -[[package]] -name = "futures-task" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" - -[[package]] -name = "futures-util" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" -dependencies = [ - "futures-core", - "futures-macro", - "futures-task", - "pin-utils", - "proc-macro-hack", - "proc-macro-nested", - "slab", -] - -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" - -[[package]] -name = "generic-array" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac746a5f3bbfdadd6106868134545e684693d54d9d44f6e9588a7d54af0bf980" -dependencies = [ - "typenum", - "version_check", -] - -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "group" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f15be54742789e36f03307c8fdf0621201e1345e94f1387282024178b5e9ec8c" -dependencies = [ - "ff", - "rand 0.7.3", - "rand_xorshift", -] - -[[package]] -name = "hermit-abi" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8" -dependencies = [ - "libc", -] - -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" - -[[package]] -name = "hex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" - -[[package]] -name = "hex-literal" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" -dependencies = [ - "hex-literal-impl", - "proc-macro-hack", -] - -[[package]] -name = "hex-literal-impl" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" -dependencies = [ - "proc-macro-hack", -] - -[[package]] -name = "hmac" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" -dependencies = [ - "crypto-mac", - "digest 0.8.1", -] - -[[package]] -name = "hmac-drbg" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -dependencies = [ - "digest 0.8.1", - "generic-array 0.12.3", - "hmac", -] - -[[package]] -name = "impl-rlp" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" -dependencies = [ - "rlp", -] - -[[package]] -name = "itoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" - -[[package]] -name = "libsecp256k1" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" -dependencies = [ - "arrayref", - "crunchy", - "digest 0.8.1", - "hmac-drbg", - "rand 0.7.3", - "sha2", - "subtle 2.2.2", - "typenum", -] - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - -[[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "memoffset" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" -dependencies = [ - "rustc_version", -] - -[[package]] -name = "num-bigint" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "opaque-debug" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d620c9c26834b34f039489ac0dfdb12c7ac15ccaf818350a64c9b5334a452ad7" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "pairing" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8290dea210a712682cd65031dc2b34fd132cf2729def3df7ee08f0737ff5ed6" -dependencies = [ - "byteorder", - "ff", - "group", - "rand_core 0.5.1", -] - -[[package]] -name = "pbkdf2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9" -dependencies = [ - "byteorder", - "crypto-mac", - "rayon", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" - -[[package]] -name = "ppv-lite86" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" - -[[package]] -name = "primitive-types" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5e4b9943a2da369aec5e96f7c10ebc74fcf434d39590d974b0a3460e6f67fbb" -dependencies = [ - "fixed-hash", - "impl-rlp", - "uint", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", -] - -[[package]] -name = "proc-macro-nested" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - -[[package]] -name = "proc-macro2" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" -dependencies = [ - "unicode-xid 0.2.0", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - -[[package]] -name = "quote" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" -dependencies = [ - "proc-macro2 1.0.18", -] - -[[package]] -name = "radium" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" - -[[package]] -name = "rand" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -dependencies = [ - "libc", - "rand 0.4.6", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core 0.5.1", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_xorshift" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rayon" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098" -dependencies = [ - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "lazy_static", - "num_cpus", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" - -[[package]] -name = "regex" -version = "1.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", - "thread_local", -] - -[[package]] -name = "regex-syntax" -version = "0.6.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae" - -[[package]] -name = "ripemd160" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "482aa56cc68aaeccdaaff1cc5a72c247da8bbad3beb174ca5741f274c22883fb" -dependencies = [ - "block-buffer 0.3.3", - "byte-tools 0.2.0", - "digest 0.7.6", -] - -[[package]] -name = "ripemd160" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "opaque-debug 0.2.3", -] - -[[package]] -name = "rlp" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a7d3f9bed94764eac15b8f14af59fac420c236adaff743b7bcc88e265cb4345" -dependencies = [ - "rustc-hex", -] - -[[package]] -name = "rust-crypto" -version = "0.2.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" -dependencies = [ - "gcc", - "libc", - "rand 0.3.23", - "rustc-serialize", - "time", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc-serialize" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "ryu" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", -] - -[[package]] -name = "serde_json" -version = "1.0.55" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2c5d7e739bc07a3e73381a39d61fdb5f671c60c1df26a130690665803d8226" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "stream-cipher" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30dc6118470d69ce0fdcf7e6f95e95853f7f4f72f80d835d4519577c323814ab" -dependencies = [ - "generic-array 0.9.0", -] - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "subtle" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" - -[[package]] -name = "subtle" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" - -[[package]] -name = "syn" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "unicode-xid 0.1.0", -] - -[[package]] -name = "syn" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "unicode-xid 0.2.0", -] - -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -dependencies = [ - "proc-macro2 1.0.18", - "quote 1.0.3", - "syn 1.0.33", - "unicode-xid 0.2.0", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "time" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" -dependencies = [ - "libc", - "redox_syscall", - "winapi", -] - -[[package]] -name = "tiny-keccak" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d8a021c69bb74a44ccedb824a046447e2c84a01df9e5c20779750acb38e11b2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tiny-keccak" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2953ca5148619bc99695c1274cb54c5275bbb913c6adad87e72eaf8db9787f69" -dependencies = [ - "crunchy", -] - -[[package]] -name = "tokio" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa5e81d6bc4e67fe889d5783bd2a128ab2e0cfa487e0be16b6a8d177b101616" -dependencies = [ - "bytes", - "futures-core", - "memchr", - "pin-project-lite", -] - -[[package]] -name = "typenum" -version = "1.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" - -[[package]] -name = "uint" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173cd16430c206dc1a430af8a89a0e9c076cf15cb42b4aedb10e8cc8fee73681" -dependencies = [ - "byteorder", - "crunchy", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "unicode-width" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" - -[[package]] -name = "version_check" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" - -[[package]] -name = "wagyu" -version = "0.6.3" -dependencies = [ - "arrayvec", - "base58", - "clap", - "colored", - "digest 0.9.0", - "either", - "failure", - "hex 0.4.2", - "lazy_static", - "rand 0.7.3", - "rand_core 0.5.1", - "safemem", - "serde", - "serde_json", - "tiny-keccak 1.5.0", - "wagyu-bitcoin", - "wagyu-ethereum", - "wagyu-model", - "wagyu-monero", - "wagyu-zcash", -] - -[[package]] -name = "wagyu-bitcoin" -version = "0.6.3" -dependencies = [ - "base58", - "bech32", - "bitvec", - "digest 0.9.0", - "failure", - "hex 0.4.2", - "hmac", - "libsecp256k1", - "pbkdf2", - "rand 0.7.3", - "rand_xorshift", - "ripemd160 0.8.0", - "serde", - "serde_json", - "sha2", - "tiny-keccak 1.5.0", - "wagyu-model", -] - -[[package]] -name = "wagyu-ethereum" -version = "0.6.3" -dependencies = [ - "base58", - "bitvec", - "ethereum-types", - "hex 0.4.2", - "hmac", - "libsecp256k1", - "pbkdf2", - "rand 0.7.3", - "rand_xorshift", - "regex", - "rlp", - "serde", - "serde_json", - "sha2", - "tiny-keccak 1.5.0", - "wagyu-model", -] - -[[package]] -name = "wagyu-model" -version = "0.6.3" -dependencies = [ - "base58", - "base58-monero", - "bech32", - "byteorder", - "crypto-mac", - "ethereum-types", - "failure", - "ff", - "hex 0.4.2", - "libsecp256k1", - "rand 0.7.3", - "rand_core 0.5.1", - "ripemd160 0.8.0", - "rlp", - "serde_json", - "sha2", - "uint", -] - -[[package]] -name = "wagyu-monero" -version = "0.6.3" -dependencies = [ - "base58-monero", - "cmake", - "crc", - "curve25519-dalek", - "failure", - "hex 0.4.2", - "libc", - "rand 0.7.3", - "serde", - "serde_json", - "tiny-keccak 1.5.0", - "wagyu-model", -] - -[[package]] -name = "wagyu-zcash" -version = "0.6.3" -dependencies = [ - "aes 0.2.0", - "base58", - "bech32", - "bellman", - "blake2b_simd", - "blake2s_simd", - "byteorder", - "curve25519-dalek", - "ff", - "field-derive", - "fpe 0.1.0", - "hex 0.4.2", - "hex-literal", - "lazy_static", - "libsecp256k1", - "pairing", - "rand 0.7.3", - "rand_core 0.5.1", - "rand_xorshift", - "ripemd160 0.7.0", - "rust-crypto", - "serde", - "serde_json", - "sha2", - "wagyu-model", - "wagyu-zcash-parameters", - "zcash_primitives", - "zcash_proofs", -] - -[[package]] -name = "wagyu-zcash-parameters" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c904628658374e651288f000934c33ef738b2d8b3e65d4100b70b395dbe2bb" -dependencies = [ - "wagyu-zcash-parameters-1", - "wagyu-zcash-parameters-2", - "wagyu-zcash-parameters-3", - "wagyu-zcash-parameters-4", - "wagyu-zcash-parameters-5", - "wagyu-zcash-parameters-6", -] - -[[package]] -name = "wagyu-zcash-parameters-1" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bf2e21bb027d3f8428c60d6a720b54a08bf6ce4e6f834ef8e0d38bb5695da8" - -[[package]] -name = "wagyu-zcash-parameters-2" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a616ab2e51e74cc48995d476e94de810fb16fc73815f390bf2941b046cc9ba2c" - -[[package]] -name = "wagyu-zcash-parameters-3" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14da1e2e958ff93c0830ee68e91884069253bf3462a67831b02b367be75d6147" - -[[package]] -name = "wagyu-zcash-parameters-4" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f058aeef03a2070e8666ffb5d1057d8bb10313b204a254a6e6103eb958e9a6d6" - -[[package]] -name = "wagyu-zcash-parameters-5" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ffe916b30e608c032ae1b734f02574a3e12ec19ab5cc5562208d679efe4969d" - -[[package]] -name = "wagyu-zcash-parameters-6" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7b6d5a78adc3e8f198e9cd730f219a695431467f7ec29dcfc63ade885feebe1" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -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-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zcash_primitives" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f33b9e4f3b4db97234fc79ea67b12f2d5778bde8f3eab6dbba52eb54c596585" -dependencies = [ - "aes 0.3.2", - "blake2b_simd", - "blake2s_simd", - "byteorder", - "crypto_api_chachapoly", - "ff", - "fpe 0.2.0", - "hex 0.3.2", - "lazy_static", - "log", - "pairing", - "rand 0.7.3", - "rand_core 0.5.1", - "sha2", -] - -[[package]] -name = "zcash_proofs" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2011f78f14d5121248d3b4f921434207b1d870fb3bf2efc7d784cae79b19bfbc" -dependencies = [ - "bellman", - "blake2b_simd", - "byteorder", - "directories", - "ff", - "pairing", - "rand_core 0.5.1", - "zcash_primitives", -] - -[[package]] -name = "zeroize" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" diff --git a/Cargo.toml b/Cargo.toml index dae71a02..24a1d1d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,10 @@ members = [ "bitcoin", "ethereum", "model", "monero", "zcash" ] [badges] travis-ci = { repository = "AleoHQ/wagyu", branch = "master" } +[features] +default = ["std"] +std = ["wagyu-model/std", "wagyu-bitcoin/std", "wagyu-ethereum/std", "wagyu-model/std", "wagyu-monero/std", "wagyu-zcash/std"] + [dependencies] wagyu-bitcoin = { path = "./bitcoin", version = "0.6.3" } wagyu-ethereum = { path = "./ethereum", version = "0.6.3" } diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml index b86aa069..e1896f43 100644 --- a/bitcoin/Cargo.toml +++ b/bitcoin/Cargo.toml @@ -38,7 +38,7 @@ tiny-keccak = { version = "1.4" } [features] default = ["std"] -std = ["wagyu-model/default"] +std = ["wagyu-model/std"] [badges] travis-ci = { repository = "AleoHQ/wagyu", branch = "master" } diff --git a/bitcoin/src/address.rs b/bitcoin/src/address.rs index 3467bee8..b1576527 100644 --- a/bitcoin/src/address.rs +++ b/bitcoin/src/address.rs @@ -3,11 +3,11 @@ use crate::network::BitcoinNetwork; use crate::private_key::BitcoinPrivateKey; use crate::public_key::BitcoinPublicKey; use crate::witness_program::WitnessProgram; +use wagyu_model::no_std::*; use wagyu_model::{ crypto::{checksum, hash160}, Address, AddressError, PrivateKey, }; -use wagyu_model::no_std::*; use base58::{FromBase58, ToBase58}; use bech32::{u5, Bech32, FromBase32, ToBase32}; @@ -35,7 +35,12 @@ impl Address for BitcoinAddress { let public_key = private_key.to_public_key(); match format { BitcoinFormat::P2PKH => Self::p2pkh(&public_key), - BitcoinFormat::P2WSH => return Err(AddressError::IncompatibleFormats(String::from("non-script"), String::from("p2wsh address"))), + BitcoinFormat::P2WSH => { + return Err(AddressError::IncompatibleFormats( + String::from("non-script"), + String::from("p2wsh address"), + )) + } BitcoinFormat::P2SH_P2WPKH => Self::p2sh_p2wpkh(&public_key), BitcoinFormat::Bech32 => Self::bech32(&public_key), } @@ -45,7 +50,12 @@ impl Address for BitcoinAddress { fn from_public_key(public_key: &Self::PublicKey, format: &Self::Format) -> Result { match format { BitcoinFormat::P2PKH => Self::p2pkh(public_key), - BitcoinFormat::P2WSH => return Err(AddressError::IncompatibleFormats(String::from("non-script"), String::from("p2wsh address"))), + BitcoinFormat::P2WSH => { + return Err(AddressError::IncompatibleFormats( + String::from("non-script"), + String::from("p2wsh address"), + )) + } BitcoinFormat::P2SH_P2WPKH => Self::p2sh_p2wpkh(public_key), BitcoinFormat::Bech32 => Self::bech32(public_key), } @@ -841,14 +851,14 @@ mod tests { ), ( "210253be79afe84fd9342c1f52024379b6da6299ea98844aee23838e8e678a765f7cac", - "tb1qhmdep02f0jpjxs36ckyzjtfesknu8a8xmhnva7f3vw95t9g6q4ksaqhl9x" - ) + "tb1qhmdep02f0jpjxs36ckyzjtfesknu8a8xmhnva7f3vw95t9g6q4ksaqhl9x", + ), ]; #[test] fn from_str() { SCRIPTPAIRS.iter().for_each(|(script, address)| { - let script_hex= hex::decode(script).unwrap(); + let script_hex = hex::decode(script).unwrap(); let new_address = BitcoinAddress::::p2wsh(&script_hex).unwrap(); assert_eq!(new_address.to_string(), address.to_string()); assert_eq!(new_address.format, BitcoinFormat::P2WSH); @@ -863,5 +873,4 @@ mod tests { }); } } - } diff --git a/bitcoin/src/amount.rs b/bitcoin/src/amount.rs index 04d32708..18f938dc 100644 --- a/bitcoin/src/amount.rs +++ b/bitcoin/src/amount.rs @@ -1,5 +1,5 @@ -use wagyu_model::{Amount, AmountError}; use wagyu_model::no_std::*; +use wagyu_model::{Amount, AmountError}; use core::fmt; use serde::Serialize; diff --git a/bitcoin/src/extended_private_key.rs b/bitcoin/src/extended_private_key.rs index 19925e15..03e30b00 100644 --- a/bitcoin/src/extended_private_key.rs +++ b/bitcoin/src/extended_private_key.rs @@ -78,10 +78,8 @@ impl ExtendedPrivateKey for BitcoinExtendedPrivateKey { let mut extended_private_key = self.clone(); for index in path.to_vec()?.into_iter() { - let public_key = &PublicKey::from_secret_key( - &extended_private_key.private_key.to_secp256k1_secret_key(), - ) - .serialize_compressed()[..]; + let public_key = &PublicKey::from_secret_key(&extended_private_key.private_key.to_secp256k1_secret_key()) + .serialize_compressed()[..]; let mut mac = HmacSha512::new_varkey(&extended_private_key.chain_code)?; match index { diff --git a/bitcoin/src/extended_public_key.rs b/bitcoin/src/extended_public_key.rs index 23b15bae..0e0e9557 100644 --- a/bitcoin/src/extended_public_key.rs +++ b/bitcoin/src/extended_public_key.rs @@ -208,10 +208,7 @@ mod tests { let extended_private_key = BitcoinExtendedPrivateKey::::from_str(extended_private_key).unwrap(); let extended_public_key = BitcoinExtendedPublicKey::::from_extended_private_key(&extended_private_key); assert_eq!(expected_extended_public_key, extended_public_key.to_string()); - assert_eq!( - expected_public_key, - extended_public_key.public_key.to_string() - ); + assert_eq!(expected_public_key, extended_public_key.public_key.to_string()); assert_eq!(expected_child_index, u32::from(extended_public_key.child_index)); assert_eq!(expected_chain_code, hex::encode(extended_public_key.chain_code)); assert_eq!( @@ -263,10 +260,7 @@ mod tests { extended_public_key: &str, ) { let extended_public_key = BitcoinExtendedPublicKey::::from_str(&extended_public_key).unwrap(); - assert_eq!( - expected_public_key, - extended_public_key.public_key.to_string() - ); + assert_eq!(expected_public_key, extended_public_key.public_key.to_string()); assert_eq!(expected_child_index, u32::from(extended_public_key.child_index)); assert_eq!(expected_chain_code, hex::encode(extended_public_key.chain_code)); assert_eq!( diff --git a/bitcoin/src/format.rs b/bitcoin/src/format.rs index 0a295ce8..6182dc57 100644 --- a/bitcoin/src/format.rs +++ b/bitcoin/src/format.rs @@ -1,6 +1,6 @@ use crate::network::BitcoinNetwork; -use wagyu_model::{AddressError, ExtendedPrivateKeyError, ExtendedPublicKeyError, Format}; use wagyu_model::no_std::*; +use wagyu_model::{AddressError, ExtendedPrivateKeyError, ExtendedPublicKeyError, Format}; use core::fmt; use serde::Serialize; diff --git a/bitcoin/src/mnemonic.rs b/bitcoin/src/mnemonic.rs index 59257862..41043a31 100644 --- a/bitcoin/src/mnemonic.rs +++ b/bitcoin/src/mnemonic.rs @@ -6,8 +6,8 @@ use crate::network::BitcoinNetwork; use crate::private_key::BitcoinPrivateKey; use crate::public_key::BitcoinPublicKey; use crate::wordlist::BitcoinWordlist; -use wagyu_model::{ExtendedPrivateKey, Mnemonic, MnemonicCount, MnemonicError, MnemonicExtended}; use wagyu_model::no_std::*; +use wagyu_model::{ExtendedPrivateKey, Mnemonic, MnemonicCount, MnemonicError, MnemonicExtended}; use bitvec::prelude::*; use core::{fmt, marker::PhantomData, ops::Div, str, str::FromStr}; diff --git a/bitcoin/src/network/mainnet.rs b/bitcoin/src/network/mainnet.rs index bc2da274..b37f850a 100644 --- a/bitcoin/src/network/mainnet.rs +++ b/bitcoin/src/network/mainnet.rs @@ -1,9 +1,9 @@ use crate::format::BitcoinFormat; use crate::network::BitcoinNetwork; +use wagyu_model::no_std::*; use wagyu_model::{ AddressError, ChildIndex, ExtendedPrivateKeyError, ExtendedPublicKeyError, Network, NetworkError, PrivateKeyError, }; -use wagyu_model::no_std::*; use core::{fmt, str::FromStr}; use serde::Serialize; diff --git a/bitcoin/src/network/mod.rs b/bitcoin/src/network/mod.rs index 86c3259a..39d16f87 100644 --- a/bitcoin/src/network/mod.rs +++ b/bitcoin/src/network/mod.rs @@ -1,8 +1,8 @@ use crate::format::BitcoinFormat; +use wagyu_model::no_std::*; use wagyu_model::{ AddressError, ChildIndex, ExtendedPrivateKeyError, ExtendedPublicKeyError, Network, PrivateKeyError, }; -use wagyu_model::no_std::*; pub mod mainnet; pub use self::mainnet::*; diff --git a/bitcoin/src/network/testnet.rs b/bitcoin/src/network/testnet.rs index 522eaa97..8e695d7e 100644 --- a/bitcoin/src/network/testnet.rs +++ b/bitcoin/src/network/testnet.rs @@ -1,9 +1,9 @@ use crate::format::BitcoinFormat; use crate::network::BitcoinNetwork; +use wagyu_model::no_std::*; use wagyu_model::{ AddressError, ChildIndex, ExtendedPrivateKeyError, ExtendedPublicKeyError, Network, NetworkError, PrivateKeyError, }; -use wagyu_model::no_std::*; use core::{fmt, str::FromStr}; use serde::Serialize; diff --git a/bitcoin/src/transaction.rs b/bitcoin/src/transaction.rs index 5f60d9ee..01b985e5 100644 --- a/bitcoin/src/transaction.rs +++ b/bitcoin/src/transaction.rs @@ -5,8 +5,8 @@ use crate::network::BitcoinNetwork; use crate::private_key::BitcoinPrivateKey; use crate::public_key::BitcoinPublicKey; use crate::witness_program::WitnessProgram; +use wagyu_model::no_std::{io::Read, *}; use wagyu_model::{PrivateKey, Transaction, TransactionError, TransactionId}; -use wagyu_model::no_std::{*, io::Read}; use base58::FromBase58; use bech32::{Bech32, FromBase32}; @@ -313,7 +313,7 @@ pub struct BitcoinTransactionInput { /// Provide more flexibility for multiple signatures (for P2WSH) pub additional_witness: Option<(Vec, bool)>, /// Option for additional witness stack script args - pub witness_script_data: Option> + pub witness_script_data: Option>, } impl BitcoinTransactionInput { @@ -400,7 +400,7 @@ impl BitcoinTransactionInput { witnesses: vec![], is_signed: script_sig.len() > 0, additional_witness: None, - witness_script_data: None + witness_script_data: None, }) } @@ -618,8 +618,8 @@ impl Transaction for BitcoinTransaction { }; let c_address = BitcoinAddress::::p2wsh(&input_script)?; address == &c_address - }, - _ => address == &private_key.to_address(&address.format())? + } + _ => address == &private_key.to_address(&address.format())?, }; if address_is_valid && !transaction.parameters.inputs[vin].is_signed { @@ -632,9 +632,9 @@ impl Transaction for BitcoinTransaction { // Signature let (signature, _) = secp256k1::sign( - &secp256k1::Message::parse_slice(&transaction_hash)?, - &private_key.to_secp256k1_secret_key(), - ); + &secp256k1::Message::parse_slice(&transaction_hash)?, + &private_key.to_secp256k1_secret_key(), + ); let mut signature = signature.serialize_der().as_ref().to_vec(); signature.push((input.sighash_code as u32).to_le_bytes()[0]); let signature = [variable_length_integer(signature.len() as u64)?, signature].concat(); @@ -642,9 +642,7 @@ impl Transaction for BitcoinTransaction { // Public key let public_key = private_key.to_public_key(); let public_key_bytes = match (&address.format(), public_key.is_compressed()) { - (BitcoinFormat::P2PKH, false) => { - public_key.to_secp256k1_public_key().serialize().to_vec() - } + (BitcoinFormat::P2PKH, false) => public_key.to_secp256k1_public_key().serialize().to_vec(), _ => public_key.to_secp256k1_public_key().serialize_compressed().to_vec(), }; let public_key = [vec![public_key_bytes.len() as u8], public_key_bytes].concat(); @@ -660,29 +658,36 @@ impl Transaction for BitcoinTransaction { None => return Err(TransactionError::InvalidInputs("P2WSH".into())), }; - let ser_input_script = [variable_length_integer(input_script.len() as u64)?, input_script].concat(); + let ser_input_script = + [variable_length_integer(input_script.len() as u64)?, input_script].concat(); transaction.parameters.segwit_flag = true; transaction.parameters.inputs[vin].script_sig = vec![]; // TODO: (jaakinyele) Generalize to a vec of additional witnesses - let (other_signature, is_other_sig_first) = match transaction.parameters.inputs[vin].additional_witness.clone() { - Some(n) => (n.0, n.1), - None => return Err(TransactionError::InvalidInputs("P2WSH: missing additional witness input to complete multi-sig".into())), - }; + let (other_signature, is_other_sig_first) = + match transaction.parameters.inputs[vin].additional_witness.clone() { + Some(n) => (n.0, n.1), + None => { + return Err(TransactionError::InvalidInputs( + "P2WSH: missing additional witness input to complete multi-sig".into(), + )) + } + }; // Determine whether to append or prepend other signature(s) let mut witness_field = match is_other_sig_first { true => vec![other_signature, signature.clone()], - false => vec![signature.clone(), other_signature] + false => vec![signature.clone(), other_signature], }; // Append witness stack script args (before witness script) if transaction.parameters.inputs[vin].witness_script_data.is_some() { - let witness_script_data = transaction.parameters.inputs[vin].witness_script_data.clone().unwrap(); - let witness_script_data = [vec![witness_script_data.len() as u8], witness_script_data].concat(); + let witness_script_data = + transaction.parameters.inputs[vin].witness_script_data.clone().unwrap(); + let witness_script_data = + [vec![witness_script_data.len() as u8], witness_script_data].concat(); witness_field.append(&mut vec![witness_script_data]); } // Append the witness script last witness_field.append(&mut vec![ser_input_script.clone()]); - transaction.parameters.inputs[vin].witnesses - .append(&mut witness_field); + transaction.parameters.inputs[vin].witnesses.append(&mut witness_field); transaction.parameters.inputs[vin].is_signed = true; } BitcoinFormat::P2SH_P2WPKH => { @@ -946,11 +951,11 @@ mod tests { inputs: Vec, outputs: Vec, expected_signed_transaction: &str, - expected_transaction_id: &str + expected_transaction_id: &str, ) { let mut input_vec = vec![]; for input in &inputs { - let private_key = BitcoinPrivateKey::from_str(input.private_key).unwrap(); + let private_key = BitcoinPrivateKey::from_str(input.private_key).unwrap(); let transaction_id = hex::decode(input.transaction_id).unwrap(); let redeem_script = match (input.redeem_script, input.address_format.clone()) { (Some(script), BitcoinFormat::P2WSH) => Some(hex::decode(script).unwrap()), @@ -958,15 +963,18 @@ mod tests { (None, BitcoinFormat::P2SH_P2WPKH) => { let mut redeem_script = vec![0x00, 0x14]; redeem_script.extend(&hash160( - &private_key.to_public_key().to_secp256k1_public_key().serialize_compressed(), + &private_key + .to_public_key() + .to_secp256k1_public_key() + .serialize_compressed(), )); Some(redeem_script) } (None, _) => None, - }; + }; let address = match &input.address_format { BitcoinFormat::P2WSH => BitcoinAddress::::p2wsh(redeem_script.as_ref().unwrap()).unwrap(), - _ => private_key.to_address(&input.address_format).unwrap() + _ => private_key.to_address(&input.address_format).unwrap(), }; let script_pub_key = input.script_pub_key.map(|script| hex::decode(script).unwrap()); let sequence = input.sequence.map(|seq| seq.to_vec()); @@ -994,13 +1002,13 @@ mod tests { let address = BitcoinAddress::::from_str(output.address); if address.is_ok() { output_vec.push(BitcoinTransactionOutput::new(&address.unwrap(), output.amount).unwrap()); - } else { + } else { let tx_output = BitcoinTransactionOutput { amount: output.amount, - script_pub_key: hex::decode(output.address).unwrap() + script_pub_key: hex::decode(output.address).unwrap(), }; output_vec.push(tx_output); - } + } } let transaction_parameters = BitcoinTransactionParameters:: { @@ -1020,14 +1028,14 @@ mod tests { .unwrap(); } - let signed_transaction_without_witness = hex::encode(&transaction.to_transaction_bytes_without_witness().unwrap()); + let signed_transaction_without_witness = + hex::encode(&transaction.to_transaction_bytes_without_witness().unwrap()); let transaction_id = hex::encode(&transaction.to_transaction_id().unwrap().txid); assert_eq!(expected_signed_transaction, &signed_transaction_without_witness); assert_eq!(expected_transaction_id, &transaction_id); } - fn test_transaction( version: u32, lock_time: u32, @@ -1046,7 +1054,10 @@ mod tests { (None, BitcoinFormat::P2SH_P2WPKH) => { let mut redeem_script = vec![0x00, 0x14]; redeem_script.extend(&hash160( - &private_key.to_public_key().to_secp256k1_public_key().serialize_compressed(), + &private_key + .to_public_key() + .to_secp256k1_public_key() + .serialize_compressed(), )); Some(redeem_script) } @@ -1117,7 +1128,10 @@ mod tests { (None, BitcoinFormat::P2SH_P2WPKH) => { let mut redeem_script = vec![0x00, 0x14]; redeem_script.extend(&hash160( - &private_key.to_public_key().to_secp256k1_public_key().serialize_compressed(), + &private_key + .to_public_key() + .to_secp256k1_public_key() + .serialize_compressed(), )); Some(redeem_script) } @@ -1866,7 +1880,7 @@ mod tests { // Not including witness for now expected_signed_transaction: "0200000001fa6a6160f798cba0c5cac5b9d2ba91d177fa8589875ba8ae7e46864c4e42957c37000000171600143d295b6276ff8e4579f3350873db3e839e230f41ffffffff0180841e0000000000220020c015c4a6be010e21657068fc2e6a9d02b27ebe4d490a25846f7237f104d1a3cd00000000", expected_transaction_id: "d7f70088081d8c3bf45040f11789ee53868b4b00f900c86d32702f3497dec879", - }, + }, TransactionTestCase { // Transaction 2 -> P2WSH to Bech32(P2WPKH) and itself version: 2, lock_time: 0, @@ -1923,7 +1937,6 @@ mod tests { ); }); } - } mod test_helper_functions { diff --git a/bitcoin/src/witness_program.rs b/bitcoin/src/witness_program.rs index a4547c0c..ef6ec5ae 100644 --- a/bitcoin/src/witness_program.rs +++ b/bitcoin/src/witness_program.rs @@ -20,8 +20,8 @@ //! If the version byte is 0, but the witness program is neither 20 nor 32 bytes, the script must fail. //! -use wagyu_model::{AddressError, TransactionError}; use wagyu_model::no_std::*; +use wagyu_model::{AddressError, TransactionError}; use core::str::FromStr; diff --git a/bitcoin/src/wordlist/mod.rs b/bitcoin/src/wordlist/mod.rs index 6aff532d..c8ae8305 100644 --- a/bitcoin/src/wordlist/mod.rs +++ b/bitcoin/src/wordlist/mod.rs @@ -1,5 +1,5 @@ -use wagyu_model::wordlist::{Wordlist, WordlistError}; use wagyu_model::no_std::*; +use wagyu_model::wordlist::{Wordlist, WordlistError}; pub mod chinese_simplified; pub use self::chinese_simplified::*; diff --git a/ethereum/Cargo.toml b/ethereum/Cargo.toml index b29b5544..31dc8874 100644 --- a/ethereum/Cargo.toml +++ b/ethereum/Cargo.toml @@ -37,7 +37,7 @@ tiny-keccak = { version = "1.4" } [features] default = ["std"] -std = ["wagyu-model/default"] +std = ["wagyu-model/std"] [badges] travis-ci = { repository = "AleoHQ/wagyu", branch = "master" } diff --git a/ethereum/src/address.rs b/ethereum/src/address.rs index fa3a95d1..c3682a82 100644 --- a/ethereum/src/address.rs +++ b/ethereum/src/address.rs @@ -3,9 +3,9 @@ use crate::private_key::EthereumPrivateKey; use crate::public_key::EthereumPublicKey; use wagyu_model::{to_hex_string, Address, AddressError, PrivateKey}; +use core::{convert::TryFrom, fmt, str::FromStr}; use regex::Regex; use serde::Serialize; -use std::{convert::TryFrom, fmt, str::FromStr}; use tiny_keccak::keccak256; /// Represents an Ethereum address diff --git a/ethereum/src/amount.rs b/ethereum/src/amount.rs index 644f7c98..b345f9aa 100644 --- a/ethereum/src/amount.rs +++ b/ethereum/src/amount.rs @@ -1,7 +1,7 @@ use wagyu_model::{Amount, AmountError}; +use core::fmt; use ethereum_types::U256; -use std::fmt; /// Represents the amount of Ethereum in wei #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/ethereum/src/derivation_path.rs b/ethereum/src/derivation_path.rs index 55b72aa1..d45dccb1 100644 --- a/ethereum/src/derivation_path.rs +++ b/ethereum/src/derivation_path.rs @@ -1,8 +1,8 @@ use crate::network::EthereumNetwork; use wagyu_model::derivation_path::{ChildIndex, DerivationPath, DerivationPathError}; -use std::convert::TryFrom; -use std::{fmt, marker::PhantomData, str::FromStr}; +use core::convert::TryFrom; +use core::{fmt, marker::PhantomData, str::FromStr}; /// Represents a Ethereum derivation path #[derive(Clone, PartialEq, Eq)] diff --git a/ethereum/src/extended_private_key.rs b/ethereum/src/extended_private_key.rs index bc6275bb..6979145c 100644 --- a/ethereum/src/extended_private_key.rs +++ b/ethereum/src/extended_private_key.rs @@ -12,10 +12,10 @@ use wagyu_model::{ }; use base58::{FromBase58, ToBase58}; +use core::{convert::TryFrom, fmt, fmt::Display, marker::PhantomData, str::FromStr}; use hmac::{Hmac, Mac}; use secp256k1::{PublicKey, SecretKey}; use sha2::Sha512; -use std::{convert::TryFrom, fmt, fmt::Display, marker::PhantomData, str::FromStr}; type HmacSha512 = Hmac; @@ -78,9 +78,8 @@ impl ExtendedPrivateKey for EthereumExtendedPrivateKey { let mut extended_private_key = self.clone(); for index in path.to_vec()?.into_iter() { - let public_key = &PublicKey::from_secret_key( - &extended_private_key.private_key.to_secp256k1_secret_key(), - ).serialize_compressed(); + let public_key = &PublicKey::from_secret_key(&extended_private_key.private_key.to_secp256k1_secret_key()) + .serialize_compressed(); let mut mac = HmacSha512::new_varkey(&extended_private_key.chain_code)?; match index { diff --git a/ethereum/src/extended_public_key.rs b/ethereum/src/extended_public_key.rs index c7ed476d..2a957efa 100644 --- a/ethereum/src/extended_public_key.rs +++ b/ethereum/src/extended_public_key.rs @@ -10,11 +10,11 @@ use wagyu_model::{ }; use base58::{FromBase58, ToBase58}; +use core::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; use hex; use hmac::{Hmac, Mac}; use secp256k1::{PublicKey as Secp256k1_PublicKey, SecretKey}; use sha2::Sha512; -use std::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; type HmacSha512 = Hmac; diff --git a/ethereum/src/format.rs b/ethereum/src/format.rs index c55c0232..5ad59c90 100644 --- a/ethereum/src/format.rs +++ b/ethereum/src/format.rs @@ -1,7 +1,7 @@ use wagyu_model::Format; +use core::fmt; use serde::Serialize; -use std::fmt; /// Represents the format of a Ethereum address #[derive(Serialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/ethereum/src/lib.rs b/ethereum/src/lib.rs index 8f527fa5..01260f9b 100644 --- a/ethereum/src/lib.rs +++ b/ethereum/src/lib.rs @@ -1,7 +1,9 @@ //! # Ethereum //! //! A library for generating Ethereum wallets. -#![warn(unused_extern_crates)] +//! +#![cfg_attr(not(feature = "std"), no_std)] +#![warn(unused_extern_crates, dead_code)] #![forbid(unsafe_code)] pub mod address; diff --git a/ethereum/src/mnemonic.rs b/ethereum/src/mnemonic.rs index f7b83085..75820b69 100644 --- a/ethereum/src/mnemonic.rs +++ b/ethereum/src/mnemonic.rs @@ -9,11 +9,11 @@ use crate::wordlist::EthereumWordlist; use wagyu_model::{ExtendedPrivateKey, Mnemonic, MnemonicCount, MnemonicError, MnemonicExtended}; use bitvec::prelude::*; +use core::{fmt, marker::PhantomData, ops::Div, str, str::FromStr}; use hmac::Hmac; use pbkdf2::pbkdf2; use rand::Rng; use sha2::{Digest, Sha256, Sha512}; -use std::{fmt, marker::PhantomData, ops::Div, str, str::FromStr}; const PBKDF2_ROUNDS: usize = 2048; const PBKDF2_BYTES: usize = 64; diff --git a/ethereum/src/private_key.rs b/ethereum/src/private_key.rs index 442be07c..7d6cdbed 100644 --- a/ethereum/src/private_key.rs +++ b/ethereum/src/private_key.rs @@ -3,9 +3,9 @@ use crate::format::EthereumFormat; use crate::public_key::EthereumPublicKey; use wagyu_model::{Address, AddressError, PrivateKey, PrivateKeyError, PublicKey}; +use core::{fmt, fmt::Display, str::FromStr}; use rand::Rng; use secp256k1; -use std::{fmt, fmt::Display, str::FromStr}; /// Represents an Ethereum private key #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/ethereum/src/public_key.rs b/ethereum/src/public_key.rs index f0dbdb8e..700297d3 100644 --- a/ethereum/src/public_key.rs +++ b/ethereum/src/public_key.rs @@ -3,8 +3,8 @@ use crate::format::EthereumFormat; use crate::private_key::EthereumPrivateKey; use wagyu_model::{Address, AddressError, PublicKey, PublicKeyError}; +use core::{fmt, fmt::Display, str::FromStr}; use secp256k1; -use std::{fmt, fmt::Display, str::FromStr}; /// Represents an Ethereum public key #[derive(Debug, Clone, PartialEq, Eq)] @@ -17,7 +17,9 @@ impl PublicKey for EthereumPublicKey { /// Returns the address corresponding to the given public key. fn from_private_key(private_key: &Self::PrivateKey) -> Self { - Self(secp256k1::PublicKey::from_secret_key(&private_key.to_secp256k1_secret_key())) + Self(secp256k1::PublicKey::from_secret_key( + &private_key.to_secp256k1_secret_key(), + )) } /// Returns the address of the corresponding private key. @@ -43,7 +45,8 @@ impl FromStr for EthereumPublicKey { fn from_str(public_key: &str) -> Result { Ok(Self(secp256k1::PublicKey::parse_slice( - hex::decode(format!("04{}", public_key).as_str())?.as_slice(), None + hex::decode(format!("04{}", public_key).as_str())?.as_slice(), + None, )?)) } } diff --git a/ethereum/src/transaction.rs b/ethereum/src/transaction.rs index a868eaea..8f62468c 100644 --- a/ethereum/src/transaction.rs +++ b/ethereum/src/transaction.rs @@ -6,10 +6,10 @@ use crate::private_key::EthereumPrivateKey; use crate::public_key::EthereumPublicKey; use wagyu_model::{PrivateKey, PublicKey, Transaction, TransactionError, TransactionId}; +use core::{fmt, marker::PhantomData, str::FromStr}; use ethereum_types::U256; use rlp::{decode_list, RlpStream}; use secp256k1; -use std::{fmt, marker::PhantomData, str::FromStr}; use tiny_keccak::keccak256; pub fn to_bytes(value: u32) -> Result, TransactionError> { @@ -187,9 +187,11 @@ impl Transaction for EthereumTransaction { _network: PhantomData, }; let message = secp256k1::Message::parse_slice(&raw_transaction.to_transaction_id()?.txid)?; - let public_key = EthereumPublicKey::from_secp256k1_public_key( - secp256k1::recover(&message, &secp256k1::Signature::parse_slice(signature.as_slice())?, &recovery_id)?, - ); + let public_key = EthereumPublicKey::from_secp256k1_public_key(secp256k1::recover( + &message, + &secp256k1::Signature::parse_slice(signature.as_slice())?, + &recovery_id, + )?); Ok(Self { sender: Some(public_key.to_address(&EthereumFormat::Standard)?), diff --git a/model/src/address.rs b/model/src/address.rs index ba3ec9fd..b1f96f8a 100644 --- a/model/src/address.rs +++ b/model/src/address.rs @@ -10,7 +10,9 @@ use core::{ }; /// The interface for a generic address. -pub trait Address: 'static + Clone + Debug + Display + FromStr + Hash + PartialEq + Eq + Ord + Send + Sized + Sync { +pub trait Address: + 'static + Clone + Debug + Display + FromStr + Hash + PartialEq + Eq + Ord + Send + Sized + Sync +{ type Format: Format; type PrivateKey: PrivateKey; type PublicKey: PublicKey; diff --git a/model/src/lib.rs b/model/src/lib.rs index 259652f3..dacfafd4 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -6,7 +6,7 @@ #![warn(unused_extern_crates, dead_code)] #![forbid(unsafe_code)] -#[cfg(not(feature="std"))] +#[cfg(not(feature = "std"))] #[allow(unused_imports)] #[doc(hidden)] #[macro_use] diff --git a/model/src/mnemonic.rs b/model/src/mnemonic.rs index 2b0e10d9..04b625d2 100644 --- a/model/src/mnemonic.rs +++ b/model/src/mnemonic.rs @@ -137,4 +137,3 @@ impl From for MnemonicError { MnemonicError::Crate("rand", format!("{:?}", error)) } } - diff --git a/monero/Cargo.toml b/monero/Cargo.toml index 336161fd..6b044d24 100644 --- a/monero/Cargo.toml +++ b/monero/Cargo.toml @@ -18,7 +18,8 @@ edition = "2018" build = "build.rs" [features] -default = [] +default = ["std"] +std = ["wagyu-model/std"] transaction = [] [dependencies] diff --git a/monero/src/address.rs b/monero/src/address.rs index f3742295..cf4e2002 100644 --- a/monero/src/address.rs +++ b/monero/src/address.rs @@ -2,10 +2,11 @@ use crate::format::MoneroFormat; use crate::network::MoneroNetwork; use crate::private_key::MoneroPrivateKey; use crate::public_key::MoneroPublicKey; +use wagyu_model::no_std::{vec, String, ToString}; use wagyu_model::{Address, AddressError, PrivateKey}; use base58_monero as base58; -use std::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; +use core::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; use tiny_keccak::keccak256; /// Represents a Monero address diff --git a/monero/src/amount.rs b/monero/src/amount.rs index 9b4efa9a..63aaad15 100644 --- a/monero/src/amount.rs +++ b/monero/src/amount.rs @@ -1,7 +1,8 @@ +use wagyu_model::no_std::ToString; use wagyu_model::Amount; +use core::fmt; use serde::Serialize; -use std::fmt; // Number of piconeros (base unit) per Monero const COIN: i128 = 1_0000_0000_000; diff --git a/monero/src/format.rs b/monero/src/format.rs index a2f2da56..5f94e02c 100644 --- a/monero/src/format.rs +++ b/monero/src/format.rs @@ -1,8 +1,8 @@ use crate::network::MoneroNetwork; -use wagyu_model::{AddressError, Format}; +use wagyu_model::{no_std::vec, AddressError, Format}; +use core::fmt; use serde::Serialize; -use std::fmt; /// Represents the format of a Monero address #[derive(Serialize, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/monero/src/lib.rs b/monero/src/lib.rs index c88fd537..04e5e05c 100644 --- a/monero/src/lib.rs +++ b/monero/src/lib.rs @@ -1,7 +1,8 @@ //! # Monero //! //! A library for generating Monero wallets. -#![warn(unused_extern_crates)] +#![cfg_attr(not(feature = "std"), no_std)] +#![warn(unused_extern_crates, dead_code)] #[macro_use] extern crate failure; diff --git a/monero/src/mnemonic.rs b/monero/src/mnemonic.rs index 2233fe1b..b28e0320 100644 --- a/monero/src/mnemonic.rs +++ b/monero/src/mnemonic.rs @@ -4,12 +4,16 @@ use crate::network::MoneroNetwork; use crate::private_key::MoneroPrivateKey; use crate::public_key::MoneroPublicKey; use crate::wordlist::MoneroWordlist; -use wagyu_model::{Mnemonic, MnemonicError, PrivateKey}; +use wagyu_model::no_std::vec; +use wagyu_model::{ + no_std::{String, ToString, Vec}, + Mnemonic, MnemonicError, PrivateKey, +}; +use core::{fmt, marker::PhantomData, str, str::FromStr}; use crc::{crc32, Hasher32}; use curve25519_dalek::scalar::Scalar; use rand::Rng; -use std::{fmt, marker::PhantomData, str, str::FromStr}; #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] /// Represents a Monero mnemonic diff --git a/monero/src/network/mainnet.rs b/monero/src/network/mainnet.rs index a68a060c..b8ee54e8 100644 --- a/monero/src/network/mainnet.rs +++ b/monero/src/network/mainnet.rs @@ -1,9 +1,10 @@ use super::*; use crate::format::MoneroFormat; +use wagyu_model::no_std::vec; use wagyu_model::{AddressError, Network, NetworkError}; +use core::{fmt, str::FromStr}; use serde::Serialize; -use std::{fmt, str::FromStr}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Mainnet; diff --git a/monero/src/network/stagenet.rs b/monero/src/network/stagenet.rs index 2a74894b..7001b804 100644 --- a/monero/src/network/stagenet.rs +++ b/monero/src/network/stagenet.rs @@ -1,9 +1,10 @@ use super::*; use crate::format::MoneroFormat; +use wagyu_model::no_std::vec; use wagyu_model::{AddressError, Network, NetworkError}; +use core::{fmt, str::FromStr}; use serde::Serialize; -use std::{fmt, str::FromStr}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Stagenet; diff --git a/monero/src/network/testnet.rs b/monero/src/network/testnet.rs index 7b136fd8..51858cc4 100644 --- a/monero/src/network/testnet.rs +++ b/monero/src/network/testnet.rs @@ -1,9 +1,10 @@ use super::*; use crate::format::MoneroFormat; +use wagyu_model::no_std::vec; use wagyu_model::{AddressError, Network, NetworkError}; +use core::{fmt, str::FromStr}; use serde::Serialize; -use std::{fmt, str::FromStr}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Testnet; diff --git a/monero/src/one_time_key.rs b/monero/src/one_time_key.rs index fde0d446..5a14044d 100644 --- a/monero/src/one_time_key.rs +++ b/monero/src/one_time_key.rs @@ -3,11 +3,12 @@ use crate::network::MoneroNetwork; use crate::private_key::MoneroPrivateKey; use crate::public_key::MoneroPublicKey; +use wagyu_model::no_std::{vec, String, Vec}; use wagyu_model::{PublicKeyError, TransactionError}; +use core::marker::PhantomData; use curve25519_dalek::edwards::{CompressedEdwardsY, EdwardsPoint}; use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, edwards::EdwardsBasepointTable, scalar::Scalar}; -use std::marker::PhantomData; use tiny_keccak::keccak256; #[derive(Debug, Fail)] diff --git a/monero/src/private_key.rs b/monero/src/private_key.rs index d598e109..149a6277 100644 --- a/monero/src/private_key.rs +++ b/monero/src/private_key.rs @@ -2,12 +2,12 @@ use crate::address::MoneroAddress; use crate::format::MoneroFormat; use crate::network::MoneroNetwork; use crate::public_key::MoneroPublicKey; -use wagyu_model::{Address, AddressError, PrivateKey, PrivateKeyError, PublicKey}; +use wagyu_model::{no_std::Vec, Address, AddressError, PrivateKey, PrivateKeyError, PublicKey}; +use core::{fmt, fmt::Display, marker::PhantomData, str::FromStr}; use curve25519_dalek::scalar::Scalar; use hex; use rand::Rng; -use std::{fmt, fmt::Display, marker::PhantomData, str::FromStr}; use tiny_keccak::keccak256; /// Represents a Monero private key diff --git a/monero/src/public_key.rs b/monero/src/public_key.rs index bbaa7946..7dc47dbb 100644 --- a/monero/src/public_key.rs +++ b/monero/src/public_key.rs @@ -4,8 +4,8 @@ use crate::network::MoneroNetwork; use crate::private_key::MoneroPrivateKey; use wagyu_model::{Address, AddressError, PublicKey, PublicKeyError}; +use core::{fmt, fmt::Display, marker::PhantomData, str::FromStr}; use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, edwards::EdwardsBasepointTable, scalar::Scalar}; -use std::{fmt, fmt::Display, marker::PhantomData, str::FromStr}; /// Represents a Monero public key #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/monero/src/transaction.rs b/monero/src/transaction.rs index 0ab9af5f..1828abd7 100644 --- a/monero/src/transaction.rs +++ b/monero/src/transaction.rs @@ -8,13 +8,13 @@ use crate::private_key::MoneroPrivateKey; use crate::public_key::MoneroPublicKey; use wagyu_model::{Transaction, TransactionError, TransactionId}; -use libc::c_char; -use serde::{export::PhantomData, Deserialize, Serialize}; -use serde_json; -use std::{ +use core::{ ffi::{CStr, CString}, fmt, str, }; +use libc::c_char; +use serde::{export::PhantomData, Deserialize, Serialize}; +use serde_json; /// Represents a Monero transaction #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] diff --git a/monero/src/wordlist/mod.rs b/monero/src/wordlist/mod.rs index e1c6bcc1..0329410f 100644 --- a/monero/src/wordlist/mod.rs +++ b/monero/src/wordlist/mod.rs @@ -1,3 +1,4 @@ +use wagyu_model::no_std::{String, Vec}; use wagyu_model::wordlist::{Wordlist, WordlistError}; pub mod chinese_simplified; diff --git a/wagyu/cli/bitcoin.rs b/wagyu/cli/bitcoin.rs index 9cb3dd1f..5c7dca9d 100644 --- a/wagyu/cli/bitcoin.rs +++ b/wagyu/cli/bitcoin.rs @@ -13,11 +13,13 @@ use crate::model::{ use clap::{ArgMatches, Values}; use colored::*; +use core::{fmt, fmt::Display, str::FromStr}; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; use serde::{Deserialize, Serialize}; use serde_json::from_str; -use std::{fmt, fmt::Display, str::FromStr}; + +use crate::model::no_std::{format, vec, String, ToOwned, ToString, Vec}; /// Represents a generic wallet to output #[derive(Serialize, Debug, Default)] diff --git a/wagyu/cli/ethereum.rs b/wagyu/cli/ethereum.rs index 236bf244..b1642a57 100644 --- a/wagyu/cli/ethereum.rs +++ b/wagyu/cli/ethereum.rs @@ -12,11 +12,13 @@ use crate::model::{ use clap::{ArgMatches, Values}; use colored::*; +use core::{fmt, fmt::Display, str::FromStr}; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; use serde::{Deserialize, Serialize}; use serde_json::from_str; -use std::{fmt, fmt::Display, str::FromStr}; + +use crate::model::no_std::{format, vec, String, ToOwned, ToString, Vec}; /// Represents a generic wallet to output #[derive(Serialize, Debug, Default)] @@ -564,12 +566,14 @@ impl EthereumOptions { let start = self.index; let end = start + self.indices; let mut options = self.clone(); - (start..end).map(|index| { - // Sets the index to the specified index - options.index(Some(index)); - // Generates the derivation path for the specified information - options.to_derivation_path(default) - }).collect() + (start..end) + .map(|index| { + // Sets the index to the specified index + options.index(Some(index)); + // Generates the derivation path for the specified information + options.to_derivation_path(default) + }) + .collect() } } @@ -599,7 +603,10 @@ impl CLI for EthereumCLI { ("hd", Some(arguments)) => { options.subcommand = Some("hd".into()); options.parse(arguments, &["count", "json"]); - options.parse(arguments, &["derivation", "index", "indices", "language", "password", "word count"]); + options.parse( + arguments, + &["derivation", "index", "indices", "language", "password", "word count"], + ); } ("import", Some(arguments)) => { options.subcommand = Some("import".into()); @@ -650,17 +657,24 @@ impl CLI for EthereumCLI { password, &options.to_derivation_path(true).unwrap(), ) - .unwrap(); + .unwrap(); let mnemonic = &wallet.mnemonic.unwrap(); // Generate the HD wallet, from `index` to a number of specified `indices` - options.to_derivation_paths(true).iter().flat_map(|path| { - match EthereumWallet::from_mnemonic::(mnemonic, password, path.as_ref().unwrap()) { - Ok(wallet) => vec![wallet], - _ => vec![], - } - }) - .collect::>() + options + .to_derivation_paths(true) + .iter() + .flat_map(|path| { + match EthereumWallet::from_mnemonic::( + mnemonic, + password, + path.as_ref().unwrap(), + ) { + Ok(wallet) => vec![wallet], + _ => vec![], + } + }) + .collect::>() }) .collect() } @@ -685,7 +699,11 @@ impl CLI for EthereumCLI { let mut wallets = vec![]; let password = options.password.as_ref().map(String::as_str); for path in options.to_derivation_paths(true) { - wallets.push(EthereumWallet::from_mnemonic::(mnemonic, password, path.as_ref().unwrap())?); + wallets.push(EthereumWallet::from_mnemonic::( + mnemonic, + password, + path.as_ref().unwrap(), + )?); } Ok(wallets) } @@ -700,22 +718,28 @@ impl CLI for EthereumCLI { .or(process_mnemonic::(&mnemonic, &options))? } else if let Some(extended_private_key) = options.extended_private_key.clone() { // Generate the extended private keys, from `index` to a number of specified `indices` - options.to_derivation_paths(true).iter().flat_map(|path| { - match EthereumWallet::from_extended_private_key::(&extended_private_key, path) { - Ok(wallet) => vec![wallet], - _ => vec![], - } - }) - .collect::>() + options + .to_derivation_paths(true) + .iter() + .flat_map(|path| { + match EthereumWallet::from_extended_private_key::(&extended_private_key, path) { + Ok(wallet) => vec![wallet], + _ => vec![], + } + }) + .collect::>() } else if let Some(extended_public_key) = options.extended_public_key.clone() { // Generate the extended public keys, from `index` to a number of specified `indices` - options.to_derivation_paths(true).iter().flat_map(|path| { - match EthereumWallet::from_extended_public_key::(&extended_public_key, path) { - Ok(wallet) => vec![wallet], - _ => vec![], - } - }) - .collect::>() + options + .to_derivation_paths(true) + .iter() + .flat_map(|path| { + match EthereumWallet::from_extended_public_key::(&extended_public_key, path) { + Ok(wallet) => vec![wallet], + _ => vec![], + } + }) + .collect::>() } else { vec![] } diff --git a/wagyu/cli/mod.rs b/wagyu/cli/mod.rs index 3c448756..ceae86a2 100644 --- a/wagyu/cli/mod.rs +++ b/wagyu/cli/mod.rs @@ -15,6 +15,8 @@ use types::*; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; +use crate::model::no_std::{format, String, Vec}; + pub trait CLI { type Options; diff --git a/wagyu/cli/monero.rs b/wagyu/cli/monero.rs index ee593058..e916cbbb 100644 --- a/wagyu/cli/monero.rs +++ b/wagyu/cli/monero.rs @@ -7,10 +7,12 @@ use crate::monero::{ use clap::{ArgMatches, Values}; use colored::*; +use core::{fmt, fmt::Display, str::FromStr}; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; use serde::Serialize; -use std::{fmt, fmt::Display, str::FromStr}; + +use crate::model::no_std::{format, vec, String, ToOwned, ToString, Vec}; /// Represents a generic wallet to output #[derive(Serialize, Debug, Default)] diff --git a/wagyu/cli/zcash.rs b/wagyu/cli/zcash.rs index 275a583a..96ccba66 100644 --- a/wagyu/cli/zcash.rs +++ b/wagyu/cli/zcash.rs @@ -9,11 +9,13 @@ use crate::zcash::{ use clap::{ArgMatches, Values}; use colored::*; +use core::{fmt, fmt::Display, str::FromStr}; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; use serde::{Deserialize, Serialize}; use serde_json::from_str; -use std::{fmt, fmt::Display, str::FromStr}; + +use crate::model::no_std::{format, vec, String, ToOwned, ToString, Vec}; /// Represents values to derive standard wallets #[derive(Serialize, Clone, Debug)] diff --git a/wagyu/lib.rs b/wagyu/lib.rs index 9b3559be..a8c7bedf 100644 --- a/wagyu/lib.rs +++ b/wagyu/lib.rs @@ -1,3 +1,6 @@ +#![warn(unused_extern_crates, dead_code)] +#![forbid(unsafe_code)] + #[macro_use] extern crate failure; diff --git a/zcash/Cargo.toml b/zcash/Cargo.toml index c020fa73..74591571 100644 --- a/zcash/Cargo.toml +++ b/zcash/Cargo.toml @@ -49,6 +49,12 @@ serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } sha2 = { version = "0.8" } +failure = { version = "0.1.8", default-features = false, features = ["derive"] } + +[features] +default = ["std"] +std = ["wagyu-model/std"] + [dev-dependencies] # librustzcash fork dependencies hex-literal = { version = "0.2" } diff --git a/zcash/src/address.rs b/zcash/src/address.rs index a9e6827e..fe4c4a06 100644 --- a/zcash/src/address.rs +++ b/zcash/src/address.rs @@ -4,6 +4,7 @@ use crate::librustzcash::JUBJUB; use crate::network::ZcashNetwork; use crate::private_key::ZcashPrivateKey; use crate::public_key::{P2PKHViewingKey, SaplingFullViewingKey, SproutViewingKey, ZcashPublicKey}; +use wagyu_model::no_std::{vec, String, ToString, Vec}; use wagyu_model::{ crypto::{checksum, hash160}, Address, AddressError, PrivateKey, @@ -11,11 +12,11 @@ use wagyu_model::{ use base58::{FromBase58, ToBase58}; use bech32::{Bech32, FromBase32, ToBase32}; +use core::{convert::TryFrom, fmt, marker::PhantomData, str, str::FromStr}; use curve25519_dalek::constants::ED25519_BASEPOINT_TABLE; use curve25519_dalek::scalar::Scalar; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; -use std::{convert::TryFrom, fmt, marker::PhantomData, str, str::FromStr}; /// Represents a Zcash address #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/zcash/src/amount.rs b/zcash/src/amount.rs index 4cc502c5..7b4a24a1 100644 --- a/zcash/src/amount.rs +++ b/zcash/src/amount.rs @@ -1,7 +1,8 @@ +use wagyu_model::no_std::ToString; use wagyu_model::{Amount, AmountError}; +use core::fmt; use serde::Serialize; -use std::fmt; // Number of zatoshis (base unit) per ZEC const COIN: i64 = 1_0000_0000; diff --git a/zcash/src/derivation_path.rs b/zcash/src/derivation_path.rs index 3cd66b78..f131374d 100644 --- a/zcash/src/derivation_path.rs +++ b/zcash/src/derivation_path.rs @@ -1,7 +1,8 @@ use crate::network::ZcashNetwork; use wagyu_model::derivation_path::{ChildIndex, DerivationPath, DerivationPathError}; +use wagyu_model::no_std::{vec, ToString, Vec}; -use std::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; +use core::{convert::TryFrom, fmt, marker::PhantomData, str::FromStr}; /// Represents a Zcash derivation path #[derive(Clone, PartialEq, Eq)] diff --git a/zcash/src/extended_private_key.rs b/zcash/src/extended_private_key.rs index 50dd9dcb..922e93ed 100644 --- a/zcash/src/extended_private_key.rs +++ b/zcash/src/extended_private_key.rs @@ -6,13 +6,14 @@ use crate::librustzcash::zip32::ExtendedSpendingKey; use crate::network::ZcashNetwork; use crate::private_key::{SaplingSpendingKey, ZcashPrivateKey}; use crate::public_key::ZcashPublicKey; +use wagyu_model::no_std::{vec, ToString, Vec}; use wagyu_model::{ Address, AddressError, ChildIndex, DerivationPath, ExtendedPrivateKey, ExtendedPrivateKeyError, ExtendedPublicKey, PublicKey, }; use bech32::{Bech32, FromBase32, ToBase32}; -use std::{cmp::Ordering, fmt, fmt::Display, marker::PhantomData, str::FromStr}; +use core::{cmp::Ordering, fmt, fmt::Display, marker::PhantomData, str::FromStr}; /// Represents a Zcash extended private key #[derive(Debug, Clone)] diff --git a/zcash/src/extended_public_key.rs b/zcash/src/extended_public_key.rs index 4ae585a9..6d5b2138 100644 --- a/zcash/src/extended_public_key.rs +++ b/zcash/src/extended_public_key.rs @@ -5,12 +5,13 @@ use crate::format::ZcashFormat; use crate::librustzcash::zip32::ExtendedFullViewingKey; use crate::network::ZcashNetwork; use crate::public_key::ZcashPublicKey; +use wagyu_model::no_std::{vec, ToString, Vec}; use wagyu_model::{ Address, AddressError, ChildIndex, DerivationPath, DerivationPathError, ExtendedPublicKey, ExtendedPublicKeyError, }; use bech32::{Bech32, FromBase32, ToBase32}; -use std::{cmp::Ordering, fmt, fmt::Display, str::FromStr}; +use core::{cmp::Ordering, fmt, fmt::Display, str::FromStr}; /// Represents a Zcash extended public key #[derive(Debug, Clone)] diff --git a/zcash/src/format.rs b/zcash/src/format.rs index bc157663..3081056b 100644 --- a/zcash/src/format.rs +++ b/zcash/src/format.rs @@ -1,8 +1,9 @@ use crate::network::ZcashNetwork; +use wagyu_model::no_std::Vec; use wagyu_model::{AddressError, Format}; +use core::fmt; use serde::Serialize; -use std::fmt; /// Represents the format of a Zcash address #[derive(Serialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/zcash/src/lib.rs b/zcash/src/lib.rs index bf9f6d9c..0b85c66b 100644 --- a/zcash/src/lib.rs +++ b/zcash/src/lib.rs @@ -1,9 +1,19 @@ //! # Zcash //! //! A library for generating Zcash wallets. -#![warn(unused_extern_crates)] +#![cfg_attr(not(feature = "std"), no_std)] +#![warn(unused_extern_crates, dead_code)] #![forbid(unsafe_code)] +#[cfg(not(feature = "std"))] +#[allow(unused_imports)] +#[doc(hidden)] +#[macro_use] +extern crate alloc; + +#[macro_use] +extern crate failure; + #[cfg(test)] #[macro_use] extern crate hex_literal; diff --git a/zcash/src/librustzcash/algebra/curve/bls12_381/ec.rs b/zcash/src/librustzcash/algebra/curve/bls12_381/ec.rs index fc773d72..78c561df 100644 --- a/zcash/src/librustzcash/algebra/curve/bls12_381/ec.rs +++ b/zcash/src/librustzcash/algebra/curve/bls12_381/ec.rs @@ -10,6 +10,8 @@ macro_rules! curve_impl { $compressed:ident, $pairing:ident ) => { + use wagyu_model::no_std::Vec; + #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct $affine { pub(crate) x: $basefield, @@ -17,8 +19,8 @@ macro_rules! curve_impl { pub(crate) infinity: bool, } - impl ::std::fmt::Display for $affine { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + impl ::core::fmt::Display for $affine { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if self.infinity { write!(f, "{}(Infinity)", $name) } else { @@ -34,8 +36,8 @@ macro_rules! curve_impl { pub(crate) z: $basefield, } - impl ::std::fmt::Display for $projective { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + impl ::core::fmt::Display for $projective { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "{}", self.into_affine()) } } @@ -619,8 +621,8 @@ pub mod g1 { use crate::librustzcash::algebra::field::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField}; use crate::librustzcash::algebra::group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}; + use core::fmt; use rand_core::RngCore; - use std::fmt; curve_impl!( "G1", @@ -1283,8 +1285,8 @@ pub mod g2 { use crate::librustzcash::algebra::field::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField}; use crate::librustzcash::algebra::group::{CurveAffine, CurveProjective, EncodedPoint, GroupDecodingError}; + use core::fmt; use rand_core::RngCore; - use std::fmt; curve_impl!( "G2", G2, diff --git a/zcash/src/librustzcash/algebra/curve/bls12_381/fq12.rs b/zcash/src/librustzcash/algebra/curve/bls12_381/fq12.rs index 0301a05e..3218e3a6 100644 --- a/zcash/src/librustzcash/algebra/curve/bls12_381/fq12.rs +++ b/zcash/src/librustzcash/algebra/curve/bls12_381/fq12.rs @@ -12,8 +12,8 @@ pub struct Fq12 { pub c1: Fq6, } -impl ::std::fmt::Display for Fq12 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +impl ::core::fmt::Display for Fq12 { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "Fq12({} + {} * w)", self.c0, self.c1) } } diff --git a/zcash/src/librustzcash/algebra/curve/bls12_381/fq2.rs b/zcash/src/librustzcash/algebra/curve/bls12_381/fq2.rs index 688710e7..ad744904 100644 --- a/zcash/src/librustzcash/algebra/curve/bls12_381/fq2.rs +++ b/zcash/src/librustzcash/algebra/curve/bls12_381/fq2.rs @@ -1,8 +1,8 @@ use super::fq::{Fq, FROBENIUS_COEFF_FQ2_C1, NEGATIVE_ONE}; use crate::librustzcash::algebra::field::{Field, LegendreSymbol, SqrtField}; +use core::cmp::Ordering; use rand_core::RngCore; -use std::cmp::Ordering; /// An element of Fq2, represented by c0 + c1 * u. #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -11,8 +11,8 @@ pub struct Fq2 { pub c1: Fq, } -impl ::std::fmt::Display for Fq2 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +impl ::core::fmt::Display for Fq2 { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "Fq2({} + {} * u)", self.c0, self.c1) } } diff --git a/zcash/src/librustzcash/algebra/curve/bls12_381/fq6.rs b/zcash/src/librustzcash/algebra/curve/bls12_381/fq6.rs index 807c3aba..4a4d198b 100644 --- a/zcash/src/librustzcash/algebra/curve/bls12_381/fq6.rs +++ b/zcash/src/librustzcash/algebra/curve/bls12_381/fq6.rs @@ -12,8 +12,8 @@ pub struct Fq6 { pub c2: Fq2, } -impl ::std::fmt::Display for Fq6 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +impl ::core::fmt::Display for Fq6 { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "Fq6({} + {} * v, {} * v^2)", self.c0, self.c1, self.c2) } } @@ -21,7 +21,7 @@ impl ::std::fmt::Display for Fq6 { impl Fq6 { /// Multiply by quadratic nonresidue v. pub fn mul_by_nonresidue(&mut self) { - use std::mem::swap; + use core::mem::swap; swap(&mut self.c0, &mut self.c1); swap(&mut self.c0, &mut self.c2); diff --git a/zcash/src/librustzcash/algebra/curve/bls12_381/mod.rs b/zcash/src/librustzcash/algebra/curve/bls12_381/mod.rs index b449e1ee..38b16314 100644 --- a/zcash/src/librustzcash/algebra/curve/bls12_381/mod.rs +++ b/zcash/src/librustzcash/algebra/curve/bls12_381/mod.rs @@ -22,6 +22,8 @@ use super::{Engine, PairingCurveAffine}; use crate::librustzcash::algebra::field::{BitIterator, Field, ScalarEngine}; use crate::librustzcash::algebra::group::CurveAffine; +use wagyu_model::no_std::vec; + // The BLS parameter x for BLS12-381 is -0xd201000000010000 const BLS_X: u64 = 0xd201000000010000; const BLS_X_IS_NEGATIVE: bool = true; diff --git a/zcash/src/librustzcash/algebra/field/field-derive/src/lib.rs b/zcash/src/librustzcash/algebra/field/field-derive/src/lib.rs index 8290c7c3..839f2c76 100644 --- a/zcash/src/librustzcash/algebra/field/field-derive/src/lib.rs +++ b/zcash/src/librustzcash/algebra/field/field-derive/src/lib.rs @@ -1,14 +1,32 @@ #![recursion_limit = "1024"] +#![cfg_attr(not(feature = "std"), no_std)] extern crate proc_macro; #[macro_use] extern crate quote; +use core::str::FromStr; use num_bigint::BigUint; use num_integer::Integer; use num_traits::{One, ToPrimitive, Zero}; use quote::TokenStreamExt; -use std::str::FromStr; + +#[cfg(not(feature = "std"))] +#[allow(unused_imports)] +#[doc(hidden)] +#[macro_use] +extern crate alloc; + +#[cfg(not(feature = "std"))] +use alloc::{ + string::{String, ToString}, + vec::Vec, +}; +#[cfg(feature = "std")] +use std::{ + string::{String, ToString}, + vec::Vec, +}; #[proc_macro_derive(PrimeField, attributes(PrimeFieldModulus, PrimeFieldGenerator))] pub fn prime_field(input: proc_macro::TokenStream) -> proc_macro::TokenStream { @@ -113,9 +131,9 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS #[derive(Copy, Clone, PartialEq, Eq, Default)] pub struct #repr(pub [u64; #limbs]); - impl ::std::fmt::Debug for #repr + impl ::core::fmt::Debug for #repr { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "0x")?; for i in self.0.iter().rev() { write!(f, "{:016x}", *i)?; @@ -125,8 +143,8 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS } } - impl ::std::fmt::Display for #repr { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + impl ::core::fmt::Display for #repr { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "0x")?; for i in self.0.iter().rev() { write!(f, "{:016x}", *i)?; @@ -153,7 +171,7 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS impl From for #repr { #[inline(always)] fn from(val: u64) -> #repr { - use std::default::Default; + use core::default::Default; let mut repr = Self::default(); repr.0[0] = val; @@ -163,22 +181,22 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS impl Ord for #repr { #[inline(always)] - fn cmp(&self, other: &#repr) -> ::std::cmp::Ordering { + fn cmp(&self, other: &#repr) -> ::core::cmp::Ordering { for (a, b) in self.0.iter().rev().zip(other.0.iter().rev()) { if a < b { - return ::std::cmp::Ordering::Less + return ::core::cmp::Ordering::Less } else if a > b { - return ::std::cmp::Ordering::Greater + return ::core::cmp::Ordering::Greater } } - ::std::cmp::Ordering::Equal + ::core::cmp::Ordering::Equal } } impl PartialOrd for #repr { #[inline(always)] - fn partial_cmp(&self, other: &#repr) -> Option<::std::cmp::Ordering> { + fn partial_cmp(&self, other: &#repr) -> Option<::core::cmp::Ordering> { Some(self.cmp(other)) } } @@ -209,7 +227,7 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS while n >= 64 { let mut t = 0; for i in self.0.iter_mut().rev() { - ::std::mem::swap(&mut t, i); + ::core::mem::swap(&mut t, i); } n -= 64; } @@ -257,7 +275,7 @@ fn prime_field_repr_impl(repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenS while n >= 64 { let mut t = 0; for i in &mut self.0 { - ::std::mem::swap(&mut t, i); + ::core::mem::swap(&mut t, i); } n -= 64; } @@ -556,7 +574,11 @@ fn prime_field_constants_and_sqrt( fn prime_field_impl(name: &syn::Ident, repr: &syn::Ident, limbs: usize) -> proc_macro2::TokenStream { // Returns r{n} as an ident. fn get_temp(n: usize) -> syn::Ident { - syn::Ident::new(&format!("r{}", n), proc_macro2::Span::call_site()) + #[cfg(not(feature = "std"))] + return syn::Ident::new(&alloc::format!("r{}", n), proc_macro2::Span::call_site()); + + #[cfg(feature = "std")] + return syn::Ident::new(&std::format!("r{}", n), proc_macro2::Span::call_site()); } // The parameter list for the mont_reduce() internal method. @@ -764,25 +786,25 @@ fn prime_field_impl(name: &syn::Ident, repr: &syn::Ident, limbs: usize) -> proc_ let top_limb_index = limbs - 1; quote! { - impl ::std::marker::Copy for #name { } + impl ::core::marker::Copy for #name { } - impl ::std::clone::Clone for #name { + impl ::core::clone::Clone for #name { fn clone(&self) -> #name { *self } } - impl ::std::cmp::PartialEq for #name { + impl ::core::cmp::PartialEq for #name { fn eq(&self, other: &#name) -> bool { self.0 == other.0 } } - impl ::std::cmp::Eq for #name { } + impl ::core::cmp::Eq for #name { } - impl ::std::fmt::Debug for #name + impl ::core::fmt::Debug for #name { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "{}({:?})", stringify!(#name), self.into_repr()) } } @@ -790,20 +812,20 @@ fn prime_field_impl(name: &syn::Ident, repr: &syn::Ident, limbs: usize) -> proc_ /// Elements are ordered lexicographically. impl Ord for #name { #[inline(always)] - fn cmp(&self, other: &#name) -> ::std::cmp::Ordering { + fn cmp(&self, other: &#name) -> ::core::cmp::Ordering { self.into_repr().cmp(&other.into_repr()) } } impl PartialOrd for #name { #[inline(always)] - fn partial_cmp(&self, other: &#name) -> Option<::std::cmp::Ordering> { + fn partial_cmp(&self, other: &#name) -> Option<::core::cmp::Ordering> { Some(self.cmp(other)) } } - impl ::std::fmt::Display for #name { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + impl ::core::fmt::Display for #name { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "{}({})", stringify!(#name), self.into_repr()) } } @@ -824,7 +846,11 @@ fn prime_field_impl(name: &syn::Ident, repr: &syn::Ident, limbs: usize) -> proc_ Ok(r) } else { - Err(PrimeFieldDecodingError::NotInField(format!("{}", r.0))) + #[cfg(not(feature = "std"))] + return Err(PrimeFieldDecodingError::NotInField(alloc::format!("{}", r.0))); + + #[cfg(feature = "std")] + return Err(PrimeFieldDecodingError::NotInField(std::format!("{}", r.0))); } } diff --git a/zcash/src/librustzcash/algebra/field/mod.rs b/zcash/src/librustzcash/algebra/field/mod.rs index 59e8d0c0..72aabb38 100644 --- a/zcash/src/librustzcash/algebra/field/mod.rs +++ b/zcash/src/librustzcash/algebra/field/mod.rs @@ -1,9 +1,10 @@ pub use field_derive::*; +use core::fmt; use rand_core::RngCore; -use std::error::Error; -use std::fmt; -use std::io::{self, Read, Write}; + +use wagyu_model::no_std::io::{self, Read, Write}; +use wagyu_model::no_std::String; /// This trait represents an element of a field. pub trait Field: Sized + Eq + Copy + Clone + Send + Sync + fmt::Debug + fmt::Display + 'static { @@ -183,28 +184,13 @@ pub enum LegendreSymbol { /// An error that may occur when trying to interpret a `PrimeFieldRepr` as a /// `PrimeField` element. -#[derive(Debug)] +#[derive(Debug, Fail)] pub enum PrimeFieldDecodingError { /// The encoded value is not in the field + #[fail(display = "{} is not an element of the field", _0)] NotInField(String), } -impl Error for PrimeFieldDecodingError { - fn description(&self) -> &str { - match *self { - PrimeFieldDecodingError::NotInField(..) => "not an element of the field", - } - } -} - -impl fmt::Display for PrimeFieldDecodingError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - PrimeFieldDecodingError::NotInField(ref repr) => write!(f, "{} is not an element of the field", repr), - } - } -} - /// This represents an element of a prime field. pub trait PrimeField: Field { /// The prime field can be converted back and forth into this biginteger diff --git a/zcash/src/librustzcash/algebra/group/mod.rs b/zcash/src/librustzcash/algebra/group/mod.rs index 4a99c632..fa4815bc 100644 --- a/zcash/src/librustzcash/algebra/group/mod.rs +++ b/zcash/src/librustzcash/algebra/group/mod.rs @@ -1,8 +1,7 @@ use crate::librustzcash::algebra::field::{PrimeField, PrimeFieldDecodingError, ScalarEngine, SqrtField}; +use core::fmt; use rand::RngCore; -use std::error::Error; -use std::fmt; #[cfg(test)] pub mod tests; @@ -144,39 +143,21 @@ pub trait EncodedPoint: Sized + Send + Sync + AsRef<[u8]> + AsMut<[u8]> + Clone } /// An error that may occur when trying to decode an `EncodedPoint`. -#[derive(Debug)] +#[derive(Debug, Fail)] pub enum GroupDecodingError { /// The coordinate(s) do not lie on the curve. + #[fail(display = "coordinate(s) do not lie on the curve")] NotOnCurve, /// The element is not part of the r-order subgroup. + #[fail(display = "the element is not part of an r-order subgroup")] NotInSubgroup, /// One of the coordinates could not be decoded + #[fail(display = "{} decoding error: {}", _0, _1)] CoordinateDecodingError(&'static str, PrimeFieldDecodingError), /// The compression mode of the encoded element was not as expected + #[fail(display = "encoding has unexpected compression mode")] UnexpectedCompressionMode, /// The encoding contained bits that should not have been set + #[fail(display = "encoding has unexpected information")] UnexpectedInformation, } - -impl Error for GroupDecodingError { - fn description(&self) -> &str { - match *self { - GroupDecodingError::NotOnCurve => "coordinate(s) do not lie on the curve", - GroupDecodingError::NotInSubgroup => "the element is not part of an r-order subgroup", - GroupDecodingError::CoordinateDecodingError(..) => "coordinate(s) could not be decoded", - GroupDecodingError::UnexpectedCompressionMode => "encoding has unexpected compression mode", - GroupDecodingError::UnexpectedInformation => "encoding has unexpected information", - } - } -} - -impl fmt::Display for GroupDecodingError { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - GroupDecodingError::CoordinateDecodingError(description, ref err) => { - write!(f, "{} decoding error: {}", description, err) - } - _ => write!(f, "{}", self.description()), - } - } -} diff --git a/zcash/src/librustzcash/sapling_crypto/jubjub/edwards.rs b/zcash/src/librustzcash/sapling_crypto/jubjub/edwards.rs index 0b378f3f..c9562b12 100644 --- a/zcash/src/librustzcash/sapling_crypto/jubjub/edwards.rs +++ b/zcash/src/librustzcash/sapling_crypto/jubjub/edwards.rs @@ -3,9 +3,8 @@ use crate::librustzcash::sapling_crypto::jubjub::{montgomery, JubjubEngine, Jubj use rand_core::RngCore; -use std::marker::PhantomData; - -use std::io::{self, Read, Write}; +use core::marker::PhantomData; +use wagyu_model::no_std::io::{self, Read, Write}; // Represents the affine point (X/Z, Y/Z) via the extended // twisted Edwards coordinates. diff --git a/zcash/src/librustzcash/sapling_crypto/jubjub/fs.rs b/zcash/src/librustzcash/sapling_crypto/jubjub/fs.rs index 026be6dc..b4ed613b 100644 --- a/zcash/src/librustzcash/sapling_crypto/jubjub/fs.rs +++ b/zcash/src/librustzcash/sapling_crypto/jubjub/fs.rs @@ -7,6 +7,8 @@ use crate::librustzcash::algebra::field::{ use byteorder::{ByteOrder, LittleEndian}; use rand_core::RngCore; +use wagyu_model::no_std::format; + use super::ToUniform; // s = 6554484396890773809930967563523245729705921265872317281365359162392183254199 @@ -74,8 +76,8 @@ const NEGATIVE_ONE: Fs = Fs(FsRepr([ #[derive(Copy, Clone, PartialEq, Eq, Default, Debug)] pub struct FsRepr(pub [u64; 4]); -impl ::std::fmt::Display for FsRepr { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +impl ::core::fmt::Display for FsRepr { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "0x")?; for i in self.0.iter().rev() { write!(f, "{:016x}", *i)?; @@ -110,22 +112,22 @@ impl From for FsRepr { impl Ord for FsRepr { #[inline(always)] - fn cmp(&self, other: &FsRepr) -> ::std::cmp::Ordering { + fn cmp(&self, other: &FsRepr) -> ::core::cmp::Ordering { for (a, b) in self.0.iter().rev().zip(other.0.iter().rev()) { if a < b { - return ::std::cmp::Ordering::Less; + return ::core::cmp::Ordering::Less; } else if a > b { - return ::std::cmp::Ordering::Greater; + return ::core::cmp::Ordering::Greater; } } - ::std::cmp::Ordering::Equal + ::core::cmp::Ordering::Equal } } impl PartialOrd for FsRepr { #[inline(always)] - fn partial_cmp(&self, other: &FsRepr) -> Option<::std::cmp::Ordering> { + fn partial_cmp(&self, other: &FsRepr) -> Option<::core::cmp::Ordering> { Some(self.cmp(other)) } } @@ -156,7 +158,7 @@ impl PrimeFieldRepr for FsRepr { while n >= 64 { let mut t = 0; for i in self.0.iter_mut().rev() { - ::std::mem::swap(&mut t, i); + ::core::mem::swap(&mut t, i); } n -= 64; } @@ -204,7 +206,7 @@ impl PrimeFieldRepr for FsRepr { while n >= 64 { let mut t = 0; for i in &mut self.0 { - ::std::mem::swap(&mut t, i); + ::core::mem::swap(&mut t, i); } n -= 64; } @@ -257,8 +259,8 @@ impl PrimeFieldRepr for FsRepr { #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Fs(FsRepr); -impl ::std::fmt::Display for Fs { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { +impl ::core::fmt::Display for Fs { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { write!(f, "Fs({})", self.into_repr()) } } @@ -661,7 +663,7 @@ use rand_xorshift::XorShiftRng; fn test_fs_repr_ordering() { fn assert_equality(a: FsRepr, b: FsRepr) { assert_eq!(a, b); - assert!(a.cmp(&b) == ::std::cmp::Ordering::Equal); + assert!(a.cmp(&b) == ::core::cmp::Ordering::Equal); } fn assert_lt(a: FsRepr, b: FsRepr) { diff --git a/zcash/src/librustzcash/sapling_crypto/jubjub/mod.rs b/zcash/src/librustzcash/sapling_crypto/jubjub/mod.rs index 92760185..9efd4146 100644 --- a/zcash/src/librustzcash/sapling_crypto/jubjub/mod.rs +++ b/zcash/src/librustzcash/sapling_crypto/jubjub/mod.rs @@ -23,6 +23,8 @@ use crate::librustzcash::algebra::field::{Field, PrimeField, SqrtField}; use crate::librustzcash::sapling_crypto::constants; use crate::librustzcash::sapling_crypto::group_hash::group_hash; +use wagyu_model::no_std::{vec, Vec}; + /// This is an implementation of the twisted Edwards Jubjub curve. pub mod edwards; diff --git a/zcash/src/librustzcash/sapling_crypto/jubjub/montgomery.rs b/zcash/src/librustzcash/sapling_crypto/jubjub/montgomery.rs index 80f808a4..33395470 100644 --- a/zcash/src/librustzcash/sapling_crypto/jubjub/montgomery.rs +++ b/zcash/src/librustzcash/sapling_crypto/jubjub/montgomery.rs @@ -1,8 +1,8 @@ use crate::librustzcash::algebra::field::{BitIterator, Field, PrimeField, PrimeFieldRepr, SqrtField}; use crate::librustzcash::sapling_crypto::jubjub::{edwards, JubjubEngine, JubjubParams, PrimeOrder, Unknown}; +use core::marker::PhantomData; use rand_core::RngCore; -use std::marker::PhantomData; // Represents the affine point (X, Y) pub struct Point { diff --git a/zcash/src/librustzcash/sapling_crypto/pedersen_hash.rs b/zcash/src/librustzcash/sapling_crypto/pedersen_hash.rs index 4c265818..9d1b0417 100644 --- a/zcash/src/librustzcash/sapling_crypto/pedersen_hash.rs +++ b/zcash/src/librustzcash/sapling_crypto/pedersen_hash.rs @@ -1,6 +1,8 @@ use crate::librustzcash::algebra::field::{Field, PrimeField, PrimeFieldRepr}; use crate::librustzcash::sapling_crypto::jubjub::*; +use wagyu_model::no_std::{vec, Vec}; + #[derive(Copy, Clone)] pub enum Personalization { NoteCommitment, diff --git a/zcash/src/librustzcash/sapling_crypto/primitives/mod.rs b/zcash/src/librustzcash/sapling_crypto/primitives/mod.rs index 6d7da8c3..106d76dc 100644 --- a/zcash/src/librustzcash/sapling_crypto/primitives/mod.rs +++ b/zcash/src/librustzcash/sapling_crypto/primitives/mod.rs @@ -8,6 +8,8 @@ use byteorder::{LittleEndian, WriteBytesExt}; use blake2s_simd::Params as Blake2sParams; +use wagyu_model::no_std::{vec, Vec}; + #[derive(Clone)] pub struct ValueCommitment { pub value: u64, diff --git a/zcash/src/librustzcash/zip32.rs b/zcash/src/librustzcash/zip32.rs index c57b419e..8893249b 100644 --- a/zcash/src/librustzcash/zip32.rs +++ b/zcash/src/librustzcash/zip32.rs @@ -8,14 +8,15 @@ use crate::librustzcash::JUBJUB; use crate::network::ZcashNetwork; use crate::private_key::{SaplingOutgoingViewingKey, SaplingSpendingKey}; use crate::public_key::SaplingFullViewingKey; +use wagyu_model::no_std::io::{self, Read, Write}; +use wagyu_model::no_std::vec; use wagyu_model::ChildIndex; use aes::Aes256; use blake2b_simd::{Hash as Blake2bHash, Params as Blake2bParams}; use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt}; +use core::marker::PhantomData; use fpe::ff1::{BinaryNumeralString, FF1}; -use std::io::{self, Read, Write}; -use std::marker::PhantomData; pub const ZIP32_SAPLING_MASTER_PERSONALIZATION: &'static [u8; 16] = b"ZcashIP32Sapling"; pub const ZIP32_SAPLING_FVFP_PERSONALIZATION: &'static [u8; 16] = b"ZcashSaplingFVFP"; @@ -274,7 +275,7 @@ impl ExtendedSpendingKey { } } -impl std::cmp::PartialEq for ExtendedSpendingKey { +impl core::cmp::PartialEq for ExtendedSpendingKey { fn eq(&self, rhs: &ExtendedSpendingKey) -> bool { self.depth == rhs.depth && self.parent_fvk_tag == rhs.parent_fvk_tag @@ -287,8 +288,8 @@ impl std::cmp::PartialEq for ExtendedSpendingKey { } } -impl std::fmt::Debug for ExtendedSpendingKey { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { +impl core::fmt::Debug for ExtendedSpendingKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { write!( f, "ExtendedSpendingKey(d = {}, tag_p = {:?}, i = {:?})", @@ -397,7 +398,7 @@ impl ExtendedFullViewingKey { } } -impl std::cmp::PartialEq for ExtendedFullViewingKey { +impl core::cmp::PartialEq for ExtendedFullViewingKey { fn eq(&self, rhs: &Self) -> bool { self.depth == rhs.depth && self.parent_fvk_tag == rhs.parent_fvk_tag @@ -410,8 +411,8 @@ impl std::cmp::PartialEq for ExtendedFullViewingKey { } } -impl std::fmt::Debug for ExtendedFullViewingKey { - fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { +impl core::fmt::Debug for ExtendedFullViewingKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { write!( f, "ExtendedFullViewingKey(d = {}, tag_p = {:?}, i = {:?})", diff --git a/zcash/src/network/mainnet.rs b/zcash/src/network/mainnet.rs index 0b8ffd74..02381e73 100644 --- a/zcash/src/network/mainnet.rs +++ b/zcash/src/network/mainnet.rs @@ -1,9 +1,10 @@ use super::*; use crate::format::ZcashFormat; +use wagyu_model::no_std::vec; use wagyu_model::{AddressError, ChildIndex, Network, NetworkError, PrivateKeyError}; +use core::{fmt, str::FromStr}; use serde::Serialize; -use std::{fmt, str::FromStr}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Mainnet; diff --git a/zcash/src/network/mod.rs b/zcash/src/network/mod.rs index 628696ba..9c200570 100644 --- a/zcash/src/network/mod.rs +++ b/zcash/src/network/mod.rs @@ -1,4 +1,5 @@ use crate::format::ZcashFormat; +use wagyu_model::no_std::{String, Vec}; use wagyu_model::{AddressError, ChildIndex, Network, NetworkError, PrivateKeyError}; pub mod mainnet; diff --git a/zcash/src/network/testnet.rs b/zcash/src/network/testnet.rs index 898362e1..ee89e82d 100644 --- a/zcash/src/network/testnet.rs +++ b/zcash/src/network/testnet.rs @@ -1,9 +1,10 @@ use super::*; use crate::format::ZcashFormat; +use wagyu_model::no_std::vec; use wagyu_model::{AddressError, ChildIndex, Network, NetworkError, PrivateKeyError}; +use core::{fmt, str::FromStr}; use serde::Serialize; -use std::{fmt, str::FromStr}; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)] pub struct Testnet; diff --git a/zcash/src/private_key.rs b/zcash/src/private_key.rs index fd8c5978..7c423099 100644 --- a/zcash/src/private_key.rs +++ b/zcash/src/private_key.rs @@ -9,19 +9,23 @@ use crate::librustzcash::sapling_crypto::{ use crate::librustzcash::zip32::prf_expand; use crate::network::ZcashNetwork; use crate::public_key::ZcashPublicKey; +use wagyu_model::no_std::{ + io::{self, Read, Write}, + vec, String, ToString, Vec, +}; use wagyu_model::{crypto::checksum, Address, AddressError, PrivateKey, PrivateKeyError, PublicKey}; use base58::{FromBase58, ToBase58}; use bech32::{Bech32, FromBase32, ToBase32}; -use rand::Rng; -use secp256k1; -use std::{ +use core::{ cmp::{Eq, PartialEq}, fmt::{self, Debug, Display}, - io::{self, Read, Write}, marker::PhantomData, str::FromStr, }; +use failure::AsFail; +use rand::Rng; +use secp256k1; #[derive(Debug, Clone, PartialEq, Eq)] pub struct P2PKHSpendingKey { @@ -150,12 +154,12 @@ impl SaplingSpendingKey { let mut ask_repr = <::Fs as PrimeField>::Repr::default(); ask_repr.read_le(&mut reader)?; let ask = ::Fs::from_repr(ask_repr) - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e.as_fail().to_string()))?; let mut nsk_repr = <::Fs as PrimeField>::Repr::default(); nsk_repr.read_le(&mut reader)?; let nsk = ::Fs::from_repr(nsk_repr) - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e.as_fail().to_string()))?; let mut ovk = [0; 32]; reader.read_exact(&mut ovk)?; diff --git a/zcash/src/public_key.rs b/zcash/src/public_key.rs index b02f6139..23f2e78e 100644 --- a/zcash/src/public_key.rs +++ b/zcash/src/public_key.rs @@ -8,19 +8,22 @@ use crate::librustzcash::sapling_crypto::{ use crate::librustzcash::JUBJUB; use crate::network::ZcashNetwork; use crate::private_key::{SaplingOutgoingViewingKey, SaplingSpendingKey, ZcashPrivateKey}; +use wagyu_model::no_std::{ + io::{self, Read, Write}, + ToString, Vec, +}; use wagyu_model::{crypto::checksum, Address, AddressError, PublicKey, PublicKeyError}; use base58::{FromBase58, ToBase58}; use bech32::{Bech32, FromBase32, ToBase32}; -use crypto::sha2::sha256_digest_block; -use secp256k1; -use std::{ +use core::{ cmp::{Eq, PartialEq}, fmt::{self, Display}, - io::{self, Read, Write}, marker::PhantomData, str::FromStr, }; +use crypto::sha2::sha256_digest_block; +use secp256k1; static H256: [u32; 8] = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, @@ -207,9 +210,7 @@ impl PublicKey for ZcashPublicKey { match private_key { // Transparent Public Key ZcashPrivateKey::::P2PKH(spending_key) => ZcashPublicKey::::P2PKH(P2PKHViewingKey { - public_key: secp256k1::PublicKey::from_secret_key( - &spending_key.secret_key, - ), + public_key: secp256k1::PublicKey::from_secret_key(&spending_key.secret_key), compressed: spending_key.compressed, }), // Transparent Multisignature diff --git a/zcash/src/transaction.rs b/zcash/src/transaction.rs index 5dac3e62..0d41cf12 100644 --- a/zcash/src/transaction.rs +++ b/zcash/src/transaction.rs @@ -6,16 +6,21 @@ use crate::librustzcash::zip32::prf_expand; use crate::network::ZcashNetwork; use crate::private_key::{SaplingOutgoingViewingKey, ZcashPrivateKey}; use crate::public_key::ZcashPublicKey; +use wagyu_model::no_std::{ + format, + io::{self, BufReader, Read}, + vec, String, ToString, Vec, +}; use wagyu_model::{ExtendedPrivateKey, PrivateKey, Transaction, TransactionError, TransactionId}; use base58::FromBase58; use blake2b_simd::{Hash, Params, State}; +use core::{fmt, str::FromStr}; use rand::{rngs::StdRng, Rng}; use rand_core::SeedableRng; use secp256k1; use serde::Serialize; use sha2::{Digest, Sha256}; -use std::{fmt, io::{self, BufReader, Read}, str::FromStr}; // librustzcash crates use bellman::groth16::{prepare_verifying_key, Parameters, PreparedVerifyingKey, Proof}; @@ -137,24 +142,21 @@ pub fn load_sapling_parameters() -> ( let (spend, output) = wagyu_zcash_parameters::load_sapling_parameters(); let mut spend_fs = HashReader::new(BufReader::with_capacity(1024 * 1024, &spend[..])); - let mut output_fs = - HashReader::new(BufReader::with_capacity(1024 * 1024, &output[..])); + let mut output_fs = HashReader::new(BufReader::with_capacity(1024 * 1024, &output[..])); // Deserialize params - let spend_params = Parameters::::read(&mut spend_fs, false) - .expect("couldn't deserialize Sapling spend parameters file"); - let output_params = Parameters::::read(&mut output_fs, false) - .expect("couldn't deserialize Sapling spend parameters file"); + let spend_params = + Parameters::::read(&mut spend_fs, false).expect("couldn't deserialize Sapling spend parameters file"); + let output_params = + Parameters::::read(&mut output_fs, false).expect("couldn't deserialize Sapling spend parameters file"); // There is extra stuff (the transcript) at the end of the parameter file which is // used to verify the parameter validity, but we're not interested in that. We do // want to read it, though, so that the BLAKE2b computed afterward is consistent // with `b2sum` on the files. let mut sink = io::sink(); - io::copy(&mut spend_fs, &mut sink) - .expect("couldn't finish reading Sapling spend parameter file"); - io::copy(&mut output_fs, &mut sink) - .expect("couldn't finish reading Sapling output parameter file"); + io::copy(&mut spend_fs, &mut sink).expect("couldn't finish reading Sapling spend parameter file"); + io::copy(&mut output_fs, &mut sink).expect("couldn't finish reading Sapling output parameter file"); if spend_fs.into_hash() != "8270785a1a0d0bc77196f000ee6d221c9c9894f55307bd9357c3f0105d31ca63991ab91324160d8f53e2bbd3c2633a6eb8bdf5205d822e7f3f73edac51b2b70c" { panic!("Sapling spend parameter is not correct. please file a Github issue."); @@ -1251,7 +1253,7 @@ impl Transaction for ZcashTransaction { &p2pkh_spending_key.to_secp256k1_secret_key(), ); signature.serialize_der().as_ref().to_vec() - }, + } _ => unimplemented!(), }; signature.push((input.sighash_code as u32).to_le_bytes()[0]); @@ -1261,10 +1263,7 @@ impl Transaction for ZcashTransaction { let public_viewing_key = match private_key.to_public_key() { ZcashPublicKey::::P2PKH(p2pkh_view_key) => match p2pkh_view_key.is_compressed() { true => p2pkh_view_key.to_secp256k1_public_key().serialize_compressed().to_vec(), - false => p2pkh_view_key - .to_secp256k1_public_key() - .serialize() - .to_vec(), + false => p2pkh_view_key.to_secp256k1_public_key().serialize().to_vec(), }, _ => unimplemented!(), }; @@ -1593,7 +1592,7 @@ mod tests { use crate::{Mainnet, Testnet}; use bellman::groth16::PreparedVerifyingKey; - use zcash_primitives::merkle_tree::{CommitmentTree, MerklePath, IncrementalWitness}; + use zcash_primitives::merkle_tree::{CommitmentTree, IncrementalWitness, MerklePath}; #[derive(Clone)] pub struct TransactionData<'a> { @@ -2777,7 +2776,6 @@ mod tests { fn test_real_sapling_spend_transactions() { test_sapling_transactions::(REAL_TESTNET_SAPLING_SPEND_TRANSACTIONS.to_vec()); } - } mod test_real_testnet_sapling_output_transactions {