bip32: split generic wrapper for Xpriv::new_master
What changed, and why it matters
This is a small internal code cleanup in a Bitcoin library. It splits one function into two so the inner logic doesn't have to be repeated, but the public behavior is unchanged. There is no security issue visible in the change.
No action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors Xpriv::new_master in rust-bitcoin’s bip32 module. It keeps the public generic signature (impl Into
Changed components
key_expression/src/bip32.rsXpriv::new_masterInspect captured patch +6 / −2
diff --git a/key_expression/src/bip32.rs b/key_expression/src/bip32.rs
index 5ad10892..fd840bdc 100644
--- a/key_expression/src/bip32.rs
+++ b/key_expression/src/bip32.rs
@@ -655,12 +655,16 @@ impl Xpriv {
/// Constructs a new master key from a [`Bip32Seed`].
#[allow(clippy::missing_panics_doc)]
pub fn new_master(network: impl Into<NetworkKind>, seed: impl AsRef<Bip32Seed>) -> Self {
+ Self::new_master_inner(network.into(), seed.as_ref())
+ }
+
+ fn new_master_inner(network: NetworkKind, seed: &Bip32Seed) -> Self {
let mut engine = HmacEngine::<sha512::HashEngine>::new(b"Bitcoin seed");
- engine.input(seed.as_ref().as_bytes());
+ engine.input(seed.as_bytes());
let hmac = engine.finalize();
Self {
- network: network.into(),
+ network,
depth: 0,
parent_fingerprint: Fingerprint::default(),
child_number: ChildNumber::ZERO_NORMAL,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.