Skip to content

Commit

Permalink
Lint, and remove unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Feb 23, 2024
1 parent e977266 commit 1d46674
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
28 changes: 7 additions & 21 deletions src/common/merkle.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,16 @@

#include "merkle.h"

#include "cx_ram.h"
#include "debug-helpers/debug.h"

#include "ledger_assert.h"

void merkle_compute_element_hash(const uint8_t *in, size_t in_len, uint8_t out[static CX_SHA256_SIZE]) {
void merkle_compute_element_hash(const uint8_t *in,
size_t in_len,
uint8_t out[static CX_SHA256_SIZE]) {
// H(0x00 | in)
uint8_t data = 0x00;
cx_iovec_t iovec[2] = {
{
.iov_base = &data, .iov_len = 1
},
{
.iov_base = in, .iov_len = in_len
}
};
cx_iovec_t iovec[2] = {{.iov_base = &data, .iov_len = 1}, {.iov_base = in, .iov_len = in_len}};
cx_sha256_hash_iovec(iovec, 2, out);
}

Expand All @@ -49,17 +43,9 @@ void merkle_combine_hashes(const uint8_t left[static CX_SHA256_SIZE],
PRINT_STACK_POINTER();

uint8_t prefix = 0x01;
cx_iovec_t iovec[3] = {
{
.iov_base = &prefix, .iov_len = 1
},
{
.iov_base = left, .iov_len = CX_SHA256_SIZE
},
{
.iov_base = right, .iov_len = CX_SHA256_SIZE
}
};
cx_iovec_t iovec[3] = {{.iov_base = &prefix, .iov_len = 1},
{.iov_base = left, .iov_len = CX_SHA256_SIZE},
{.iov_base = right, .iov_len = CX_SHA256_SIZE}};
cx_sha256_hash_iovec(iovec, 3, out);
}

Expand Down
18 changes: 4 additions & 14 deletions src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,20 +466,10 @@ static void crypto_tr_tagged_hash(const uint8_t *tag,
// First compute hashtag, reuse out buffer for that
cx_sha256_hash(tag, tag_len, out);

cx_iovec_t iovec[4] = {
{
.iov_base = out, .iov_len = CX_SHA256_SIZE
},
{
.iov_base = out, .iov_len = CX_SHA256_SIZE
},
{
.iov_base = data, .iov_len = data_len
},
{
.iov_base = data2, .iov_len = data2_len
}
};
cx_iovec_t iovec[4] = {{.iov_base = out, .iov_len = CX_SHA256_SIZE},
{.iov_base = out, .iov_len = CX_SHA256_SIZE},
{.iov_base = data, .iov_len = data_len},
{.iov_base = data2, .iov_len = data2_len}};
if (data2_len > 0) {
cx_sha256_hash_iovec(iovec, 4, out);
} else {
Expand Down

0 comments on commit 1d46674

Please sign in to comment.