Skip to content

Commit

Permalink
fix: open checking logic
Browse files Browse the repository at this point in the history
  • Loading branch information
soralit committed Dec 18, 2024
1 parent fa3f10c commit 6a04d69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 7 additions & 8 deletions rust/apps/zcash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ pub fn check_pczt<P: consensus::Parameters>(
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<P: consensus::Parameters>(
Expand Down
10 changes: 8 additions & 2 deletions src/managers/account_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6a04d69

Please sign in to comment.