Skip to content

Commit

Permalink
Merge #573: Use library to_hex function
Browse files Browse the repository at this point in the history
bdfa0ff Use library to_hex function (Tobin C. Harding)

Pull request description:

  We do not need to use the `hex` module from `bitcoin_hashes` to encode into hex, we have a function in this library.

  Use library hex encoding logic, removes dependency on the `hex` module of `bitcoin_hashes` entirely from this crate.

ACKs for top commit:
  apoelstra:
    ACK bdfa0ff

Tree-SHA512: 0923939cfeb3cb4f8a3c2fad3961f2b17d3083d85232b3992d9efef59e622fa18f6ecf3c93b064518a7cb6ac4b704480a59ecdc3bcc016811758b4a13b00d31f
  • Loading branch information
apoelstra committed Jan 25, 2023
2 parents 0e689c7 + bdfa0ff commit 92c4923
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2401,14 +2401,13 @@ mod test {
}

#[test]
#[cfg(all(feature = "rand-std", feature = "bitcoin-hashes-std"))]
#[cfg(feature = "rand-std")]
fn test_keypair_from_str() {
use bitcoin_hashes::hex::ToHex;

let ctx = crate::Secp256k1::new();
let keypair = KeyPair::new(&ctx, &mut rand::thread_rng());
let msg = keypair.secret_key().secret_bytes().to_hex();
let parsed_key: KeyPair = msg.parse().unwrap();
let mut buf = [0_u8; constants::SECRET_KEY_SIZE * 2]; // Holds hex digits.
let s = to_hex(&keypair.secret_key().secret_bytes(), &mut buf).unwrap();
let parsed_key = KeyPair::from_str(s).unwrap();
assert_eq!(parsed_key, keypair);
}

Expand Down

0 comments on commit 92c4923

Please sign in to comment.