refactor(core): exclude THP-related confirmation from `THP=0` builds
What changed, and why it matters
This commit is a build-system cleanup: it wraps a Trezor-Host Protocol (THP) credential confirmation screen so it is only compiled into firmware builds that actually have THP enabled. For non-THP builds, only the simpler non-THP confirmation is kept. There is no direct evidence in the commit that this fixes an active security bug; it appears to be a refactor to avoid including unused THP code in builds where the feature is disabled.
No immediate action required. Treat as routine maintenance. If auditing, verify that `utils.USE_THP` is correctly set for each firmware variant and that the non-THP confirmation still provides adequate user notice for delegated identity key export.
Security signals we found
Conditional compilation excludes unused authentication/confirmation code
No change to validation logic for enabled builds
No changelog entry suggests routine refactor rather than security fix
Evidence from the diff
The change moves confirm_thp() and confirm_no_thp() under an if utils.USE_THP: / else: split. When USE_THP is false, the THP credential decoding/validation path and its UI confirmation are excluded from the build, and only confirm_no_thp() remains. This reduces code size and removes dependencies on THP modules in non-THP firmware variants. The diff does not alter runtime behavior for either build variant; it only changes which variant of the helper is defined at compile time.
Changed components
core/src/apps/evolu/get_delegated_identity_key.pyTrezor Model T / Safe firmware coreTHP (Trezor-Host Protocol) feature flag buildsInspect captured patch +38 / −35
diff --git a/core/src/apps/evolu/get_delegated_identity_key.py b/core/src/apps/evolu/get_delegated_identity_key.py
index 677f56a7..3482ac1b 100644
--- a/core/src/apps/evolu/get_delegated_identity_key.py
+++ b/core/src/apps/evolu/get_delegated_identity_key.py
@@ -56,41 +56,44 @@ async def get_delegated_identity_key(
)
-async def confirm_thp(msg: EvoluGetDelegatedIdentityKey) -> None:
- from trezor import TR
- from trezor.ui.layouts import confirm_action
- from trezor.wire.context import get_channel_context
- from trezor.wire.errors import DataError
-
- from apps.thp.credential_manager import decode_credential, validate_credential
-
- if msg.thp_credential is None:
- raise DataError("THP credential must be provided when THP is enabled")
- credential_received = decode_credential(msg.thp_credential)
- host_static_public_key = (
- get_channel_context().channel_cache.get_host_static_public_key()
- )
- if not validate_credential(credential_received, host_static_public_key):
- raise DataError("Invalid credential")
-
- app_name = credential_received.cred_metadata.app_name
- host_name = credential_received.cred_metadata.host_name
- await confirm_action(
- "suite_sync",
- TR.suite_sync__header,
- TR.suite_sync__delegated_identity_key_thp.format(app_name, host_name),
- )
-
-
-async def confirm_no_thp() -> None:
- from trezor import TR
- from trezor.ui.layouts import confirm_action
-
- await confirm_action(
- "suite_sync",
- TR.suite_sync__header,
- TR.suite_sync__delegated_identity_key_no_thp,
- )
+if utils.USE_THP:
+
+ async def confirm_thp(msg: EvoluGetDelegatedIdentityKey) -> None:
+ from trezor import TR
+ from trezor.ui.layouts import confirm_action
+ from trezor.wire.context import get_channel_context
+ from trezor.wire.errors import DataError
+
+ from apps.thp.credential_manager import decode_credential, validate_credential
+
+ if msg.thp_credential is None:
+ raise DataError("THP credential must be provided when THP is enabled")
+ credential_received = decode_credential(msg.thp_credential)
+ host_static_public_key = (
+ get_channel_context().channel_cache.get_host_static_public_key()
+ )
+ if not validate_credential(credential_received, host_static_public_key):
+ raise DataError("Invalid credential")
+
+ app_name = credential_received.cred_metadata.app_name
+ host_name = credential_received.cred_metadata.host_name
+ await confirm_action(
+ "suite_sync",
+ TR.suite_sync__header,
+ TR.suite_sync__delegated_identity_key_thp.format(app_name, host_name),
+ )
+
+else:
+
+ async def confirm_no_thp() -> None:
+ from trezor import TR
+ from trezor.ui.layouts import confirm_action
+
+ await confirm_action(
+ "suite_sync",
+ TR.suite_sync__header,
+ TR.suite_sync__delegated_identity_key_no_thp,
+ )
def get_rotation_index(msg: EvoluGetDelegatedIdentityKey) -> int | None:
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.