Skip to content

Commit

Permalink
chore(bip0039): replace hex with const-hex (#75)
Browse files Browse the repository at this point in the history
* chore(bip0039): replace hex with const-hex

* update rust-version

* update msrv to 1.64.0
  • Loading branch information
koushiro authored Aug 17, 2024
1 parent 01f92a4 commit a3a9627
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bip0039.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.61.0
toolchain: 1.64.0
override: true

- name: Test
Expand Down
4 changes: 2 additions & 2 deletions bip0039/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "bip0039"
version = "0.12.0"
authors = ["koushiro <[email protected]>"]
edition = "2021"
rust-version = "1.60.0"
rust-version = "1.64.0"
resolver = "2"

description = "Another Rust implementation of BIP-0039 standard"
Expand Down Expand Up @@ -62,6 +62,6 @@ unicode-normalization = { version = "0.1", default-features = false }
zeroize = "1.2"

[dev-dependencies]
hex = "0.4"
const-hex = "1.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
2 changes: 1 addition & 1 deletion bip0039/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[crates-url]: https://crates.io/crates/bip0039
[docs-svg]: https://docs.rs/bip0039/badge.svg
[docs-url]: https://docs.rs/bip0039
[msrv-svg]: https://img.shields.io/badge/rustc-1.61+-blue.svg
[msrv-svg]: https://img.shields.io/badge/rustc-1.64+-blue.svg

Another Rust implementation of [BIP-0039](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) standard.

Expand Down
2 changes: 1 addition & 1 deletion bip0039/src/language/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod tests {
assert!(unicode_normalization::is_nfkd(word));
digest.update(format!("{}\n", word));
}
assert_eq!(hex::encode(digest.finalize()), $checksum);
assert_eq!(const_hex::encode(digest.finalize()), $checksum);
}};
}

Expand Down
2 changes: 1 addition & 1 deletion bip0039/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//!
//! // Generates the HD wallet seed from the mnemonic and the passphrase.
//! let seed = mnemonic.to_seed("");
//! println!("seed: {}", hex::encode(&seed[..]));
//! println!("seed: {}", const_hex::encode(&seed[..]));
//! ```
//!
#![cfg_attr(
Expand Down
2 changes: 1 addition & 1 deletion bip0039/src/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ assert_eq!(result.unwrap_err(), Error::UnknownWord("ばか".nfkd().to_string()))
/// let mnemonic = <Mnemonic>::from_phrase(phrase).unwrap();
/// assert_eq!(
/// mnemonic.to_seed("").to_vec(),
/// hex::decode("02d5cd1db85b4d1397d78978062a1160e76e94cc5aaad3089644846865bb18fc68ddf383059d3fe82902a203d60790a8c8ab488de5013d10a8a8bded8d9174b9").unwrap()
/// const_hex::decode("02d5cd1db85b4d1397d78978062a1160e76e94cc5aaad3089644846865bb18fc68ddf383059d3fe82902a203d60790a8c8ab488de5013d10a8a8bded8d9174b9").unwrap()
/// );
/// ```
pub fn to_seed<P: AsRef<str>>(&self, passphrase: P) -> [u8; 64] {
Expand Down
4 changes: 2 additions & 2 deletions bip0039/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ fn test_mnemonic<L: Language>(
expected_phrase: &str,
expected_seed_hex: &str,
) {
let entropy = hex::decode(entropy_hex).unwrap();
let entropy = const_hex::decode(entropy_hex).unwrap();
let mnemonic = <Mnemonic<L>>::from_entropy(entropy).unwrap();
assert_eq!(mnemonic.phrase(), expected_phrase.nfkd().to_string());
assert!(<Mnemonic<L>>::from_phrase(expected_phrase).is_ok());

let seed = mnemonic.to_seed(passphrase);
assert_eq!(hex::encode(&seed[..]), expected_seed_hex);
assert_eq!(const_hex::encode(&seed[..]), expected_seed_hex);
}

0 comments on commit a3a9627

Please sign in to comment.