Skip to content

Commit

Permalink
check return error
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Dec 7, 2023
1 parent 2e623f8 commit 6dcdbbc
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 100 deletions.
10 changes: 7 additions & 3 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,17 @@ void handleTest(volatile uint32_t *tx) {

jubjub_extendedpoint p;
jubjub_fq scal;
jubjub_field_frombytes(scal, scalar);
if (jubjub_field_frombytes(scal, scalar) != zxerr_ok) {
*tx = 0;
MEMZERO(point, sizeof(point));
THROW(APDU_CODE_OK);
}

jubjub_extendedpoint_tobytes(point, JUBJUB_GEN);
zxerr_t err = jubjub_extendedpoint_frombytes(&p, point);
const zxerr_t err = jubjub_extendedpoint_frombytes(&p, point);
if (err != zxerr_ok) {
*tx = 0;
MEMZERO(point, 32);
MEMZERO(point, sizeof(point));
THROW(APDU_CODE_OK);
}
// MEMCPY(&p, &JUBJUB_GEN, 32);
Expand Down
9 changes: 4 additions & 5 deletions app/src/c_api/rust.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ void c_jubjub_scalarmult(uint8_t *point, const uint8_t *scalar) {
MEMCPY(scal, scalar, JUBJUB_FIELD_BYTES);
SWAP_ENDIAN_BYTES(scal);

zxerr_t err = jubjub_extendedpoint_frombytes(&p, point);
if (err != zxerr_ok) {
if (jubjub_extendedpoint_frombytes(&p, point) != zxerr_ok ||
jubjub_extendedpoint_scalarmult(&p, scal) != zxerr_ok ||
jubjub_extendedpoint_tobytes(point, p) != zxerr_ok) {

MEMZERO(point, JUBJUB_FIELD_BYTES);
return;
}
jubjub_extendedpoint_scalarmult(&p, scal);
jubjub_extendedpoint_tobytes(point, p);
}

void c_jubjub_spending_base_scalarmult(uint8_t *point, const uint8_t *scalar) {
Expand Down
Loading

0 comments on commit 6dcdbbc

Please sign in to comment.