Skip to content

Commit

Permalink
use ripemd160 oneshot and update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
chcmedeiros committed Feb 22, 2024
1 parent 284d6d7 commit 9ea1217
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ endif

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.platform

DEFINES += HAVE_SHA3 HAVE_HASH HAVE_BLAKE2 HAVE_SHA256 HAVE_SHA512
APP_SOURCE_PATH += $(MY_DIR)/../deps/jsmn/src

.PHONY: rust
Expand Down
9 changes: 1 addition & 8 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@ zxerr_t crypto_sign(uint8_t *output,
return error;
}

static zxerr_t ripemd160_32(uint8_t *out, uint8_t *in) {
cx_ripemd160_t rip160;
CHECK_CX_OK(cx_ripemd160_init_no_throw(&rip160));
CHECK_CX_OK(cx_hash_no_throw(&rip160.header, CX_LAST, in, CX_SHA256_SIZE, out, CX_RIPEMD160_SIZE));
return zxerr_ok;
}

zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrResponseLen) {
if (buffer_len < PK_LEN_SECP256K1 + 50) {
return zxerr_buffer_too_small;
Expand All @@ -188,7 +181,7 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR
// Hash it
cx_hash_sha256(buffer, PK_LEN_SECP256K1, hashed1_pk, CX_SHA256_SIZE);
uint8_t hashed2_pk[CX_RIPEMD160_SIZE] = {0};
CHECK_ZXERR(ripemd160_32(hashed2_pk, hashed1_pk));
CHECK_CX_OK(cx_ripemd160_hash(hashed1_pk, CX_SHA256_SIZE, hashed2_pk));
CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed2_pk, CX_RIPEMD160_SIZE, 1, BECH32_ENCODING_BECH32));
break;
}
Expand Down

0 comments on commit 9ea1217

Please sign in to comment.