Skip to content

Commit 6a04d69

Browse files
committed
fix: open checking logic
1 parent fa3f10c commit 6a04d69

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

rust/apps/zcash/src/lib.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ pub fn check_pczt<P: consensus::Parameters>(
3636
seed_fingerprint: &[u8; 32],
3737
account_index: u32,
3838
) -> Result<()> {
39-
// let ufvk = UnifiedFullViewingKey::decode(params, ufvk_text)
40-
// .map_err(|e| ZcashError::InvalidDataError(e.to_string()))?;
41-
// let pczt =
42-
// Pczt::parse(pczt).map_err(|_e| ZcashError::InvalidPczt(format!("invalid pczt data")))?;
43-
// let account_index = zip32::AccountId::try_from(account_index)
44-
// .map_err(|_e| ZcashError::InvalidDataError(format!("invalid account index")))?;
45-
// pczt::check::check_pczt(params, seed_fingerprint, account_index, &ufvk, &pczt)
46-
Ok(())
39+
let ufvk = UnifiedFullViewingKey::decode(params, ufvk_text)
40+
.map_err(|e| ZcashError::InvalidDataError(e.to_string()))?;
41+
let pczt =
42+
Pczt::parse(pczt).map_err(|_e| ZcashError::InvalidPczt(format!("invalid pczt data")))?;
43+
let account_index = zip32::AccountId::try_from(account_index)
44+
.map_err(|_e| ZcashError::InvalidDataError(format!("invalid account index")))?;
45+
pczt::check::check_pczt(params, seed_fingerprint, account_index, &ufvk, &pczt)
4746
}
4847

4948
pub fn parse_pczt<P: consensus::Parameters>(

src/managers/account_manager.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static uint8_t g_lastAccountIndex = ACCOUNT_INDEX_LOGOUT;
3333
static AccountInfo_t g_currentAccountInfo = {0};
3434
static PublicInfo_t g_publicInfo = {0};
3535
static ZcashUFVKCache_t g_zcashUFVKcache = {0};
36+
static void ClearZcashUFVK();
3637

3738
/// @brief Get current account info from SE, and copy info to g_currentAccountInfo.
3839
/// @return err code.
@@ -226,6 +227,7 @@ int32_t VerifyPasswordAndLogin(uint8_t *accountIndex, const char *password)
226227
ret = ReadCurrentAccountInfo();
227228
g_publicInfo.loginPasswordErrorCount = 0;
228229
g_publicInfo.currentPasswordErrorCount = 0;
230+
ClearZcashUFVK();
229231
if (PassphraseExist(g_currentAccountIndex)) {
230232
//passphrase exist.
231233
printf("passphrase exist\r\n");
@@ -561,14 +563,18 @@ int32_t CreateNewTonAccount(uint8_t accountIndex, const char *mnemonic, const ch
561563
static void SetZcashUFVK(uint8_t accountIndex, const char* ufvk, const uint8_t* seedFingerprint) {
562564
ASSERT(accountIndex <= 2);
563565
g_zcashUFVKcache.accountIndex = accountIndex;
564-
memset_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, '\0', ZCASH_UFVK_MAX_LEN);
566+
ClearZcashUFVK();
565567
strcpy_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, ufvk);
566568

567-
memset_s(g_zcashUFVKcache.seedFingerprint, 32, 0, 32);
568569
memcpy_s(g_zcashUFVKcache.seedFingerprint, 32, seedFingerprint, 32);
569570
printf("SetZcashUFVK, %s\r\n", g_zcashUFVKcache.ufvkCache);
570571
}
571572

573+
static void ClearZcashUFVK() {
574+
memset_s(g_zcashUFVKcache.ufvkCache, ZCASH_UFVK_MAX_LEN, '\0', ZCASH_UFVK_MAX_LEN);
575+
memset_s(g_zcashUFVKcache.seedFingerprint, 32, 0, 32);
576+
}
577+
572578
int32_t GetZcashUFVK(uint8_t accountIndex, char* outUFVK, uint8_t* outSFP) {
573579
ASSERT(accountIndex <= 2);
574580
if (g_zcashUFVKcache.accountIndex == accountIndex)

0 commit comments

Comments
 (0)