From 46707eab19c58f429369f3f9a1598f74915b2781 Mon Sep 17 00:00:00 2001 From: Christian Reitter Date: Fri, 8 Dec 2023 21:58:19 +0100 Subject: [PATCH 1/3] Optimize speed by skipping 4-byte fingerprint generation --- bitcoin/src/bip32.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index fa019bac4..be26aa878 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -626,10 +626,13 @@ impl Xpriv { let tweaked = sk.add_tweak(&self.private_key.into()).expect("statistically impossible to hit"); + // BREAKING CHANGE + // parent_fingerprint: self.fingerprint(secp), + // this brings a strong performance improvement Ok(Xpriv { network: self.network, depth: self.depth + 1, - parent_fingerprint: self.fingerprint(secp), + parent_fingerprint: Default::default(), child_number: i, private_key: tweaked, chain_code: ChainCode::from_hmac(hmac_result), @@ -758,10 +761,13 @@ impl Xpub { let (sk, chain_code) = self.ckd_pub_tweak(i)?; let tweaked = self.public_key.add_exp_tweak(secp, &sk.into())?; + // BREAKING CHANGE + // parent_fingerprint: self.fingerprint(), + // this brings less of a performance improvement Ok(Xpub { network: self.network, depth: self.depth + 1, - parent_fingerprint: self.fingerprint(), + parent_fingerprint: Default::default(), child_number: i, public_key: tweaked, chain_code, From d7294a88041b6f533c735564b69c1de11aa33e6f Mon Sep 17 00:00:00 2001 From: Christian Reitter Date: Sat, 27 Apr 2024 13:19:39 +0200 Subject: [PATCH 2/3] Use special vendoring version, force use of vendored rust-secp256k1 dependency --- bitcoin/Cargo.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml index 4f4a6c8b3..0a6b6ccec 100644 --- a/bitcoin/Cargo.toml +++ b/bitcoin/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "bitcoin" -version = "0.32.0-rc1" +# fake version for vendoring +version = "0.99.0" authors = ["Andrew Poelstra "] license = "CC0-1.0" repository = "https://github.com/rust-bitcoin/rust-bitcoin/" @@ -35,7 +36,8 @@ hex = { package = "hex-conservative", version = "0.2.0", default-features = fals hex_lit = "0.1.1" internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] } io = { package = "bitcoin-io", version = "0.1.1", default-features = false, features = ["alloc"] } -secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] } +# ensure the internal version is actually used +secp256k1 = { version = "0.99.0", default-features = false, features = ["hashes", "alloc"] } units = { package = "bitcoin-units", version = "0.1.0", default-features = false, features = ["alloc"] } base64 = { version = "0.21.3", optional = true } From ef150c56fa89bc07e214a7a94c29335e2089cd3e Mon Sep 17 00:00:00 2001 From: Christian Reitter Date: Sat, 27 Apr 2024 14:01:57 +0200 Subject: [PATCH 3/3] Document unsafe and unsupported nature of this fork --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index e30924cb8..9ea1004ff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,15 @@ +# Unsafe Fast Fork +## DO NOT USE THIS LIBRARY + +This is an experimental fork with extreme changes that **intentionally break important security mechanisms and functionality** in favor of speed for certain security research workloads. + +The forked library version is **completely unsuitable for any type of production use** and receives no support or maintenance of any kind. +It is published primarily as a reference for other researchers. You have been warned. + +The original documentation content and other references are kept as-is to limit the repository differences to upstream. However, be aware that none of the contact information, usage guidance or security guarantees still applies since this is a deliberately broken variant of the project. + +---- +

Rust Bitcoin