From 4e004ff983fd537873e22865019cab81d4ab1d84 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Mon, 23 Sep 2024 08:37:01 -0600 Subject: [PATCH] bip32: use prerelease dependencies; MSRV 1.72 Updates to the following prereleases: - `hmac` v0.13.0-pre.4 - `ripemd` v0.2.0-pre.4 - `sha2` v0.11.0-pre.4 - `k256` v0.14.0-pre.2 - `pbkdf2` v0.13.0-pre.1 --- .github/workflows/bip32.yml | 4 +- .github/workflows/workspace.yml | 2 +- Cargo.toml | 3 +- README.md | 2 +- bip32/Cargo.lock | 422 ++++++++++++++++++++++++++ bip32/Cargo.toml | 14 +- bip32/README.md | 6 +- bip32/src/extended_key.rs | 2 +- bip32/src/extended_key/private_key.rs | 2 +- bip32/src/mnemonic/phrase.rs | 2 +- bip32/src/prefix.rs | 2 +- bip32/src/private_key.rs | 2 +- bip32/src/public_key.rs | 2 +- 13 files changed, 444 insertions(+), 21 deletions(-) create mode 100644 bip32/Cargo.lock diff --git a/.github/workflows/bip32.yml b/.github/workflows/bip32.yml index 2f0932cc..97199412 100644 --- a/.github/workflows/bip32.yml +++ b/.github/workflows/bip32.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: rust: - - 1.65.0 # MSRV + - 1.72.0 # MSRV - stable target: - armv7a-none-eabi @@ -50,7 +50,7 @@ jobs: - macos-latest - windows-latest toolchain: - - 1.65.0 # MSRV + - 1.72.0 # MSRV - stable runs-on: ${{ matrix.platform }} steps: diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 1a9e83fa..6e5e2184 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.70.0 # MSRV + toolchain: 1.72.0 # MSRV components: clippy override: true profile: minimal diff --git a/Cargo.toml b/Cargo.toml index 6d4bea9c..9716759d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = [ - "bip32", + #"bip32", "canonical-path", "hkd32", "iqhttp", @@ -9,3 +9,4 @@ members = [ "signatory", "subtle-encoding", ] +exclude = ["bip32"] diff --git a/README.md b/README.md index e0f94a13..a6386095 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This repository contains the following crates: ## License -Copyright © 2018-2023 iqlusion +Copyright © 2018-2024 iqlusion Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/bip32/Cargo.lock b/bip32/Cargo.lock new file mode 100644 index 00000000..fcaacdc8 --- /dev/null +++ b/bip32/Cargo.lock @@ -0,0 +1,422 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "bip32" +version = "0.6.0-pre" +dependencies = [ + "bs58", + "hex-literal", + "hmac", + "k256", + "once_cell", + "pbkdf2", + "rand_core", + "ripemd", + "secp256k1", + "sha2 0.11.0-pre.4", + "subtle", + "zeroize", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.11.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8969801e57d15e15bc4d7cdc5600dc15ca06a9a62b622bd4871c2d21d8aeb42d" +dependencies = [ + "crypto-common 0.2.0-rc.1", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2 0.10.8", +] + +[[package]] +name = "cc" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-oid" +version = "0.10.0-rc.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9adcf94f05e094fca3005698822ec791cb4433ced416afda1c5ca3b8dfc05a2f" + +[[package]] +name = "cpufeatures" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-bigint" +version = "0.6.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "040a95c58773f47c92f5f17814702bfd68e8ace9ddce4690c982d0019cac32e2" +dependencies = [ + "hybrid-array", + "num-traits", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "der" +version = "0.8.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82db698b33305f0134faf590b9d1259dc171b5481ac41d5c8146c3b3ee7d4319" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.6", +] + +[[package]] +name = "digest" +version = "0.11.0-pre.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379" +dependencies = [ + "block-buffer 0.11.0-rc.1", + "const-oid", + "crypto-common 0.2.0-rc.1", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.17.0-pre.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e62f2041a28c40b8884b79fbd19bc7457d76c6397767831e9ff4029fc0473a9" +dependencies = [ + "der", + "digest 0.11.0-pre.9", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "elliptic-curve" +version = "0.14.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc43715037532dc2d061e5c97e81b684c28993d52a4fa4eb7d2ce2826d78f2f2" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.11.0-pre.9", + "ff", + "group", + "hybrid-array", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hmac" +version = "0.13.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58" +dependencies = [ + "digest 0.11.0-pre.9", +] + +[[package]] +name = "hybrid-array" +version = "0.2.0-rc.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae36f8710514b3e7aab028021733330de6e455e0352e19c6dd4513eecb7aa9a" +dependencies = [ + "typenum", + "zeroize", +] + +[[package]] +name = "k256" +version = "0.14.0-pre.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6995f4341b819603e1b836b530ba1c33bbb677d0a3d68ed122a55081abfc82dd" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2 0.11.0-pre.4", +] + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "pbkdf2" +version = "0.13.0-pre.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e11753d5193f26dc27ae698e0b536b5e511b7799c5ac475ec10783f26d164a" +dependencies = [ + "digest 0.11.0-pre.9", + "hmac", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rfc6979" +version = "0.5.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871ee76a3eee98b0f805e5d1caf26929f4565073c580c053a55f886fc15dea49" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ripemd" +version = "0.2.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48cf93482ea998ad1302c42739bc73ab3adc574890c373ec89710e219357579" +dependencies = [ + "digest 0.11.0-pre.9", +] + +[[package]] +name = "sec1" +version = "0.8.0-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce9453a41af5251f8439173d21b0ed2ae5d4a7c411abb76661806a44811a9d2c" +dependencies = [ + "base16ct", + "der", + "hybrid-array", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.11.0-pre.9", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signature" +version = "2.3.0-pre.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054d71959c7051b9042c26af337f05cc930575ed2604d7d3ced3158383e59734" +dependencies = [ + "digest 0.11.0-pre.9", + "rand_core", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/bip32/Cargo.toml b/bip32/Cargo.toml index 0df44a9b..f8f10f68 100644 --- a/bip32/Cargo.toml +++ b/bip32/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bip32" -version = "0.5.2" +version = "0.6.0-pre" description = """ BIP32 hierarchical key derivation implemented in a generic, no_std-friendly manner. Supports deriving keys using the pure Rust k256 crate or the @@ -14,21 +14,21 @@ categories = ["cryptography", "no-std"] keywords = ["crypto", "bip32", "bip39", "derivation", "mnemonic"] readme = "README.md" edition = "2021" -rust-version = "1.65" +rust-version = "1.72" [dependencies] bs58 = { version = "0.5", default-features = false, features = ["check"] } -hmac = { version = "0.12", default-features = false } +hmac = { version = "=0.13.0-pre.4", default-features = false } rand_core = { version = "0.6", default-features = false } -ripemd = { version = "0.1", default-features = false } -sha2 = { version = "0.10", default-features = false } +ripemd = { version = "=0.2.0-pre.4", default-features = false } +sha2 = { version = "=0.11.0-pre.4", default-features = false } subtle = { version = "2", default-features = false } zeroize = { version = "1", default-features = false } # optional dependencies -k256 = { version = "0.13", optional = true, default-features = false, features = ["ecdsa", "sha256"] } +k256 = { version = "=0.14.0-pre.2", optional = true, default-features = false, features = ["ecdsa", "sha256"] } once_cell = { version = "1", optional = true } -pbkdf2 = { version = "0.12", optional = true, default-features = false, features = ["hmac"] } +pbkdf2 = { version = "=0.13.0-pre.1", optional = true, default-features = false, features = ["hmac"] } secp256k1-ffi = { package = "secp256k1", version = "0.27", optional = true } [dev-dependencies] diff --git a/bip32/README.md b/bip32/README.md index 09a7f036..34409bfd 100644 --- a/bip32/README.md +++ b/bip32/README.md @@ -24,7 +24,7 @@ from a set of 24-words from a preset list, a.k.a. a "mnemonic". ## Minimum Supported Rust Version -Rust **1.65** or newer. +Rust **1.72** or newer. In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's SemVer guarantees), however when we do it will be accompanied by @@ -48,13 +48,13 @@ without any additional terms or conditions. [//]: # (badges) -[crate-image]: https://img.shields.io/crates/v/bip32.svg +[crate-image]: https://img.shields.io/crates/v/bip32.svg?logo=rust [crate-link]: https://crates.io/crates/bip32 [docs-image]: https://docs.rs/bip32/badge.svg [docs-link]: https://docs.rs/bip32/ [license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg [license-link]: https://github.com/iqlusioninc/crates/blob/main/LICENSE -[rustc-image]: https://img.shields.io/badge/rustc-1.65+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.72+-blue.svg [safety-image]: https://img.shields.io/badge/unsafe-forbidden-success.svg [safety-link]: https://github.com/rust-secure-code/safety-dance/ [build-image]: https://github.com/iqlusioninc/crates/actions/workflows/bip32.yml/badge.svg diff --git a/bip32/src/extended_key.rs b/bip32/src/extended_key.rs index 63600720..a4496521 100644 --- a/bip32/src/extended_key.rs +++ b/bip32/src/extended_key.rs @@ -49,7 +49,7 @@ impl ExtendedKey { bytes[13..45].copy_from_slice(&self.attrs.chain_code); bytes[45..78].copy_from_slice(&self.key_bytes); - let base58_len = bs58::encode(&bytes).with_check().onto(buffer.as_mut())?; + let base58_len = bs58::encode(&bytes).with_check().onto(buffer.as_mut_slice())?; bytes.zeroize(); str::from_utf8(&buffer[..base58_len]).map_err(|_| Error::Base58) diff --git a/bip32/src/extended_key/private_key.rs b/bip32/src/extended_key/private_key.rs index cd8f7ff6..ae178b31 100644 --- a/bip32/src/extended_key/private_key.rs +++ b/bip32/src/extended_key/private_key.rs @@ -8,7 +8,7 @@ use core::{ fmt::{self, Debug}, str::FromStr, }; -use hmac::Mac; +use hmac::{KeyInit, Mac}; use subtle::{Choice, ConstantTimeEq}; use zeroize::Zeroize; diff --git a/bip32/src/mnemonic/phrase.rs b/bip32/src/mnemonic/phrase.rs index 251d185e..63ed80a1 100644 --- a/bip32/src/mnemonic/phrase.rs +++ b/bip32/src/mnemonic/phrase.rs @@ -44,7 +44,7 @@ impl Phrase { /// Create a new BIP39 mnemonic phrase from the given entropy pub fn from_entropy(entropy: Entropy, language: Language) -> Self { let wordlist = language.wordlist(); - let checksum_byte = Sha256::digest(entropy.as_ref()).as_slice()[0]; + let checksum_byte = Sha256::digest(entropy.as_slice()).as_slice()[0]; // First, create a byte iterator for the given entropy and the first byte of the // hash of the entropy that will serve as the checksum (up to 8 bits for biggest diff --git a/bip32/src/prefix.rs b/bip32/src/prefix.rs index 329b682c..3076e003 100644 --- a/bip32/src/prefix.rs +++ b/bip32/src/prefix.rs @@ -86,7 +86,7 @@ impl Prefix { bytes[..4].copy_from_slice(&version.to_be_bytes()); let mut buffer = [0u8; ExtendedKey::MAX_BASE58_SIZE]; - bs58::encode(&bytes).with_check().onto(buffer.as_mut())?; + bs58::encode(&bytes).with_check().onto(buffer.as_mut_slice())?; let s = str::from_utf8(&buffer[..4]).map_err(|_| Error::Base58)?; Self::validate_str(s)?; diff --git a/bip32/src/private_key.rs b/bip32/src/private_key.rs index 95b5a900..51107343 100644 --- a/bip32/src/private_key.rs +++ b/bip32/src/private_key.rs @@ -1,7 +1,7 @@ //! Trait for deriving child keys on a given type. use crate::{ChainCode, ChildNumber, Error, HmacSha512, PublicKey, Result, KEY_SIZE}; -use hmac::Mac; +use hmac::{KeyInit, Mac}; #[cfg(feature = "secp256k1")] use crate::XPrv; diff --git a/bip32/src/public_key.rs b/bip32/src/public_key.rs index a6e0121a..a8aafb72 100644 --- a/bip32/src/public_key.rs +++ b/bip32/src/public_key.rs @@ -3,7 +3,7 @@ use crate::{ ChainCode, ChildNumber, Error, HmacSha512, KeyFingerprint, PrivateKeyBytes, Result, KEY_SIZE, }; -use hmac::Mac; +use hmac::{KeyInit, Mac}; use ripemd::Ripemd160; use sha2::{Digest, Sha256};