Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pk calc #10

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Loading