Skip to content

Commit 7c9170a

Browse files
committed
Merge branch 'update-btc-deps'
2 parents fe0475b + 57e9f70 commit 7c9170a

File tree

529 files changed

+44503
-49415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

529 files changed

+44503
-49415
lines changed

src/rust/Cargo.lock

Lines changed: 29 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rust/bitbox02-rust-c/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ util = { path = "../util" }
3030
hex = { version = "0.4", default-features = false }
3131
sha2 = { version = "0.10.8", default-features = false, optional = true }
3232
sha3 = { version = "0.10.8", default-features = false, optional = true }
33-
bitcoin = { version = "0.30.0", default-features = false, features = ["no-std"], optional = true }
33+
bitcoin = { version = "0.31.0", default-features = false, features = ["no-std"], optional = true }
3434

3535
[features]
3636
# Only one of the "target-" should be activated, which in turn defines/activates the dependent features.

src/rust/bitbox02-rust/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ zeroize = "1.6.0"
3838
num-bigint = { version = "0.4.3", default-features = false, optional = true }
3939
num-traits = { version = "0.2", default-features = false, optional = true }
4040
bip32-ed25519 = { git = "https://github.com/digitalbitbox/rust-bip32-ed25519", tag = "v0.1.2", optional = true }
41-
bech32 = { version = "0.9", default-features = false, optional = true }
41+
bech32 = { version = "0.10.0-beta", default-features = false, optional = true }
4242
blake2 = { version = "0.10.6", default-features = false, optional = true }
4343
minicbor = { version = "0.20.0", default-features = false, features = ["alloc"], optional = true }
4444
crc = { version = "3.0.1", optional = true }
@@ -47,8 +47,12 @@ lazy_static = { version = "1.4.0", optional = true }
4747
async-recursion = "1.0.5"
4848
hmac = { version = "0.12.1", default-features = false, features = ["reset"] }
4949

50-
miniscript = { version = "10.0.0", default-features = false, features = ["no-std"], optional = true }
51-
bitcoin = { version = "0.30.0", default-features = false, features = ["no-std"], optional = true }
50+
miniscript = { version = "11.0.0", default-features = false, features = ["no-std"], optional = true }
51+
bitcoin = { version = "0.31.0", default-features = false, features = ["no-std"], optional = true }
52+
# We don't rely on this dep directly, the miniscript/bitcoin deps do. We list it here to enable the
53+
# small-hash feature to reduce the binary size, saving around 2784 bytes (as measured at time of
54+
# writing, this might fluctuate over time).
55+
bitcoin_hashes = { version = "0.13.0", default-features = false, features = ["small-hash"] }
5256

5357
[dependencies.prost]
5458
# keep version in sync with tools/prost-build/Cargo.toml.

src/rust/bitbox02-rust/src/hww/api/bitcoin/common.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ use alloc::string::String;
2121
use alloc::vec::Vec;
2222
use core::convert::TryFrom;
2323

24-
use bech32::{ToBase32, Variant};
25-
2624
use pb::btc_script_config::SimpleType;
2725
pub use pb::btc_sign_init_request::FormatUnit;
2826
pub use pb::{BtcCoin, BtcOutputType};
@@ -305,14 +303,12 @@ fn encode_segwit_addr(
305303
witness_version: u8,
306304
witness_program: &[u8],
307305
) -> Result<String, ()> {
308-
let variant = match witness_version {
309-
0 => Variant::Bech32,
310-
1 => Variant::Bech32m,
306+
let version = match witness_version {
307+
0 => bech32::segwit::VERSION_0,
308+
1 => bech32::segwit::VERSION_1,
311309
_ => return Err(()),
312310
};
313-
let mut b32 = witness_program.to_base32();
314-
b32.insert(0, bech32::u5::try_from_u8(witness_version).or(Err(()))?);
315-
bech32::encode(hrp, &b32, variant).or(Err(()))
311+
bech32::segwit::encode(&bech32::Hrp::parse_unchecked(hrp), version, witness_program).or(Err(()))
316312
}
317313

318314
#[cfg(test)]

src/rust/bitbox02-rust/src/hww/api/cardano/address.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ use pb::cardano_response::Response;
2525
use pb::cardano_script_config::Config;
2626
use pb::CardanoNetwork;
2727

28-
use bech32::{FromBase32, ToBase32, Variant};
29-
3028
use blake2::{
3129
digest::{Update, VariableOutput},
3230
Blake2bVar,
@@ -44,11 +42,14 @@ pub const ADDRESS_HASH_SIZE: usize = 28;
4442
/// https://github.com/cardano-foundation/CIPs/blob/0081c890995ff94618145ae5beb7f288c029a86a/CIP-0019/CIP-0019.md#shelley-addresses
4543
/// See also: https://github.com/input-output-hk/cardano-ledger-specs/blob/d0aa86ded0b973b09b629e5aa62aa1e71364d088/eras/alonzo/test-suite/cddl-files/alonzo.cddl#L119-L127
4644
fn decode_shelley_payment_address(params: &params::Params, address: &str) -> Result<Vec<u8>, ()> {
47-
let (hrp, data, variant) = bech32::decode(address).or(Err(()))?;
48-
if variant != Variant::Bech32 || hrp != params.bech32_hrp_payment {
45+
let result =
46+
bech32::primitives::decode::CheckedHrpstring::new::<bech32::Bech32>(address).or(Err(()))?;
47+
// TODO: use `result.hrp().as_str()` once bech32 has a new release.
48+
let hrp: String = result.hrp().char_iter().collect();
49+
if hrp != params.bech32_hrp_payment {
4950
return Err(());
5051
}
51-
let data = Vec::from_base32(&data).or(Err(()))?;
52+
let data: Vec<u8> = result.byte_iter().collect();
5253
if data.is_empty() {
5354
return Err(());
5455
}
@@ -189,10 +190,9 @@ pub fn validate_and_encode_payment_address(
189190
bytes.extend_from_slice(&payment_key_hash);
190191
bytes.extend_from_slice(&stake_key_hash);
191192

192-
Ok(bech32::encode(
193-
params.bech32_hrp_payment,
194-
bytes.to_base32(),
195-
Variant::Bech32,
193+
Ok(bech32::encode::<bech32::Bech32>(
194+
bech32::Hrp::parse_unchecked(params.bech32_hrp_payment),
195+
&bytes,
196196
)
197197
.unwrap())
198198
}

src/rust/bitbox02-rust/src/hww/api/cardano/sign_transaction.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use alloc::string::String;
2222
use alloc::vec::Vec;
2323
use core::convert::TryFrom;
2424

25-
use bech32::{ToBase32, Variant};
2625
use blake2::{
2726
digest::{Update, VariableOutput},
2827
Blake2bVar,
@@ -92,7 +91,7 @@ fn format_asset(policy_id: &[u8], asset_name: &[u8]) -> String {
9291
hasher.update(asset_name);
9392
let mut hash = [0u8; 20];
9493
hasher.finalize_variable(&mut hash).unwrap();
95-
bech32::encode("asset", hash.to_base32(), Variant::Bech32).unwrap()
94+
bech32::encode::<bech32::Bech32>(bech32::Hrp::parse_unchecked("asset"), &hash).unwrap()
9695
}
9796

9897
/// Validate size limits in the asset groups and that there are no duplicate assets.

src/rust/vendor/ahash/.cargo-checksum.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)