diff --git a/app/src/crypto.c b/app/src/crypto.c index dc5f13a..ef99a19 100644 --- a/app/src/crypto.c +++ b/app/src/crypto.c @@ -25,8 +25,6 @@ uint32_t hdPath[HDPATH_LEN_DEFAULT]; -// #{TODO} --> Check pubkey and sign methods - zxerr_t crypto_extractPublicKey(uint8_t *pubKey, uint16_t pubKeyLen) { if (pubKey == NULL || pubKeyLen < PUB_KEY_LENGTH) { return zxerr_invalid_crypto_settings; @@ -104,7 +102,7 @@ zxerr_t crypto_sign(uint8_t *signature, uint16_t signatureMaxlen, const uint8_t zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t bufferLen, uint16_t *addrResponseLen) { static uint8_t address[65]; - static uint8_t is_computed = 0; + static uint32_t last_hdPath[HDPATH_LEN_DEFAULT] = {0}; if (buffer == NULL || addrResponseLen == NULL) { return zxerr_out_of_bounds; @@ -118,9 +116,9 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t bufferLen, uint16_t *addrRe *addrResponseLen = 0; - if (!is_computed) { + if (MEMCMP(last_hdPath, hdPath, sizeof(uint32_t) * HDPATH_LEN_DEFAULT) != 0) { CHECK_ZXERR(crypto_extractPublicKey(address, sizeof(address))) - is_computed = 1; + MEMCPY(last_hdPath, hdPath, sizeof(uint32_t) * HDPATH_LEN_DEFAULT); } MEMCPY(buffer, address, PUB_KEY_LENGTH);