fix: slip39 passphrase create failed issue
What changed, and why it matters
This commit fixes a build-configuration bug that could prevent creating or saving public key information when using a SLIP39 passphrase. The old code accidentally skipped the normal key-derivation path for certain crypto types in non-Bitcoin-only builds, which could leave required public key data unset and cause account setup to fail. The patch restructures the conditional compilation so each build variant (Cypherpunk, Web3, Bitcoin-only) follows the correct derivation branch.
Treat as a functional/availability fix rather than a confirmed exploitable vulnerability. Reviewers should verify that all build configurations (BTC_ONLY, WEB3_VERSION, CYPHERPUNK_VERSION, and combinations thereof) now derive every required public key type and that no path leaves xPubResult uninitialized. Regression tests for SLIP39 passphrase account creation and for each supported build variant should be added or confirmed.
Security signals we found
Conditional compilation (#ifdef) restructure around cryptographic key derivation
SLIP39 passphrase creation failure addressed
Cardano BIP32-ED25519 key derivation path corrected
Zcash UFVK encryption isolated under CYPHERPUNK_VERSION flag
Potential for missing/uninitialized public key data in account setup
Evidence from the diff
In AccountPublicSavePublicInfo and TempAccountPublicInfo, the previous guard #ifndef BTC_ONLY wrapped both the Zcash UFVK encryption block and the Cardano SLIP39 branch. When BTC_ONLY was not defined, the code entered the Zcash branch and only fell through to ProcessKeyType if no earlier condition matched. The Cardano SLIP39 branch was nested inside the same #ifndef BTC_ONLY block but guarded by #ifdef WEB3_VERSION, which meant its relationship with the Zcash branch was fragile. The patch replaces the outer guard with #ifdef CYPHERPUNK_VERSION for the Zcash block, then adds a separate #ifdef WEB3_VERSION block for the Cardano SLIP39 handling, with each block explicitly calling ProcessKeyType in its else branch. This ensures SLIP39 Cardano keys and other key types are derived regardless of which feature flags are enabled.
Changed components
src/crypto/account_public_info.cAccountPublicSavePublicInfo functionTempAccountPublicInfo functionSLIP39 passphrase account creation flowCardano (BIP32_ED25519) key derivationZcash UFVK encryption (CYPHERPUNK_VERSION builds)Inspect captured patch +9 / −7
diff --git a/src/crypto/account_public_info.c b/src/crypto/account_public_info.c
index 8aabcaf..026167b 100644
--- a/src/crypto/account_public_info.c
+++ b/src/crypto/account_public_info.c
@@ -920,7 +920,7 @@ int32_t AccountPublicSavePublicInfo(uint8_t accountIndex, const char *password,
if (g_chainTable[i].cryptoKey == TON_CHECKSUM || g_chainTable[i].cryptoKey == TON_NATIVE) {
continue;
}
-#ifndef BTC_ONLY
+#ifdef CYPHERPUNK_VERSION
//encrypt zcash ufvk
if (g_chainTable[i].cryptoKey == ZCASH_UFVK_ENCRYPTED) {
char* zcashUfvk = NULL;
@@ -934,12 +934,14 @@ int32_t AccountPublicSavePublicInfo(uint8_t accountIndex, const char *password,
memcpy_s(iv_bytes, 16, iv_response->data, 16);
free_simple_response_u8(iv_response);
xPubResult = rust_aes256_cbc_encrypt(zcashUfvk, password, iv_bytes, 16);
-#ifdef WEB3_VERSION
- } else if (g_chainTable[i].cryptoKey == BIP32_ED25519 && isSlip39) {
- xPubResult = cardano_get_pubkey_by_slip23(seed, seedLen, g_chainTable[i].path);
-#endif
+ } else {
+ xPubResult = ProcessKeyType(seed, seedLen, g_chainTable[i].cryptoKey, g_chainTable[i].path, icarusMasterKey, ledgerBitbox02Key);
}
- else {
+#endif
+#ifdef WEB3_VERSION
+ if (g_chainTable[i].cryptoKey == BIP32_ED25519 && isSlip39) {
+ xPubResult = cardano_get_pubkey_by_slip23(seed, seedLen, g_chainTable[i].path);
+ } else {
xPubResult = ProcessKeyType(seed, seedLen, g_chainTable[i].cryptoKey, g_chainTable[i].path, icarusMasterKey, ledgerBitbox02Key);
}
#endif
@@ -1085,7 +1087,7 @@ int32_t TempAccountPublicInfo(uint8_t accountIndex, const char *password, bool s
if (g_chainTable[i].cryptoKey == TON_CHECKSUM || g_chainTable[i].cryptoKey == TON_NATIVE) {
continue;
}
-#ifndef BTC_ONLY
+#ifdef CYPHERPUNK_VERSION
//encrypt zcash ufvk
if (g_chainTable[i].cryptoKey == ZCASH_UFVK_ENCRYPTED) {
char* zcashUfvk = NULL;
Why this scored 32/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.