diff --git a/rust/apps/zcash/src/lib.rs b/rust/apps/zcash/src/lib.rs index 9e19b927b..3859cb402 100644 --- a/rust/apps/zcash/src/lib.rs +++ b/rust/apps/zcash/src/lib.rs @@ -36,14 +36,13 @@ pub fn check_pczt( seed_fingerprint: &[u8; 32], account_index: u32, ) -> Result<()> { - // let ufvk = UnifiedFullViewingKey::decode(params, ufvk_text) - // .map_err(|e| ZcashError::InvalidDataError(e.to_string()))?; - // let pczt = - // Pczt::parse(pczt).map_err(|_e| ZcashError::InvalidPczt(format!("invalid pczt data")))?; - // let account_index = zip32::AccountId::try_from(account_index) - // .map_err(|_e| ZcashError::InvalidDataError(format!("invalid account index")))?; - // pczt::check::check_pczt(params, seed_fingerprint, account_index, &ufvk, &pczt) - Ok(()) + let ufvk = UnifiedFullViewingKey::decode(params, ufvk_text) + .map_err(|e| ZcashError::InvalidDataError(e.to_string()))?; + let pczt = + Pczt::parse(pczt).map_err(|_e| ZcashError::InvalidPczt(format!("invalid pczt data")))?; + let account_index = zip32::AccountId::try_from(account_index) + .map_err(|_e| ZcashError::InvalidDataError(format!("invalid account index")))?; + pczt::check::check_pczt(params, seed_fingerprint, account_index, &ufvk, &pczt) } pub fn parse_pczt( diff --git a/src/managers/account_manager.c b/src/managers/account_manager.c index 8e42faa16..bd739bf78 100644 --- a/src/managers/account_manager.c +++ b/src/managers/account_manager.c @@ -33,6 +33,7 @@ static uint8_t g_lastAccountIndex = ACCOUNT_INDEX_LOGOUT; static AccountInfo_t g_currentAccountInfo = {0}; static PublicInfo_t g_publicInfo = {0}; static ZcashUFVKCache_t g_zcashUFVKcache = {0}; +static void ClearZcashUFVK(); /// @brief Get current account info from SE, and copy info to g_currentAccountInfo. /// @return err code. @@ -226,6 +227,7 @@ int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password) ret = ReadCurrentAccountInfo(); g_publicInfo.loginPasswordErrorCount = 0; g_publicInfo.currentPasswordErrorCount = 0; + ClearZcashUFVK(); if (PassphraseExist(g_currentAccountIndex)) { //passphrase exist. printf("passphrase exist\r\n"); @@ -561,14 +563,18 @@ int32_t CreateNewTonAccount(uint8_t accountIndex, const char *mnemonic, const ch static void SetZcashUFVK(uint8_t accountIndex, const char* ufvk, const uint8_t* seedFingerprint) { ASSERT(accountIndex <= 2); g_zcashUFVKcache.accountIndex = accountIndex; - memset_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, '\0', ZCASH_UFVK_MAX_LEN); + ClearZcashUFVK(); strcpy_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, ufvk); - memset_s(g_zcashUFVKcache.seedFingerprint, 32, 0, 32); memcpy_s(g_zcashUFVKcache.seedFingerprint, 32, seedFingerprint, 32); printf("SetZcashUFVK, %s\r\n", g_zcashUFVKcache.ufvkCache); } +static void ClearZcashUFVK() { + memset_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, '\0', ZCASH_UFVK_MAX_LEN); + memset_s(g_zcashUFVKcache.seedFingerprint, 32, 0, 32); +} + int32_t GetZcashUFVK(uint8_t accountIndex, char* outUFVK, uint8_t* outSFP) { ASSERT(accountIndex <= 2); if (g_zcashUFVKcache.accountIndex == accountIndex)