keystore: improve documentation of seed entropy sources
What changed, and why it matters
This commit only adds and updates comments in the code to better explain where the randomness used to create wallet seeds comes from. It does not change any actual behavior, logic, or security properties of the firmware.
No action needed; this is a non-functional documentation improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is purely documentation: it adds inline comments in random.rs describing the entropy sources (MCU TRNG, secure chip TRNG, factory randomness) and updates the docstring for create_and_store_seed in keystore.rs to note that the seed is also mixed with password_salted_hashed. No code paths, algorithms, or data flows were modified.
Changed components
src/rust/bitbox-core-utils/src/random.rssrc/rust/bitbox02-rust/src/keystore.rsInspect captured patch +9 / −3
### src/rust/bitbox-core-utils/src/random.rs
@@ -13,10 +13,12 @@ pub fn random_32_bytes_with_mixin(
let mut mixed = zeroize::Zeroizing::new([0u8; 32]);
hal_random.mcu_32_bytes(&mut mixed);
+ // Mix MCU TRNG entropy with secure chip TRNG entropy.
for (byte, mixin_byte) in mixed.iter_mut().zip(mixin.iter()) {
*byte ^= *mixin_byte;
}
+ // Mix in factory randomness.
let factory_randomness = hal_random.factory_randomness();
for (byte, factory_randomness_byte) in mixed.iter_mut().zip(factory_randomness.iter()) {
*byte ^= *factory_randomness_byte;
### src/rust/bitbox02-rust/src/keystore.rs
@@ -570,9 +570,9 @@ pub async fn copy_bip39_seed(
.map_err(|_| ())
}
-/// Generates the seed, mixes it with host_entropy, and stores it encrypted with the
-/// password. The size of the host entropy determines the size of the seed. Can be either 16 or 32
-/// bytes, resulting in 12 or 24 BIP39 recovery words.
+/// Generates the seed, mixes it with host_entropy and password_salted_hashed, and stores it
+/// encrypted with the password. The size of the host entropy determines the size of the seed.
+/// Can be either 16 or 32 bytes, resulting in 12 or 24 BIP39 recovery words.
/// This also unlocks the keystore with the new seed.
pub async fn create_and_store_seed(
hal: &mut impl crate::hal::Hal,
@@ -584,6 +584,10 @@ pub async fn create_and_store_seed(
return Err(Error::SeedSize);
}
+ // Generate seed which already includes:
+ // * Entropy from the secure chip TRNG.
+ // * Entropy from the MCU TRNG.
+ // * Entropy set during factory installation.
let mut seed_vec = bitbox_core_utils::random::random_32_bytes_from_hal(hal).await?;
let seed = &mut seed_vec[..seed_len];
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.