diff --git a/.github/workflows/build-release-ios.yml b/.github/workflows/build-release-ios.yml index 4793c399..bce63acd 100644 --- a/.github/workflows/build-release-ios.yml +++ b/.github/workflows/build-release-ios.yml @@ -14,7 +14,7 @@ jobs: build: name: Build iOS Release if: github.event.review.state == 'approved' - runs-on: macos-12 + runs-on: macos-14 steps: - name: Get the latest commit SHA id: sha diff --git a/Cargo.lock b/Cargo.lock index 5575fb73..7b9dc7f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,7 +130,7 @@ checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -172,12 +172,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.1" @@ -222,6 +216,7 @@ dependencies = [ "bech32 0.9.1", "bitcoin_hashes", "secp256k1", + "serde", ] [[package]] @@ -229,6 +224,9 @@ name = "bitcoin_hashes" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +dependencies = [ + "serde", +] [[package]] name = "bitflags" @@ -241,6 +239,9 @@ name = "bitflags" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -273,17 +274,6 @@ dependencies = [ "cty", ] -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "constant_time_eq 0.1.5", -] - [[package]] name = "blake2b_simd" version = "1.0.1" @@ -367,25 +357,11 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "bls-signatures" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b44c36726a8b4cae930903a96f3193b496664ed7c28f74f1c1b3feae0e212c3" -dependencies = [ - "blst", - "blstrs", - "fff", - "groupy", - "rand_core 0.5.1", - "thiserror", -] - [[package]] name = "blst" -version = "0.3.3" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7cb1b48c09ac759808ad27811ca44e27c037d309f837651fc80506bc19819f" +checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" dependencies = [ "cc", "glob", @@ -393,18 +369,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "blstrs" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecf78c2e543a5fd41b41499fc242d603862b436dc2c167658e7f4870523781ac" -dependencies = [ - "blst", - "fff", - "groupy", - "rand_core 0.5.1", -] - [[package]] name = "bs58" version = "0.2.5" @@ -484,6 +448,15 @@ dependencies = [ "cipher", ] +[[package]] +name = "cbor4ii" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544cf8c89359205f4f990d0e6f3828db42df85b5dac95d09157a250eb0749c4" +dependencies = [ + "serde", +] + [[package]] name = "cc" version = "1.0.83" @@ -513,13 +486,28 @@ dependencies = [ [[package]] name = "cid" -version = "0.6.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff0e3bc0b6446b3f9663c1a6aba6ef06c5aeaa1bc92bd18077be337198ab9768" +checksum = "fd94671561e36e4e7de75f753f577edafb0e7c05d6e4547229fdf7938fbcd2c3" dependencies = [ - "multibase 0.8.0", - "multihash 0.13.2", - "unsigned-varint 0.5.1", + "core2", + "multibase", + "multihash 0.18.1", + "serde", + "serde_bytes", + "unsigned-varint 0.7.2", +] + +[[package]] +name = "cid" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3147d8272e8fa0ccd29ce51194dd98f79ddfb8191ba9e3409884e751798acf3a" +dependencies = [ + "core2", + "multibase", + "multihash 0.19.1", + "unsigned-varint 0.8.0", ] [[package]] @@ -546,7 +534,7 @@ dependencies = [ "ikc-common", "ikc-device", "ikc-transport", - "num-bigint 0.4.3", + "num-bigint", "prost", "prost-types", "secp256k1", @@ -567,7 +555,7 @@ dependencies = [ "ikc-common", "ikc-device", "ikc-transport", - "num-bigint 0.4.3", + "num-bigint", "prost", "prost-types", "secp256k1", @@ -578,7 +566,7 @@ name = "coin-btc-fork" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bech32 0.9.1", "bitcoin", "bitcoin_hashes", @@ -588,7 +576,7 @@ dependencies = [ "ikc-device", "ikc-transport", "lazy_static", - "num-bigint 0.4.3", + "num-bigint", "parking_lot", "prost", "prost-types", @@ -603,7 +591,7 @@ name = "coin-ckb" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bech32 0.9.1", "bitcoin", "blake2b-rs", @@ -623,7 +611,7 @@ name = "coin-cosmos" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bech32 0.9.1", "bitcoin", "bitcoin_hashes", @@ -633,7 +621,7 @@ dependencies = [ "ikc-device", "ikc-transport", "linked-hash-map", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "prost", @@ -665,7 +653,7 @@ name = "coin-ethereum" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bitcoin", "bitcoin_hashes", "bytes", @@ -677,7 +665,7 @@ dependencies = [ "jsonrpc-core", "keccak-hash", "lazy_static", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "prost", @@ -698,25 +686,24 @@ version = "0.1.0" dependencies = [ "anyhow", "base32", - "base64 0.13.1", + "base64", "bech32 0.9.1", "bitcoin", "bitcoin_hashes", "blake2b-rs", "bytes", - "forest_address", - "forest_bigint", - "forest_cid", - "forest_crypto", - "forest_encoding", - "forest_message", - "forest_vm", + "cid 0.11.1", + "fvm_ipld_encoding", + "fvm_shared", "hex", "ikc-common", "ikc-device", "ikc-transport", "linked-hash-map", - "num-bigint 0.4.3", + "multihash-codetable", + "num", + "num-bigint", + "num-derive", "num-integer", "num-traits", "prost", @@ -724,6 +711,9 @@ dependencies = [ "secp256k1", "serde", "serde_json", + "serde_tuple", + "strum 0.26.3", + "strum_macros 0.26.4", ] [[package]] @@ -748,7 +738,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bitcoin", - "blake2b_simd 1.0.1", + "blake2b_simd", "hex", "ikc-common", "ikc-device", @@ -780,12 +770,6 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "constant_time_eq" version = "0.2.6" @@ -875,25 +859,6 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42014d4c82e74bc17aaccc4bd75d3615d2b8236198de81c51bed5ddefaae6435" -[[package]] -name = "cs_serde_bytes" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc673ddabf48214550526b068dc28065a75f05e21e452880095247c635b1d91" -dependencies = [ - "serde", -] - -[[package]] -name = "cs_serde_cbor" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7b77425566bdb3932243a292a4b072e1e34fb93aba95926f8d4a3b6ce542c5" -dependencies = [ - "half", - "serde", -] - [[package]] name = "ctr" version = "0.9.2" @@ -960,42 +925,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", -] - -[[package]] -name = "darling" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", + "syn 2.0.69", ] [[package]] @@ -1064,31 +994,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" -[[package]] -name = "derive_builder" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2658621297f2cf68762a6f7dc0bb7e1ff2cfd6583daef8ee0fed6f7ec468ec0" -dependencies = [ - "darling", - "derive_builder_core", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_core" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2791ea3e372c8495c0bc2033991d76b512cd799d07491fbd6890124db9458bef" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -1308,7 +1213,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -1326,18 +1231,6 @@ dependencies = [ "instant", ] -[[package]] -name = "fff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2544d325b4870bd803d371a7df3c6845e84dcfcb6ebe7ffcae0eac6d5d676133" -dependencies = [ - "byteorder 1.4.3", - "cc", - "lazy_static", - "rand_core 0.5.1", -] - [[package]] name = "fiat-crypto" version = "0.2.5" @@ -1392,128 +1285,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "forest_address" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b7dbc8805f7d93e4a3c63a5be26dd521d3a62b20cc9453eaf722022d7f8ee" -dependencies = [ - "data-encoding", - "data-encoding-macro", - "forest_encoding", - "leb128", - "log", - "num-derive", - "num-traits", - "once_cell", - "serde", - "thiserror", -] - -[[package]] -name = "forest_bigint" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559d63f33ef82723a75b2b25703b31c50a55d2950ead45e239e49b19aeefd1e7" -dependencies = [ - "cs_serde_bytes", - "num-bigint 0.3.3", - "num-integer", - "serde", -] - -[[package]] -name = "forest_cid" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1a935d7f977a7debbc507de2ab7990b834d85e94c819e5268b1adaefd7d434" -dependencies = [ - "cid", - "cs_serde_bytes", - "cs_serde_cbor", - "forest_json_utils", - "generic-array 0.14.7", - "integer-encoding", - "multibase 0.9.1", - "multihash 0.13.2", - "serde", -] - -[[package]] -name = "forest_crypto" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecfe12e10b7f6aa5643dcde74533d8192720ab7366ce473ff4043c71b5132c27" -dependencies = [ - "bls-signatures", - "forest_address", - "forest_encoding", - "libsecp256k1 0.6.0", - "num-derive", - "num-traits", - "serde", - "thiserror", -] - -[[package]] -name = "forest_encoding" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c8339c6dc1741c3144ba06cfb0512a2e858bd603be97bff24bf630d91cce7d" -dependencies = [ - "blake2b_simd 0.5.11", - "cs_serde_bytes", - "cs_serde_cbor", - "forest_cid", - "serde", - "serde_repr", - "serde_tuple", - "thiserror", -] - -[[package]] -name = "forest_json_utils" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da39ba6848c04b22e70520a1339f04f304502a0ebfd4526ea8a566452ea62a8" -dependencies = [ - "serde", -] - -[[package]] -name = "forest_message" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c512b9fbaea31e6bbc98c10ae32568a87b7d99b8c1f63d334ec91c482b35d30" -dependencies = [ - "derive_builder", - "forest_address", - "forest_bigint", - "forest_cid", - "forest_crypto", - "forest_encoding", - "forest_vm", - "num-traits", - "serde", -] - -[[package]] -name = "forest_vm" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cba5f1b93b15568dc4d96b333c73a1949bfba11ce539a6b5495c02e9a9d9190a" -dependencies = [ - "forest_address", - "forest_bigint", - "forest_cid", - "forest_encoding", - "lazy_static", - "num-derive", - "num-traits", - "serde", - "thiserror", -] - [[package]] name = "fragile" version = "2.0.0" @@ -1583,7 +1354,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -1616,6 +1387,59 @@ dependencies = [ "slab", ] +[[package]] +name = "fvm_ipld_blockstore" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d064b957420f5ecc137a153baaa6c32e2eb19b674135317200b6f2537eabdbfd" +dependencies = [ + "anyhow", + "cid 0.10.1", + "multihash 0.18.1", +] + +[[package]] +name = "fvm_ipld_encoding" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90608092e31d9a06236268c58f7c36668ab4b2a48afafe3a97e08f094ad7ae50" +dependencies = [ + "anyhow", + "cid 0.10.1", + "fvm_ipld_blockstore", + "multihash 0.18.1", + "serde", + "serde_ipld_dagcbor", + "serde_repr", + "serde_tuple", + "thiserror", +] + +[[package]] +name = "fvm_shared" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a907c935312f9a47a64fbe1d45f2cb7b2b0a5fbb989a90ecac395b40466069d" +dependencies = [ + "anyhow", + "bitflags 2.4.1", + "blake2b_simd", + "cid 0.10.1", + "data-encoding", + "data-encoding-macro", + "fvm_ipld_encoding", + "lazy_static", + "multihash 0.18.1", + "num-bigint", + "num-derive", + "num-integer", + "num-traits", + "serde", + "serde_tuple", + "thiserror", + "unsigned-varint 0.7.2", +] + [[package]] name = "generic-array" version = "0.12.4" @@ -1671,18 +1495,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" -[[package]] -name = "groupy" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d38f1bec17d75a7c30b754cd74db6e7cb5927529021ced14fbd622411c04d8b" -dependencies = [ - "fff", - "rand 0.7.3", - "rand_xorshift", - "thiserror", -] - [[package]] name = "h2" version = "0.3.26" @@ -1702,12 +1514,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "hash-db" version = "0.15.2" @@ -1744,6 +1550,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.3" @@ -1831,9 +1643,9 @@ checksum = "fc736091aacb31ddaa4cd5f6988b3c21e99913ac846b41f32538c5fae5d71bfe" [[package]] name = "http" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ "bytes", "fnv", @@ -1853,9 +1665,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -1935,18 +1747,12 @@ dependencies = [ "cc", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "ikc" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bitcoin", "bytes", "coin-bch", @@ -1980,7 +1786,7 @@ version = "0.1.0" dependencies = [ "aes", "anyhow", - "base64 0.13.1", + "base64", "bitcoin", "byteorder 1.4.3", "bytes", @@ -1990,7 +1796,7 @@ dependencies = [ "hyper-timeout", "hyper-tls", "lazy_static", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "parking_lot", @@ -2011,7 +1817,7 @@ name = "ikc-device" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bytes", "hex", "ikc-common", @@ -2028,7 +1834,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "sha1", + "sha1 0.6.1", "thiserror", ] @@ -2122,12 +1928,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "integer-encoding" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27df786dcc3a75ccd134f83ece166af0a1e5785d52b12b7375d0d063e1d5c47" - [[package]] name = "integer-sqrt" version = "0.1.5" @@ -2215,12 +2015,6 @@ dependencies = [ "spin", ] -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - [[package]] name = "libc" version = "0.2.140" @@ -2233,25 +2027,6 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "libsecp256k1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" -dependencies = [ - "arrayref", - "base64 0.12.3", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core 0.2.2", - "libsecp256k1-gen-ecmult 0.2.1", - "libsecp256k1-gen-genmult 0.2.1", - "rand 0.7.3", - "serde", - "sha2 0.9.9", - "typenum", -] - [[package]] name = "libsecp256k1" version = "0.7.1" @@ -2259,29 +2034,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" dependencies = [ "arrayref", - "base64 0.13.1", + "base64", "digest 0.9.0", "hmac-drbg", - "libsecp256k1-core 0.3.0", - "libsecp256k1-gen-ecmult 0.3.0", - "libsecp256k1-gen-genmult 0.3.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", "rand 0.8.5", "serde", "sha2 0.9.9", "typenum", ] -[[package]] -name = "libsecp256k1-core" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle", -] - [[package]] name = "libsecp256k1-core" version = "0.3.0" @@ -2293,31 +2057,13 @@ dependencies = [ "subtle", ] -[[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" -dependencies = [ - "libsecp256k1-core 0.2.2", -] - [[package]] name = "libsecp256k1-gen-ecmult" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" dependencies = [ - "libsecp256k1-core 0.3.0", -] - -[[package]] -name = "libsecp256k1-gen-genmult" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" -dependencies = [ - "libsecp256k1-core 0.2.2", + "libsecp256k1-core", ] [[package]] @@ -2326,7 +2072,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" dependencies = [ - "libsecp256k1-core 0.3.0", + "libsecp256k1-core", ] [[package]] @@ -2465,9 +2211,9 @@ dependencies = [ [[package]] name = "multibase" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b78c60039650ff12e140ae867ef5299a58e19dded4d334c849dc7177083667e2" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" dependencies = [ "base-x", "data-encoding", @@ -2475,71 +2221,90 @@ dependencies = [ ] [[package]] -name = "multibase" -version = "0.9.1" +name = "multihash" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +checksum = "cfd8a792c1694c6da4f68db0a9d707c72bd260994da179e6030a5dcee00bb815" dependencies = [ - "base-x", - "data-encoding", - "data-encoding-macro", + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest 0.10.6", + "multihash-derive 0.8.1", + "serde", + "serde-big-array", + "sha2 0.10.6", + "sha3", + "unsigned-varint 0.7.2", ] [[package]] name = "multihash" -version = "0.13.2" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab" +checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" dependencies = [ - "blake2b_simd 0.5.11", - "generic-array 0.14.7", - "multihash-derive 0.7.2", - "unsigned-varint 0.5.1", + "core2", + "unsigned-varint 0.7.2", ] [[package]] -name = "multihash" -version = "0.18.1" +name = "multihash-codetable" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfd8a792c1694c6da4f68db0a9d707c72bd260994da179e6030a5dcee00bb815" +checksum = "c35f0fb09f635b18e95053fc2a9a4843272d3acf898792a14471dcf6f83df0cc" dependencies = [ - "blake2b_simd 1.0.1", + "blake2b_simd", "blake2s_simd", "blake3", "core2", "digest 0.10.6", - "multihash-derive 0.8.1", + "multihash-derive 0.9.0", + "ripemd", + "sha1 0.10.5", "sha2 0.10.6", "sha3", - "unsigned-varint 0.7.2", + "strobe-rs", ] [[package]] name = "multihash-derive" -version = "0.7.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "424f6e86263cd5294cbd7f1e95746b95aca0e0d66bff31e5a40d6baa87b4aa99" +checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro-error", "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] name = "multihash-derive" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" dependencies = [ - "proc-macro-crate 1.1.3", + "core2", + "multihash 0.19.1", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3958713ce794e12f7c6326fac9aa274c68d74c4881dd37b3e2662b8a2046bb19" +dependencies = [ + "proc-macro-crate 2.0.0", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.69", + "synstructure 0.13.1", ] [[package]] @@ -2550,11 +2315,10 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "native-tls" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466" dependencies = [ - "lazy_static", "libc", "log", "openssl", @@ -2579,23 +2343,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] -name = "num-bigint" -version = "0.3.3" +name = "num" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ - "autocfg", + "num-bigint", + "num-complex", "num-integer", + "num-iter", + "num-rational", "num-traits", ] [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] @@ -2617,15 +2383,24 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-derive" -version = "0.3.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.69", ] [[package]] @@ -2640,19 +2415,18 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -2661,21 +2435,20 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", ] [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -2720,9 +2493,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.62" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -2741,7 +2514,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -2752,9 +2525,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.98" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -2812,7 +2585,7 @@ checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -2956,9 +2729,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.28" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "platforms" @@ -3082,9 +2855,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -3106,7 +2879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276470f7f281b0ed53d2ae42dd52b4a8d08853a3c70e7fe95882acbb98a6ae94" dependencies = [ "bytes", - "heck", + "heck 0.4.1", "itertools", "lazy_static", "log", @@ -3240,15 +3013,6 @@ 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 = "redox_syscall" version = "0.3.5" @@ -3284,7 +3048,7 @@ checksum = "2566c4bf6845f2c2e83b27043c3f5dfcd5ba8f2937d6c00dc009bfb51a079dc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3331,6 +3095,15 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.6", +] + [[package]] name = "rlp" version = "0.5.2" @@ -3509,6 +3282,7 @@ dependencies = [ "bitcoin_hashes", "rand 0.8.5", "secp256k1-sys", + "serde", ] [[package]] @@ -3531,9 +3305,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -3544,9 +3318,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -3560,33 +3334,52 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "c939f902bb7d0ccc5bce4f03297e161543c2dcb30914faf032c2bd0b7a0d48fc" dependencies = [ "serde_derive", ] [[package]] -name = "serde-aux" -version = "4.5.0" +name = "serde-big-array" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d2e8bfba469d06512e11e3311d4d051a4a387a5b42d010404fecf3200321c95" +checksum = "cd31f59f6fe2b0c055371bb2f16d7f0aa7d8881676c04a55b1596d1a17cd10a4" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_bytes" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c5113243e4a3a1c96587342d067f3e6b0f50790b6cf40d2868eb647a3eef0e" dependencies = [ - "chrono", "serde", - "serde_json", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.165" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "6eaae920e25fffe4019b75ff65e7660e72091e59dd204cb5849bbd6a3fd343d7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.69", +] + +[[package]] +name = "serde_ipld_dagcbor" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e880e0b1f9c7a8db874642c1217f7e19b29e325f24ab9f0fcb11818adec7f01" +dependencies = [ + "cbor4ii", + "cid 0.10.1", + "scopeguard", + "serde", ] [[package]] @@ -3608,7 +3401,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3654,7 +3447,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -3666,6 +3459,17 @@ dependencies = [ "sha1_smol", ] +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.6", +] + [[package]] name = "sha1_smol" version = "1.0.0" @@ -3729,9 +3533,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -3825,7 +3629,7 @@ dependencies = [ "hash256-std-hasher", "impl-serde", "lazy_static", - "libsecp256k1 0.7.1", + "libsecp256k1", "log", "merlin", "num-traits", @@ -3900,7 +3704,7 @@ dependencies = [ "bytes", "futures", "hash-db", - "libsecp256k1 0.7.1", + "libsecp256k1", "log", "parity-scale-codec", "parking_lot", @@ -4173,7 +3977,7 @@ checksum = "f923762d556417668b192ac2fdc9827ea21e6df011d8a0a7e68f3d5da095a675" dependencies = [ "bitvec", "hex", - "num-bigint 0.4.3", + "num-bigint", "serde", "sha2 0.9.9", "ssz_rs_derive", @@ -4198,10 +4002,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "strsim" -version = "0.9.3" +name = "strobe-rs" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" +checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +dependencies = [ + "bitflags 1.3.2", + "byteorder 1.4.3", + "keccak", + "subtle", + "zeroize", +] [[package]] name = "strum" @@ -4221,13 +4032,22 @@ dependencies = [ "strum_macros 0.25.3", ] +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros 0.26.4", +] + [[package]] name = "strum_macros" version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", @@ -4240,11 +4060,24 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.69", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.69", ] [[package]] @@ -4279,9 +4112,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -4300,6 +4133,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.69", +] + [[package]] name = "tap" version = "1.0.1" @@ -4312,7 +4156,7 @@ version = "0.1.0" dependencies = [ "anyhow", "base58", - "base64 0.13.1", + "base64", "bytes", "ethereum-types", "hex", @@ -4353,7 +4197,7 @@ name = "tcx-atom" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bech32 0.9.1", "bytes", "prost", @@ -4369,7 +4213,7 @@ name = "tcx-btc-kin" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bch_addr", "bech32 0.9.1", "bitcoin", @@ -4378,7 +4222,7 @@ dependencies = [ "bytes", "hex", "mockall", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "prost", @@ -4480,7 +4324,7 @@ name = "tcx-eos" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64", "bitcoin", "bytes", "prost", @@ -4538,20 +4382,24 @@ version = "0.1.0" dependencies = [ "anyhow", "base32", - "base64 0.13.1", + "base64", "blake2b-rs", "byteorder 1.4.3", "bytes", - "forest_address", - "forest_cid", - "forest_crypto", - "forest_encoding", - "forest_message", - "forest_vm", + "cid 0.11.1", + "fvm_ipld_encoding", + "fvm_shared", "lazy_static", + "multihash-codetable", + "num", + "num-derive", + "num-traits", "prost", "serde", "serde_json", + "serde_tuple", + "strum 0.26.3", + "strum_macros 0.26.4", "tcx-common", "tcx-constants", "tcx-crypto", @@ -4596,7 +4444,7 @@ version = "0.1.0" dependencies = [ "anyhow", "base58", - "base64 0.13.1", + "base64", "bytes", "hex", "lazy_static", @@ -4606,7 +4454,6 @@ dependencies = [ "prost", "prost-types", "serde", - "serde-aux", "serde_json", "tcx-atom", "tcx-btc-kin", @@ -4632,7 +4479,7 @@ dependencies = [ "anyhow", "bitcoin", "bitcoin_hashes", - "blake2b_simd 1.0.1", + "blake2b_simd", "blst", "byteorder 1.4.3", "digest 0.10.6", @@ -4643,7 +4490,7 @@ dependencies = [ "hex-literal", "hkdf", "lazy_static", - "num-bigint 0.4.3", + "num-bigint", "num-traits", "regex", "schnorrkel", @@ -4674,7 +4521,7 @@ version = "0.1.0" dependencies = [ "anyhow", "base58", - "base64 0.13.1", + "base64", "byteorder 1.4.3", "bytes", "parity-scale-codec", @@ -4714,7 +4561,7 @@ version = "0.1.0" dependencies = [ "anyhow", "bitcoin", - "blake2b_simd 1.0.1", + "blake2b_simd", "bytes", "hex", "prost", @@ -4739,7 +4586,7 @@ dependencies = [ "digest 0.10.6", "hex", "hex-literal", - "num-bigint 0.4.3", + "num-bigint", "num-integer", "num-traits", "prost", @@ -4791,7 +4638,7 @@ checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -4912,7 +4759,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -4927,16 +4774,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -4990,7 +4836,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] [[package]] @@ -5137,15 +4983,15 @@ dependencies = [ [[package]] name = "unsigned-varint" -version = "0.5.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" [[package]] name = "unsigned-varint" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" +checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" [[package]] name = "uuid" @@ -5217,7 +5063,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "wasm-bindgen-shared", ] @@ -5239,7 +5085,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5571,5 +5417,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.69", ] diff --git a/VERSION b/VERSION index 2c9b4ef4..a603bb50 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.7.3 +2.7.5 diff --git a/imkey-core/ikc-common/Cargo.toml b/imkey-core/ikc-common/Cargo.toml index a3dc774a..2d984820 100644 --- a/imkey-core/ikc-common/Cargo.toml +++ b/imkey-core/ikc-common/Cargo.toml @@ -11,15 +11,15 @@ hyper = { version = "=0.14.23", features = ["full"] } hyper-tls = "=0.5.0" hyper-timeout = "=0.4.1" rustc-serialize = "=0.3.24" -serde = { version = "=1.0.147", features = ["derive"] } -serde_derive = "=1.0.147" +serde = { version = "=1.0.165", features = ["derive"] } +serde_derive = "=1.0.165" serde_json = "=1.0.89" hex = "=0.4.3" tokio = { version = "=1.28.2", features = ["full"] } regex = "=1.9.3" -num-bigint = "=0.4.3" -num-traits = "=0.2.15" -num-integer = "=0.1.45" +num-bigint = "=0.4.6" +num-traits = "=0.2.19" +num-integer = "=0.1.46" prost = "=0.11.2" bytes = "=1.4.0" prost-types = "=0.11.2" diff --git a/imkey-core/ikc-common/src/apdu.rs b/imkey-core/ikc-common/src/apdu.rs index 2fb5aeab..a2b01cd2 100644 --- a/imkey-core/ikc-common/src/apdu.rs +++ b/imkey-core/ikc-common/src/apdu.rs @@ -93,6 +93,21 @@ impl BtcApdu { apdu.to_hex().to_uppercase() } + pub fn btc_taproot_sign(last_one: bool, data: Vec) -> String { + if data.len() as u32 > LC_MAX { + panic!("data to long"); + } + + let mut apdu = match last_one { + true => ApduHeader::new(0x80, 0x40, 0x80, 0x00, data.len() as u8).to_array(), + _ => ApduHeader::new(0x80, 0x40, 0x00, 0x00, data.len() as u8).to_array(), + }; + + apdu.extend(data.iter()); + apdu.push(0x00); + apdu.to_hex().to_uppercase() + } + pub fn omni_prepare_data(p1: u8, data: Vec) -> String { if data.len() as u32 > LC_MAX { panic!("data to long"); @@ -111,6 +126,58 @@ impl BtcApdu { data.extend(name); Apdu::register_address(0x37, &data) } + + pub fn btc_single_utxo_sign_prepare(ins: u8, data: &Vec) -> Vec { + let mut apdu_vec = Vec::new(); + let apdu_number = (data.len() - 1) / LC_MAX as usize + 1; + for index in 0..apdu_number { + if index == 0 && index == apdu_number - 1 { + let length = if data.len() % LC_MAX as usize == 0 { + LC_MAX + } else { + (data.len() % LC_MAX as usize) as u32 + }; + let mut temp_apdu_vec = + ApduHeader::new(0x80, ins, 0x00, 0x80, length as u8).to_array(); + temp_apdu_vec.extend_from_slice(&data[index * LC_MAX as usize..]); + apdu_vec.push(hex::encode_upper(temp_apdu_vec)); + } else if index == 0 && index != apdu_number - 1 { + let mut temp_apdu_vec = + ApduHeader::new(0x80, ins, 0x00, 0x00, LC_MAX as u8).to_array(); + temp_apdu_vec.extend_from_slice( + &data[index * LC_MAX as usize..((index + 1) * LC_MAX as usize) as usize], + ); + apdu_vec.push(hex::encode_upper(temp_apdu_vec)); + } else if index != 0 && index != apdu_number - 1 { + let mut temp_apdu_vec = + ApduHeader::new(0x80, ins, 0x80, 0x00, LC_MAX as u8).to_array(); + temp_apdu_vec.extend_from_slice( + &data[index * LC_MAX as usize..((index + 1) * LC_MAX as usize) as usize], + ); + apdu_vec.push(hex::encode_upper(temp_apdu_vec)); + } else if index != 0 && index == apdu_number - 1 { + let length = if data.len() % LC_MAX as usize == 0 { + LC_MAX + } else { + (data.len() % LC_MAX as usize) as u32 + }; + let mut temp_apdu_vec = + ApduHeader::new(0x80, ins, 0x80, 0x80, length as u8).to_array(); + temp_apdu_vec.extend_from_slice(&data[index * LC_MAX as usize..]); + apdu_vec.push(hex::encode_upper(temp_apdu_vec)); + } + } + return apdu_vec; + } + + pub fn btc_single_utxo_sign(index: u8, hash_type: u8, path: &str) -> String { + let path_bytes = path.as_bytes(); + let mut apdu = + ApduHeader::new(0x80, 0x45, index, hash_type, path_bytes.len() as u8).to_array(); + apdu.extend(path_bytes.iter()); + apdu.push(0x00); + apdu.to_hex().to_uppercase() + } } pub struct EthApdu(); diff --git a/imkey-core/ikc-common/src/constants.rs b/imkey-core/ikc-common/src/constants.rs index c3ec85c2..37046393 100644 --- a/imkey-core/ikc-common/src/constants.rs +++ b/imkey-core/ikc-common/src/constants.rs @@ -1,6 +1,6 @@ pub const VERSION: &str = "2.15.2"; -pub const URL: &str = "https://imkey.online:1000/imkey"; -// pub const URL: &str = "https://imkeyserver.com:10444/imkey"; +// pub const URL: &str = "https://imkey.online:1000/imkey"; +pub const URL: &str = "https://imkeyserver.com:10444/imkey"; pub const TSM_ACTION_SE_SECURE_CHECK: &str = "/seSecureCheck"; pub const TSM_ACTION_APP_DOWNLOAD: &str = "/appDownload"; @@ -44,11 +44,11 @@ pub const TRON_PATH: &str = "m/44'/195'/0'/0/0"; pub const MAX_UTXO_NUMBER: usize = 252; pub const EACH_ROUND_NUMBER: usize = 5; -pub const DUST_THRESHOLD: i64 = 2730; -pub const MIN_NONDUST_OUTPUT: i64 = 546; +pub const DUST_THRESHOLD: u64 = 2730; +pub const MIN_NONDUST_OUTPUT: u64 = 546; // max op return size pub const MAX_OPRETURN_SIZE: usize = 80; -pub const BTC_FORK_DUST: i64 = 546; +pub const BTC_FORK_DUST: u64 = 546; // imkey device status pub const IMKEY_DEV_STATUS_INACTIVATED: &str = "inactivated"; diff --git a/imkey-core/ikc-common/src/error.rs b/imkey-core/ikc-common/src/error.rs index d86f07ae..6f9611c8 100644 --- a/imkey-core/ikc-common/src/error.rs +++ b/imkey-core/ikc-common/src/error.rs @@ -88,4 +88,6 @@ pub enum CoinError { InvalidVersion, #[error("invalid addr length")] InvalidAddrLength, + #[error("invalid_utxo")] + InvalidUtxo, } diff --git a/imkey-core/ikc-common/src/utility.rs b/imkey-core/ikc-common/src/utility.rs index bf789174..af52b25f 100644 --- a/imkey-core/ikc-common/src/utility.rs +++ b/imkey-core/ikc-common/src/utility.rs @@ -65,7 +65,7 @@ pub fn secp256k1_sign_verify(public: &[u8], signed: &[u8], message: &[u8]) -> Re .is_ok()) } -pub fn bigint_to_byte_vec(val: i64) -> Vec { +pub fn bigint_to_byte_vec(val: u64) -> Vec { let mut return_data = BigInt::from(val).to_signed_bytes_be(); while return_data.len() < 8 { return_data.insert(0, 0x00); diff --git a/imkey-core/ikc-device/Cargo.toml b/imkey-core/ikc-device/Cargo.toml index 3739d47a..d538f3ee 100644 --- a/imkey-core/ikc-device/Cargo.toml +++ b/imkey-core/ikc-device/Cargo.toml @@ -9,8 +9,8 @@ edition = "2018" [dependencies] ikc-common = {path = "../ikc-common"} ikc-transport = {path = "../ikc-transport"} -serde = { version = "=1.0.147", features = ["derive"] } -serde_derive = "=1.0.147" +serde = { version = "=1.0.165", features = ["derive"] } +serde_derive = "=1.0.165" serde_json = "=1.0.89" base64 = "=0.13.1" hex = "=0.4.3" diff --git a/imkey-core/ikc-device/src/device_binding.rs b/imkey-core/ikc-device/src/device_binding.rs index f6f1e217..5742e075 100644 --- a/imkey-core/ikc-device/src/device_binding.rs +++ b/imkey-core/ikc-device/src/device_binding.rs @@ -237,7 +237,7 @@ pub fn bind_test() { // pub const TEST_KEY_PATH: &str = "/tmp/"; // pub const TEST_BIND_CODE: &str = "MCYNK5AH"; pub const TEST_KEY_PATH: &str = "/tmp/"; -pub const TEST_BIND_CODE: &str = "7FVRAJJ7"; +pub const TEST_BIND_CODE: &str = "FT2Z3LT2"; #[cfg(test)] mod test { diff --git a/imkey-core/ikc-proto/src/api.proto b/imkey-core/ikc-proto/src/api.proto index 66a70a6e..b1ac8b16 100644 --- a/imkey-core/ikc-proto/src/api.proto +++ b/imkey-core/ikc-proto/src/api.proto @@ -28,7 +28,7 @@ message AddressParam { string chainType = 1; string path = 2; string network = 3; - bool isSegWit = 4; + string segWit = 4; } message AddressResult { diff --git a/imkey-core/ikc-proto/src/btc.proto b/imkey-core/ikc-proto/src/btc.proto index cf4b9c1e..9c12d383 100644 --- a/imkey-core/ikc-proto/src/btc.proto +++ b/imkey-core/ikc-proto/src/btc.proto @@ -3,8 +3,8 @@ package btcapi; message Utxo { string tx_hash = 1; - int32 vout = 2; - int64 amount = 3; + uint32 vout = 2; + uint64 amount = 3; string address = 4; string script_pubKey = 5; string derived_path = 6; @@ -18,13 +18,13 @@ message BtcTxExtra { } message BtcTxInput { string to = 1; - int64 amount = 2; - int64 fee = 3; - uint32 change_address_index = 4; + uint64 amount = 2; + uint64 fee = 3; + optional uint32 change_address_index = 4; repeated Utxo unspents = 5; string segWit = 6; string protocol = 7; - BtcTxExtra extra = 8; + optional BtcTxExtra extra = 8; } message BtcTxOutput { diff --git a/imkey-core/ikc-proto/src/btcfork.proto b/imkey-core/ikc-proto/src/btcfork.proto index faee7d01..f4160478 100644 --- a/imkey-core/ikc-proto/src/btcfork.proto +++ b/imkey-core/ikc-proto/src/btcfork.proto @@ -3,8 +3,8 @@ package btcforkapi; message Utxo { string txHash = 1; - int32 vout = 2; - int64 amount = 3; + uint32 vout = 2; + uint64 amount = 3; string address = 4; string scriptPubKey = 5; string derivedPath = 6; @@ -13,9 +13,9 @@ message Utxo { message BtcForkTxInput { string to = 1; - int64 amount = 2; + uint64 amount = 2; repeated Utxo unspents = 3; - int64 fee = 4; + uint64 fee = 4; uint32 changeAddressIndex = 5; string changeAddress = 6; string segWit = 7; diff --git a/imkey-core/ikc-wallet/coin-bch/Cargo.toml b/imkey-core/ikc-wallet/coin-bch/Cargo.toml index 0ec8a606..4fe5d15f 100644 --- a/imkey-core/ikc-wallet/coin-bch/Cargo.toml +++ b/imkey-core/ikc-wallet/coin-bch/Cargo.toml @@ -17,10 +17,10 @@ secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] } tiny-bip39 = "=1.0.0" anyhow = "=1.0.79" hex = "=0.4.3" -serde = { version = "=1.0.147", features = ["derive"] } +serde = { version = "=1.0.165", features = ["derive"] } serde_json = "=1.0.89" bitcoin_hashes = "=0.11.0" -num-bigint = "=0.4.3" +num-bigint = "=0.4.6" bytes = "=1.4.0" prost = "=0.11.2" prost-types = "=0.11.2" diff --git a/imkey-core/ikc-wallet/coin-bch/src/transaction.rs b/imkey-core/ikc-wallet/coin-bch/src/transaction.rs index 7ded7094..23812d2b 100644 --- a/imkey-core/ikc-wallet/coin-bch/src/transaction.rs +++ b/imkey-core/ikc-wallet/coin-bch/src/transaction.rs @@ -25,8 +25,8 @@ use std::str::FromStr; #[derive(Clone)] pub struct Utxo { pub txhash: String, - pub vout: i32, - pub amount: i64, + pub vout: u32, + pub amount: u64, pub address: String, pub script_pubkey: String, pub derive_path: String, @@ -35,9 +35,9 @@ pub struct Utxo { pub struct BchTransaction { pub to: String, - pub amount: i64, + pub amount: u64, pub unspents: Vec, - pub fee: i64, + pub fee: u64, } impl BchTransaction { @@ -278,15 +278,15 @@ impl BchTransaction { }) } - pub fn get_total_amount(&self) -> i64 { - let mut total_amount: i64 = 0; + pub fn get_total_amount(&self) -> u64 { + let mut total_amount = 0; for unspent in &self.unspents { total_amount += unspent.amount; } total_amount } - pub fn get_change_amount(&self) -> i64 { + pub fn get_change_amount(&self) -> u64 { let total_amount = self.get_total_amount(); let change_amout = total_amount - self.amount - self.fee; change_amout diff --git a/imkey-core/ikc-wallet/coin-bitcoin/Cargo.toml b/imkey-core/ikc-wallet/coin-bitcoin/Cargo.toml index 208aafa0..a4048972 100644 --- a/imkey-core/ikc-wallet/coin-bitcoin/Cargo.toml +++ b/imkey-core/ikc-wallet/coin-bitcoin/Cargo.toml @@ -14,7 +14,7 @@ bitcoin = "=0.29.2" hex = "=0.4.3" secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] } bitcoin_hashes = "=0.11.0" -num-bigint = "=0.4.3" +num-bigint = "=0.4.6" anyhow = "=1.0.79" bytes = "=1.4.0" prost = "=0.11.2" diff --git a/imkey-core/ikc-wallet/coin-bitcoin/src/address.rs b/imkey-core/ikc-wallet/coin-bitcoin/src/address.rs index dcb091f0..c91543a2 100644 --- a/imkey-core/ikc-wallet/coin-bitcoin/src/address.rs +++ b/imkey-core/ikc-wallet/coin-bitcoin/src/address.rs @@ -1,13 +1,16 @@ use crate::common::get_xpub_data; use crate::Result; use bitcoin::network::constants::Network; +use bitcoin::schnorr::UntweakedPublicKey; use bitcoin::util::bip32::{ChainCode, ChildNumber, DerivationPath, ExtendedPubKey, Fingerprint}; use bitcoin::{Address, PublicKey}; +use bitcoin_hashes::{hash160, Hash}; use ikc_common::apdu::{ApduCheck, BtcApdu, CoinCommonApdu}; use ikc_common::error::CommonError; use ikc_common::path::check_path_validity; +use ikc_common::utility::hex_to_bytes; use ikc_transport::message::send_apdu; -use secp256k1::PublicKey as Secp256k1PublicKey; +use secp256k1::{PublicKey as Secp256k1PublicKey, Secp256k1}; use std::str::FromStr; pub struct BtcAddress(); @@ -17,34 +20,24 @@ impl BtcAddress { get btc xpub by path */ pub fn get_xpub(network: Network, path: &str) -> Result { - //path check check_path_validity(path)?; - //get xpub data let xpub_data = get_xpub_data(path, true)?; let xpub_data = &xpub_data[..194].to_string(); - //get public key and chain code let pub_key = &xpub_data[..130]; let chain_code = &xpub_data[130..]; - //build parent public key obj let parent_xpub = get_xpub_data(Self::get_parent_path(path)?, true)?; let parent_xpub = &parent_xpub[..130].to_string(); - // let mut parent_pub_key_obj = PublicKey::from_str(parent_xpub)?; - // parent_pub_key_obj.compressed = true; - let parent_pub_key_obj = Secp256k1PublicKey::from_str(parent_xpub)?; //TODO 是否是压缩公钥 + let parent_pub_key_obj = Secp256k1PublicKey::from_str(parent_xpub)?; - //build child public key obj - // let mut pub_key_obj = PublicKey::from_str(pub_key)?; - // pub_key_obj.compressed = true; - let pub_key_obj = Secp256k1PublicKey::from_str(pub_key)?; //TODO 是否是压缩公钥 + let pub_key_obj = Secp256k1PublicKey::from_str(pub_key)?; - //get parent public key fingerprint let chain_code_obj = ChainCode::from(hex::decode(chain_code).unwrap().as_slice()); let parent_ext_pub_key = ExtendedPubKey { - network: network, - depth: 0 as u8, + network, + depth: 0u8, parent_fingerprint: Fingerprint::default(), child_number: ChildNumber::from_normal_idx(0).unwrap(), public_key: parent_pub_key_obj, @@ -56,21 +49,20 @@ impl BtcAddress { let chain_code_obj = ChainCode::from(hex::decode(chain_code).unwrap().as_slice()); let chain_number_vec: Vec = DerivationPath::from_str(path)?.into(); let extend_public_key = ExtendedPubKey { - network: network, + network, depth: chain_number_vec.len() as u8, parent_fingerprint: fingerprint_obj, child_number: *chain_number_vec.get(chain_number_vec.len() - 1).unwrap(), public_key: pub_key_obj, chain_code: chain_code_obj, }; - //get and return xpub Ok(extend_public_key.to_string()) } /** get btc address by path */ - pub fn get_address(network: Network, path: &str) -> Result { + pub fn p2pkh(network: Network, path: &str) -> Result { //path check check_path_validity(path)?; @@ -87,7 +79,7 @@ impl BtcAddress { /** get segwit address by path */ - pub fn get_segwit_address(network: Network, path: &str) -> Result { + pub fn p2shwpkh(network: Network, path: &str) -> Result { //path check check_path_validity(path)?; @@ -101,6 +93,29 @@ impl BtcAddress { Ok(Address::p2shwpkh(&pub_key_obj, network)?.to_string()) } + pub fn p2wpkh(network: Network, path: &str) -> Result { + check_path_validity(path)?; + + let xpub_data = get_xpub_data(path, true)?; + let pub_key = &xpub_data[..130]; + let mut pub_key_obj = PublicKey::from_str(pub_key)?; + pub_key_obj.compressed = true; + + Ok(Address::p2wpkh(&pub_key_obj, network)?.to_string()) + } + + pub fn p2tr(network: Network, path: &str) -> Result { + check_path_validity(path)?; + + let xpub_data = get_xpub_data(path, true)?; + let pub_key = &xpub_data[..130]; + let untweak_pub_key = + UntweakedPublicKey::from(secp256k1::PublicKey::from_slice(&hex_to_bytes(&pub_key)?)?); + + let secp256k1 = Secp256k1::new(); + Ok(Address::p2tr(&secp256k1, untweak_pub_key, None, network).to_string()) + } + pub fn get_pub_key(path: &str) -> Result { //path check check_path_validity(path)?; @@ -128,28 +143,48 @@ impl BtcAddress { Ok(&path[..end_flg]) } - pub fn display_address(network: Network, path: &str) -> Result { - //path check + pub fn display_address(network: Network, path: &str, seg_wit: &str) -> Result { check_path_validity(path)?; - let address_str = Self::get_address(network, path)?; - // let apdu_res = send_apdu(BtcApdu::btc_coin_reg(address_str.clone().into_bytes()))?; - let apdu_res = send_apdu(BtcApdu::register_address( - &address_str.clone().into_bytes().to_vec(), - ))?; + + let address = match seg_wit { + "P2WPKH" => Self::p2shwpkh(network, path)?, + "VERSION_0" => Self::p2wpkh(network, path)?, + "VERSION_1" => Self::p2tr(network, path)?, + _ => Self::p2pkh(network, path)?, + }; + + let apdu_res = send_apdu(BtcApdu::register_address(&address.as_bytes()))?; ApduCheck::check_response(apdu_res.as_str())?; - Ok(address_str) + Ok(address) } - pub fn display_segwit_address(network: Network, path: &str) -> Result { - //path check - check_path_validity(path)?; - let address_str = Self::get_segwit_address(network, path)?; - // let apdu_res = send_apdu(BtcApdu::btc_coin_reg(address_str.clone().into_bytes()))?; - let apdu_res = send_apdu(BtcApdu::register_address( - &address_str.clone().into_bytes().to_vec(), - ))?; - ApduCheck::check_response(apdu_res.as_str())?; - Ok(address_str) + // pub fn display_segwit_address(network: Network, path: &str) -> Result { + // check_path_validity(path)?; + // let address_str = Self::p2shwpkh(network, path)?; + // let apdu_res = send_apdu(BtcApdu::register_address( + // &address_str.clone().into_bytes().to_vec(), + // ))?; + // ApduCheck::check_response(apdu_res.as_str())?; + // Ok(address_str) + // } + + pub fn from_public_key(public_key: &str, network: Network, seg_wit: &str) -> Result { + let mut pub_key_obj = PublicKey::from_str(public_key)?; + pub_key_obj.compressed = true; + let address = match seg_wit { + "P2WPKH" => Address::p2shwpkh(&pub_key_obj, network)?.to_string(), + "VERSION_0" => Address::p2wpkh(&pub_key_obj, network)?.to_string(), + "VERSION_1" => { + let untweak_pub_key = UntweakedPublicKey::from(secp256k1::PublicKey::from_slice( + &hex_to_bytes(&public_key)?, + )?); + let secp256k1 = Secp256k1::new(); + Address::p2tr(&secp256k1, untweak_pub_key, None, network).to_string() + } + _ => Address::p2pkh(&pub_key_obj, network).to_string(), + }; + + Ok(address) } } @@ -192,12 +227,12 @@ mod test { } #[test] - fn get_address_test() { + fn p2pkh_test() { bind_test(); let version: Network = Network::Bitcoin; let path: &str = "m/44'/0'/0'/0/0"; - let get_btc_address_result = BtcAddress::get_address(version, path); + let get_btc_address_result = BtcAddress::p2pkh(version, path); assert!(get_btc_address_result.is_ok()); let btc_address = get_btc_address_result.ok().unwrap(); @@ -205,18 +240,45 @@ mod test { } #[test] - fn get_segwit_address_test() { + fn p2shwpkh_address_test() { bind_test(); let version: Network = Network::Bitcoin; let path: &str = "m/49'/0'/0'/0/22"; - let segwit_address_result = BtcAddress::get_segwit_address(version, path); + let segwit_address_result = BtcAddress::p2shwpkh(version, path); assert!(segwit_address_result.is_ok()); let segwit_address = segwit_address_result.ok().unwrap(); assert_eq!("37E2J9ViM4QFiewo7aw5L3drF2QKB99F9e", segwit_address); } + #[test] + fn p2wpkh_address_test() { + bind_test(); + + let network: Network = Network::Bitcoin; + let path: &str = "m/49'/0'/0'/0/22"; + let segwit_address_result = BtcAddress::p2wpkh(network, path); + + assert!(segwit_address_result.is_ok()); + let segwit_address = segwit_address_result.ok().unwrap(); + assert_eq!("bc1qe74h3vkdcj94uph4wdpk48nlqjdy42y87mdm7q", segwit_address); + } + #[test] + fn p2tr_address_test() { + bind_test(); + + let network: Network = Network::Bitcoin; + let path: &str = "m/49'/0'/0'/0/22"; + let segwit_address_result = BtcAddress::p2tr(network, path); + + assert!(segwit_address_result.is_ok()); + let segwit_address = segwit_address_result.ok().unwrap(); + assert_eq!( + "bc1ph40wj9vl3kwhxq747wxkcr63e4r3uaryagpetnkey4zqhucmjfzse24jrd", + segwit_address + ); + } #[test] fn get_parent_path_test() { let path = "m/44'/0'/0'/0/0"; @@ -243,7 +305,7 @@ mod test { bind_test(); let version: Network = Network::Bitcoin; let path: &str = "m/44'/0'/0'/0/0"; - let result = BtcAddress::display_address(version, path); + let result = BtcAddress::display_address(version, path, "NONE"); assert!(result.is_ok()); let btc_address = result.ok().unwrap(); @@ -255,7 +317,7 @@ mod test { bind_test(); let network: Network = Network::Bitcoin; let path: &str = "m/49'/0'/0'/0/22"; - let result = BtcAddress::display_segwit_address(network, path); + let result = BtcAddress::display_address(network, path, "P2WPKH"); assert!(result.is_ok()); let segwit_address = result.ok().unwrap(); diff --git a/imkey-core/ikc-wallet/coin-bitcoin/src/btcapi.rs b/imkey-core/ikc-wallet/coin-bitcoin/src/btcapi.rs index f9217c83..0217ac6e 100644 --- a/imkey-core/ikc-wallet/coin-bitcoin/src/btcapi.rs +++ b/imkey-core/ikc-wallet/coin-bitcoin/src/btcapi.rs @@ -3,10 +3,10 @@ pub struct Utxo { #[prost(string, tag = "1")] pub tx_hash: ::prost::alloc::string::String, - #[prost(int32, tag = "2")] - pub vout: i32, - #[prost(int64, tag = "3")] - pub amount: i64, + #[prost(uint32, tag = "2")] + pub vout: u32, + #[prost(uint64, tag = "3")] + pub amount: u64, #[prost(string, tag = "4")] pub address: ::prost::alloc::string::String, #[prost(string, tag = "5")] @@ -31,12 +31,12 @@ pub struct BtcTxExtra { pub struct BtcTxInput { #[prost(string, tag = "1")] pub to: ::prost::alloc::string::String, - #[prost(int64, tag = "2")] - pub amount: i64, - #[prost(int64, tag = "3")] - pub fee: i64, - #[prost(uint32, tag = "4")] - pub change_address_index: u32, + #[prost(uint64, tag = "2")] + pub amount: u64, + #[prost(uint64, tag = "3")] + pub fee: u64, + #[prost(uint32, optional, tag = "4")] + pub change_address_index: ::core::option::Option, #[prost(message, repeated, tag = "5")] pub unspents: ::prost::alloc::vec::Vec, #[prost(string, tag = "6")] diff --git a/imkey-core/ikc-wallet/coin-bitcoin/src/common.rs b/imkey-core/ikc-wallet/coin-bitcoin/src/common.rs index d269bb86..50aeb447 100644 --- a/imkey-core/ikc-wallet/coin-bitcoin/src/common.rs +++ b/imkey-core/ikc-wallet/coin-bitcoin/src/common.rs @@ -1,8 +1,9 @@ use crate::transaction::Utxo; use crate::Result; +use bitcoin::schnorr::UntweakedPublicKey; use bitcoin::util::base58; use bitcoin::util::bip32::{ChainCode, ChildNumber, ExtendedPubKey}; -use bitcoin::{Address, Network, PublicKey}; +use bitcoin::{Address, AddressType, Network, PublicKey}; use ikc_common::apdu::{ApduCheck, BtcApdu, CoinCommonApdu}; use ikc_common::error::CoinError; use ikc_common::utility::{hex_to_bytes, sha256_hash}; @@ -13,43 +14,41 @@ use std::str::FromStr; /** utxo address verify */ -pub fn address_verify( - utxos: &Vec, - network: Network, - trans_type_flg: TransTypeFlg, -) -> Result> { +pub fn address_verify(utxos: &Vec, network: Network) -> Result> { let mut utxo_pub_key_vec: Vec = vec![]; for utxo in utxos { - //get xpub and sign data let xpub_data = get_xpub_data(&utxo.derive_path, false)?; //parsing xpub data - let public_key = &xpub_data[..130]; + let derive_pub_key = &xpub_data[..130]; let chain_code = &xpub_data[130..194]; let mut extend_public_key = ExtendedPubKey { network, depth: 0, parent_fingerprint: Default::default(), child_number: ChildNumber::from_normal_idx(0)?, - public_key: Secp256k1PublicKey::from_str(public_key)?, + public_key: Secp256k1PublicKey::from_str(derive_pub_key)?, chain_code: ChainCode::from(hex_to_bytes(chain_code)?.as_slice()), }; - //verify address - let se_gen_address: Result = match trans_type_flg { - TransTypeFlg::BTC => Ok(Address::p2pkh( - &PublicKey::from_str(extend_public_key.public_key.to_string().as_str())?, - network, - ) - .to_string()), - TransTypeFlg::SEGWIT => Ok(Address::p2shwpkh( - &PublicKey::from_str(extend_public_key.public_key.to_string().as_str())?, - network, - )? - .to_string()), + let public_key = PublicKey::from_str(&extend_public_key.public_key.to_string())?; + let script_pubkey = utxo.address.script_pubkey(); + let mut se_gen_address = "".to_string(); + if script_pubkey.is_p2pkh() { + se_gen_address = Address::p2pkh(&public_key, network).to_string(); + } else if script_pubkey.is_p2sh() { + se_gen_address = Address::p2shwpkh(&public_key, network)?.to_string(); + } else if script_pubkey.is_v0_p2wpkh() { + se_gen_address = Address::p2wpkh(&public_key, network)?.to_string(); + } else if script_pubkey.is_v1_p2tr() { + let untweak_pub_key = UntweakedPublicKey::from(secp256k1::PublicKey::from_slice( + &hex_to_bytes(&derive_pub_key)?, + )?); + let secp256k1 = Secp256k1::new(); + se_gen_address = Address::p2tr(&secp256k1, untweak_pub_key, None, network).to_string(); + } else { + return Err(CoinError::InvalidAddress.into()); }; - let se_gen_address_str = se_gen_address?; - let utxo_address = utxo.address.to_string(); - if !se_gen_address_str.eq(&utxo_address) { + if !se_gen_address.eq(&utxo.address.to_string()) { return Err(CoinError::ImkeyAddressMismatchWithPath.into()); } utxo_pub_key_vec.push(extend_public_key.public_key.to_string()); @@ -57,14 +56,6 @@ pub fn address_verify( Ok(utxo_pub_key_vec) } -/** -Transaction type identification -*/ -pub enum TransTypeFlg { - BTC, - SEGWIT, -} - /** get xpub */ @@ -99,24 +90,32 @@ pub fn secp256k1_sign_verify(public: &[u8], signed: &[u8], message: &[u8]) -> Re get address version */ pub fn get_address_version(network: Network, address: &str) -> Result { - match network { + let version = match network { Network::Bitcoin => { - if !address.starts_with('1') && !address.starts_with('3') { - return Err(CoinError::AddressTypeMismatch.into()); + if address.starts_with('1') || address.starts_with('3') { + let address_bytes = base58::from(address)?; + address_bytes.as_slice()[0] + } else if address.starts_with("bc1") { + 'b' as u8 + } else { + return Err(CoinError::InvalidAddress.into()); } } Network::Testnet => { - if !address.starts_with('m') && !address.starts_with('n') && !address.starts_with('2') { - return Err(CoinError::AddressTypeMismatch.into()); + if address.starts_with('m') || address.starts_with('n') || address.starts_with('2') { + let address_bytes = base58::from(address)?; + address_bytes.as_slice()[0] + } else if address.starts_with("tb1") { + 't' as u8 + } else { + return Err(CoinError::InvalidAddress.into()); } } _ => { return Err(CoinError::ImkeySdkIllegalArgument.into()); } - } - //get address version - let address_bytes = base58::from(address)?; - Ok(address_bytes.as_slice()[0]) + }; + Ok(version) } pub struct TxSignResult { diff --git a/imkey-core/ikc-wallet/coin-bitcoin/src/transaction.rs b/imkey-core/ikc-wallet/coin-bitcoin/src/transaction.rs index 6af419b1..6721e1ba 100644 --- a/imkey-core/ikc-wallet/coin-bitcoin/src/transaction.rs +++ b/imkey-core/ikc-wallet/coin-bitcoin/src/transaction.rs @@ -1,33 +1,35 @@ use crate::address::BtcAddress; -use crate::common::{address_verify, get_address_version, TransTypeFlg, TxSignResult}; +use crate::common::{address_verify, get_address_version, TxSignResult}; use crate::Result; use bitcoin::blockdata::{opcodes, script::Builder}; use bitcoin::consensus::{serialize, Encodable}; use bitcoin::hashes::hex::FromHex; +use bitcoin::psbt::serialize::Serialize; +use bitcoin::schnorr::{TapTweak, UntweakedPublicKey}; +use bitcoin::util::taproot::TapTweakHash; use bitcoin::{ - Address, EcdsaSighashType, Network, OutPoint, PackedLockTime, Script, Sequence, Transaction, - TxIn, TxOut, Witness, + Address, EcdsaSighashType, Network, OutPoint, PackedLockTime, SchnorrSighashType, Script, + Sequence, Transaction, TxIn, TxOut, WPubkeyHash, Witness, }; use bitcoin_hashes::hash160; use bitcoin_hashes::hex::ToHex; use bitcoin_hashes::Hash; use ikc_common::apdu::{ApduCheck, BtcApdu}; -use ikc_common::constants::{ - DUST_THRESHOLD, EACH_ROUND_NUMBER, MAX_OPRETURN_SIZE, MAX_UTXO_NUMBER, TIMEOUT_LONG, -}; +use ikc_common::constants::{MAX_OPRETURN_SIZE, MAX_UTXO_NUMBER, MIN_NONDUST_OUTPUT, TIMEOUT_LONG}; use ikc_common::error::CoinError; -use ikc_common::path::check_path_validity; +use ikc_common::path::{check_path_validity, get_account_path}; use ikc_common::utility::{bigint_to_byte_vec, hex_to_bytes, secp256k1_sign}; use ikc_device::device_binding::KEY_MANAGER; use ikc_transport::message::{send_apdu, send_apdu_timeout}; use secp256k1::ecdsa::Signature; +use std::borrow::Borrow; use std::str::FromStr; #[derive(Clone)] pub struct Utxo { pub txhash: String, - pub vout: i32, - pub amount: i64, + pub vout: u32, + pub amount: u64, pub address: Address, pub script_pubkey: String, pub derive_path: String, @@ -36,245 +38,471 @@ pub struct Utxo { pub struct BtcTransaction { pub to: Address, - pub amount: i64, + pub amount: u64, pub unspents: Vec, - pub fee: i64, + pub fee: u64, } impl BtcTransaction { - pub fn sign_transaction( + pub fn sign_Transaction( &self, network: Network, path: &str, - change_idx: i32, - extra_data: &Vec, + change_idx: Option, + extra_data: Option<&str>, + seg_wit: &str, ) -> Result { //path check check_path_validity(path)?; - let mut path_str = path.to_string(); - if !path.ends_with("/") { - path_str = format!("{}{}", path_str, "/"); - } + //check uxto number if &self.unspents.len() > &MAX_UTXO_NUMBER { return Err(CoinError::ImkeyExceededMaxUtxoNumber.into()); } - //utxo address verify - let utxo_pub_key_vec = address_verify(&self.unspents, network, TransTypeFlg::BTC)?; - //calc utxo total amount if self.get_total_amount() < self.amount { return Err(CoinError::ImkeyInsufficientFunds.into()); } - //add send to output - let mut txouts: Vec = vec![]; - txouts.push(self.build_send_to_output()); - - //add change output - if self.get_change_amount() > DUST_THRESHOLD { - let path_temp = format!("{}{}{}", path_str, "1/", change_idx); - let address_str = BtcAddress::get_address(network, path_temp.as_str())?; - let address_obj = Address::from_str(address_str.as_str())?; - txouts.push(TxOut { - value: self.get_change_amount() as u64, - script_pubkey: address_obj.script_pubkey(), - }); - } + //utxo address verify + let utxo_pub_key_vec = address_verify(&self.unspents, network)?; - //add the op_return - if !extra_data.is_empty() { - if extra_data.len() > MAX_OPRETURN_SIZE { - return Err(CoinError::ImkeySdkIllegalArgument.into()); - } - txouts.push(self.build_op_return_output(&extra_data)) - } + let output = self.tx_output(change_idx, &path, network, seg_wit, extra_data)?; - //output data serialize let mut tx_to_sign = Transaction { version: 1i32, lock_time: PackedLockTime::ZERO, input: vec![], - output: txouts, + output, }; - let mut output_serialize_data = serialize(&tx_to_sign); - - output_serialize_data.remove(5); - output_serialize_data.remove(5); - //add sign type - let mut encoder_hash = Vec::new(); - let len = EcdsaSighashType::All - .to_u32() - .consensus_encode(&mut encoder_hash) - .unwrap(); - debug_assert_eq!(len, encoder_hash.len()); - output_serialize_data.extend(encoder_hash); - //set input number - output_serialize_data.remove(4); - output_serialize_data.insert(4, self.unspents.len() as u8); - - //add fee amount - output_serialize_data.extend(bigint_to_byte_vec(self.fee)); - - //add address version - let address_version = get_address_version(network, self.to.to_string().as_str())?; - output_serialize_data.push(address_version); - - //set 01 tag and length - output_serialize_data.insert(0, output_serialize_data.len() as u8); - output_serialize_data.insert(0, 0x01); + self.calc_tx_hash(&mut tx_to_sign)?; + + self.tx_preview(&tx_to_sign, network)?; + + let input_with_sigs: Vec = vec![]; + for (idx, utxo) in self.unspents.iter().enumerate() { + let script = Script::from_str(&utxo.script_pubkey)?; + if script.is_p2pkh() { + self.sign_p2pkh_input(idx, &utxo_pub_key_vec[idx], &mut tx_to_sign)?; + } else if script.is_p2sh() { + self.sign_p2sh_nested_p2wpkh_input(idx, &utxo_pub_key_vec[idx], &mut tx_to_sign)?; + } else if script.is_v0_p2wpkh() { + self.sign_p2wpkh_input(idx, &utxo_pub_key_vec[idx], &mut tx_to_sign)?; + } else if script.is_v1_p2tr() { + self.sign_p2tr_input( + idx, + &utxo_pub_key_vec[idx], + &mut tx_to_sign, + SchnorrSighashType::Default, + )?; + } else { + return Err(CoinError::InvalidUtxo.into()); + }; + } - //use local private key sign data - let key_manager_obj = KEY_MANAGER.lock(); - let mut output_pareper_data = - secp256k1_sign(&key_manager_obj.pri_key, &output_serialize_data)?; - output_pareper_data.insert(0, output_pareper_data.len() as u8); - output_pareper_data.insert(0, 0x00); - output_pareper_data.extend(output_serialize_data.iter()); + let tx_bytes = serialize(&tx_to_sign); - let btc_prepare_apdu_vec = BtcApdu::btc_prepare(0x41, 0x00, &output_pareper_data); - for temp_str in btc_prepare_apdu_vec { - ApduCheck::check_response(&send_apdu_timeout(temp_str, TIMEOUT_LONG)?)?; - } + Ok(TxSignResult { + signature: tx_bytes.to_hex(), + tx_hash: tx_to_sign.txid().to_hex(), + wtx_id: tx_to_sign.wtxid().to_hex(), + }) + } - let mut lock_script_ver: Vec