Skip to content

Commit 4e24b73

Browse files
committed
WIP: Verify removal of Index trait bound
Verify we can still build after `bitcoin_hashes` removes the `Index` trait bound and replaces it for `AsRef`.
1 parent 7fde332 commit 4e24b73

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ serde = { version = "1.0", default-features = false, optional = true }
4141

4242
# You likely only want to enable these if you explicitly do not want to use "std", otherwise enable
4343
# the respective -std feature e.g., bitcoin-hashes-std
44-
bitcoin_hashes = { version = "0.11", default-features = false, optional = true }
44+
bitcoin_hashes = { git = "https://github.com/tcharding/bitcoin_hashes", branch = "08-09-rm-index-impls", default-features = false, optional = true }
4545
rand = { version = "0.8", default-features = false, optional = true }
4646

4747
[dev-dependencies]
4848
rand = "0.8"
4949
rand_core = "0.6"
5050
serde_test = "1.0"
51-
bitcoin_hashes = "0.11"
51+
bitcoin_hashes = { git = "https://github.com/tcharding/bitcoin_hashes", branch = "08-09-rm-index-impls" }
5252
bincode = "1.3.3"
5353

5454
# cbor does not build on WASM, we use it in a single trivial test (an example of when

examples/sign_verify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use secp256k1::{Error, Message, PublicKey, Secp256k1, SecretKey, ecdsa, Signing,
66

77
fn verify<C: Verification>(secp: &Secp256k1<C>, msg: &[u8], sig: [u8; 64], pubkey: [u8; 33]) -> Result<bool, Error> {
88
let msg = sha256::Hash::hash(msg);
9-
let msg = Message::from_slice(&msg)?;
9+
let msg = Message::from_slice(msg.as_ref())?;
1010
let sig = ecdsa::Signature::from_compact(&sig)?;
1111
let pubkey = PublicKey::from_slice(&pubkey)?;
1212

@@ -15,7 +15,7 @@ fn verify<C: Verification>(secp: &Secp256k1<C>, msg: &[u8], sig: [u8; 64], pubke
1515

1616
fn sign<C: Signing>(secp: &Secp256k1<C>, msg: &[u8], seckey: [u8; 32]) -> Result<ecdsa::Signature, Error> {
1717
let msg = sha256::Hash::hash(msg);
18-
let msg = Message::from_slice(&msg)?;
18+
let msg = Message::from_slice(msg.as_ref())?;
1919
let seckey = SecretKey::from_slice(&seckey)?;
2020
Ok(secp.sign_ecdsa(&msg, &seckey))
2121
}

examples/sign_verify_recovery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use secp256k1::{Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verifi
77

88
fn recover<C: Verification>(secp: &Secp256k1<C>,msg: &[u8],sig: [u8; 64],recovery_id: u8) -> Result<PublicKey, Error> {
99
let msg = sha256::Hash::hash(msg);
10-
let msg = Message::from_slice(&msg)?;
10+
let msg = Message::from_slice(msg.as_ref())?;
1111
let id = ecdsa::RecoveryId::from_i32(recovery_id as i32)?;
1212
let sig = ecdsa::RecoverableSignature::from_compact(&sig, id)?;
1313

@@ -16,7 +16,7 @@ fn recover<C: Verification>(secp: &Secp256k1<C>,msg: &[u8],sig: [u8; 64],recover
1616

1717
fn sign_recovery<C: Signing>(secp: &Secp256k1<C>, msg: &[u8], seckey: [u8; 32]) -> Result<ecdsa::RecoverableSignature, Error> {
1818
let msg = sha256::Hash::hash(msg);
19-
let msg = Message::from_slice(&msg)?;
19+
let msg = Message::from_slice(msg.as_ref())?;
2020
let seckey = SecretKey::from_slice(&seckey)?;
2121
Ok(secp.sign_ecdsa_recoverable(&msg, &seckey))
2222
}

src/secret.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ macro_rules! impl_display_secret {
5252

5353
let mut engine = sha256::Hash::engine();
5454
let tag_hash = sha256::Hash::hash(tag.as_bytes());
55-
engine.input(&tag_hash[..]);
56-
engine.input(&tag_hash[..]);
55+
engine.input(tag_hash.as_ref());
56+
engine.input(tag_hash.as_ref());
5757
engine.input(&self.secret_bytes());
5858
let hash = sha256::Hash::from_engine(engine);
5959

0 commit comments

Comments
 (0)