Replace ripemd160 dependency with ripemd

This commit is contained in:
Kris Nuttycombe 2022-01-31 16:24:03 -07:00
parent d0e1f98429
commit 8916a16f38
3 changed files with 17 additions and 15 deletions

View File

@ -40,7 +40,7 @@ orchard = "=0.1.0-beta.1"
proptest = { version = "1.0.0", optional = true }
rand = "0.8"
rand_core = "0.6"
ripemd160 = { version = "0.9", optional = true }
ripemd = { version = "0.1", optional = true }
secp256k1 = { version = "0.20", optional = true }
sha2 = "0.9"
subtle = "2.2.3"
@ -61,7 +61,7 @@ orchard = { version = "=0.1.0-beta.1", features = ["test-dependencies"] }
pprof = { version = "=0.6.1", features = ["criterion", "flamegraph"] }
[features]
transparent-inputs = ["bs58", "hdwallet", "ripemd160", "secp256k1"]
transparent-inputs = ["bs58", "hdwallet", "ripemd", "secp256k1"]
test-dependencies = ["proptest", "orchard/test-dependencies"]
zfuture = []

View File

@ -1,6 +1,7 @@
use hdwallet::{ExtendedPrivKey, ExtendedPubKey, KeyIndex};
use ripemd::Digest as RipemdDigest;
use secp256k1::PublicKey;
use sha2::{Digest, Sha256};
use sha2::{Digest as Sha2Digest, Sha256};
use std::convert::TryInto;
use crate::{consensus, keys::prf_expand_vec, zip32::AccountId};
@ -135,7 +136,7 @@ impl AccountPubKey {
/// Derives the P2PKH transparent address corresponding to the given pubkey.
#[deprecated(note = "This function will be removed from the public API in an upcoming refactor.")]
pub fn pubkey_to_address(pubkey: &secp256k1::key::PublicKey) -> TransparentAddress {
let mut hash160 = ripemd160::Ripemd160::new();
let mut hash160 = ripemd::Ripemd160::new();
hash160.update(Sha256::digest(&pubkey.serialize()));
TransparentAddress::PublicKey(*hash160.finalize().as_ref())
}

View File

@ -2,9 +2,6 @@
use std::fmt;
#[cfg(feature = "transparent-inputs")]
use blake2b_simd::Hash as Blake2bHash;
use crate::{
legacy::TransparentAddress,
transaction::components::{
@ -14,14 +11,18 @@ use crate::{
};
#[cfg(feature = "transparent-inputs")]
use crate::{
legacy::Script,
transaction::{
self as tx,
components::OutPoint,
sighash::{signature_hash, SignableInput, SIGHASH_ALL},
TransactionData, TxDigests,
use {
crate::{
legacy::Script,
transaction::{
self as tx,
components::OutPoint,
sighash::{signature_hash, SignableInput, SIGHASH_ALL},
TransactionData, TxDigests,
},
},
blake2b_simd::Hash as Blake2bHash,
ripemd::Digest,
};
#[derive(Debug, PartialEq)]
@ -96,7 +97,7 @@ impl TransparentBuilder {
let pubkey = secp256k1::PublicKey::from_secret_key(&self.secp, &sk).serialize();
match coin.script_pubkey.address() {
Some(TransparentAddress::PublicKey(hash)) => {
use ripemd160::Ripemd160;
use ripemd::Ripemd160;
use sha2::{Digest, Sha256};
if hash[..] != Ripemd160::digest(&Sha256::digest(&pubkey))[..] {