What changed, and why it matters
This commit fixes the firmware's build for a software simulator. It removes an unused public-key derivation step in Bitcoin PSBT handling, relaxes a hardware-only flash-read assertion when compiling the simulator, and adds a simulator-only header. There is no clear security fix for real hardware; the changes are build-compatibility adjustments.
No immediate security action is required. Treat as a routine build fix. If reviewing for security, verify that the removed public-key derivation in wrapped_psbt.rs was genuinely unused and that the real-hardware ASSERT in rsa.c remains active for production firmware builds.
Security signals we found
Removal of public-key derivation code in Bitcoin PSBT path
Assertion on RSA prime flash read length disabled for simulator build
Conditional simulator-only header inclusion
Evidence from the diff
The patch makes three build-related changes: (1) In wrapped_psbt.rs it removes a dead/unused derive_public_key_by_path call and its error handling, likely because the simulator lacks the underlying crypto path derivation or because the value was never used. (2) In rsa.c it guards an ASSERT that the RSA prime flash read returned the expected length with #ifndef COMPILE_SIMULATOR, so the simulator build does not abort when flash emulation behaves differently. (3) In gui_chain.c it includes simulator_model.h only under COMPILE_SIMULATOR. The commit title and message are purely ‘fix: simulator build’.
Changed components
rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rssrc/crypto/rsa.csrc/ui/gui_chain/gui_chain.cInspect captured patch +7 / −13
diff --git a/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs b/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
index d25a9e0..771d475 100644
--- a/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
+++ b/rust/apps/bitcoin/src/transactions/psbt/wrapped_psbt.rs
@@ -909,18 +909,6 @@ impl WrappedPsbt {
)));
}
};
- let public_key = match derive_public_key_by_path(
- xpub,
- parent_path,
- &_child_path,
- ) {
- Ok(pk) => pk,
- Err(_) => {
- return Err(BitcoinError::InvalidTransaction(format!(
- "invalid {purpose} #{index}, cannot derive associated public key"
- )));
- }
- };
return Ok(Some((
child.to_uppercase(),
Self::judge_external_key(child, parent_path.to_string()),
diff --git a/src/crypto/rsa.c b/src/crypto/rsa.c
index c9ca81d..06afc82 100644
--- a/src/crypto/rsa.c
+++ b/src/crypto/rsa.c
@@ -61,7 +61,10 @@ Rsa_primes_t *FlashReadRsaPrimes(void)
do {
primes = SRAM_MALLOC(sizeof(Rsa_primes_t));
- ASSERT(Gd25FlashReadBuffer(GetRsaAddress(), fullData, sizeof(fullData)) == sizeof(fullData));
+ int readLen = Gd25FlashReadBuffer(GetRsaAddress(), fullData, sizeof(fullData));
+#ifndef COMPILE_SIMULATOR
+ ASSERT(readLen == sizeof(fullData));
+#endif
int len = (GetMnemonicType() == MNEMONIC_TYPE_BIP39) ? (int)sizeof(seed) : GetCurrentAccountEntropyLen();
if (SecretCacheGetPassword() == NULL) {
diff --git a/src/ui/gui_chain/gui_chain.c b/src/ui/gui_chain/gui_chain.c
index 1bdb29d..0194bd3 100644
--- a/src/ui/gui_chain/gui_chain.c
+++ b/src/ui/gui_chain/gui_chain.c
@@ -2,6 +2,9 @@
#include "gui_chain.h"
#include "keystore.h"
#include "user_memory.h"
+#ifdef COMPILE_SIMULATOR
+#include "simulator_model.h"
+#endif
typedef TransactionCheckResult *(*CheckUrResultHandler)(void);
Why this scored 18/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.