Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Jun 19, 2024
1 parent a2462ce commit 39640cc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
sudo apt-get install -y curl protobuf-compiler build-essential git wget unzip python3 python3-pip \
libssl-dev libffi-dev libreadline-dev zlib1g-dev libbz2-dev libsqlite3-dev libncurses5-dev \
libgdbm-dev libnss3-dev liblzma-dev libxml2-dev libxmlsec1-dev libffi-dev libyaml-dev
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Checkout
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -140,7 +144,7 @@ jobs:
- name: Build NanoS
shell: bash -l {0}
run: |
make
PRODUCTION_BUILD=0 make
mv ./app/pkg/installer_s.sh ./app/pkg/installer_nanos.sh
- name: Set tag
id: nanos
Expand Down Expand Up @@ -176,7 +180,7 @@ jobs:
- name: Build NanoSP
shell: bash -l {0}
run: |
make
PRODUCTION_BUILD=0 make
mv ./app/pkg/installer_s2.sh ./app/pkg/installer_nanos_plus.sh
- name: Set tag
id: nanosp
Expand Down Expand Up @@ -212,7 +216,7 @@ jobs:
- name: Build Stax
shell: bash -l {0}
run: |
make
PRODUCTION_BUILD=0 make
- name: Set tag
id: stax
run: echo "tag_name=$(./app/pkg/installer_stax.sh version)" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ default:
endif

test_all:
PRODUCTION_BUILD=1 make
make
make zemu_install
make zemu_test
9 changes: 1 addition & 8 deletions app/src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@
#include "cx.h"
#include "cx_blake2b.h"
#include "keys_def.h"
#include "rslib.h"
#include "zxformat.h"
#include "zxmacros.h"

uint32_t hdPath[HDPATH_LEN_DEFAULT];

#define CHECK_PARSER_OK(CALL) \
do { \
cx_err_t __cx_err = CALL; \
if (__cx_err != parser_ok) { \
return zxerr_unknown; \
} \
} while (0)

static zxerr_t computeKeys(keys_t *saplingKeys) {
if (saplingKeys == NULL) {
return zxerr_no_data;
Expand Down
10 changes: 5 additions & 5 deletions app/src/crypto_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ parser_error_t transaction_signature_hash(parser_tx_t *txObj, uint8_t output[HAS
ASSERT_CX_OK(cx_blake2b_init2_no_throw(&ctx, 256, NULL, 0, personalization, sizeof(personalization)));
ASSERT_CX_OK(cx_blake2b_update(&ctx, &TXN_SIGNATURE_VERSION, 1));
ASSERT_CX_OK(cx_blake2b_update(&ctx, &txObj->transactionVersion, 1));
ASSERT_CX_OK(cx_blake2b_update(&ctx, &txObj->expiration, 4));
ASSERT_CX_OK(cx_blake2b_update(&ctx, &txObj->fee, 8));
ASSERT_CX_OK(cx_blake2b_update(&ctx, (const uint8_t *)&txObj->expiration, 4));
ASSERT_CX_OK(cx_blake2b_update(&ctx, (const uint8_t *)&txObj->fee, 8));
ASSERT_CX_OK(cx_blake2b_update(&ctx, txObj->randomizedPublicKey.ptr, txObj->randomizedPublicKey.len));
#else
blake2b_state state = {0};
Expand All @@ -107,7 +107,7 @@ parser_error_t transaction_signature_hash(parser_tx_t *txObj, uint8_t output[HAS
// Spends
const uint16_t SPENDLEN = 32 + 192 + 32 + 32 + 4 + 32 + 64;
for (uint64_t i = 0; i < txObj->spends.elements; i++) {
uint8_t *spend_i = txObj->spends.data.ptr + (SPENDLEN * i) + (32 * (i + 1));
const uint8_t *spend_i = txObj->spends.data.ptr + (SPENDLEN * i) + (32 * (i + 1));
// Don't hash neither public_key_randomness(32) nor binding_signature(64)
#if defined(LEDGER_SPECIFIC)
ASSERT_CX_OK(cx_blake2b_update(&ctx, spend_i, SPENDLEN - (32 + 64)));
Expand All @@ -119,7 +119,7 @@ parser_error_t transaction_signature_hash(parser_tx_t *txObj, uint8_t output[HAS
// Outputs
const uint16_t OUTPUTLEN = 192 + 328;
for (uint64_t i = 0; i < txObj->outputs.elements; i++) {
uint8_t *output_i = txObj->outputs.data.ptr + (OUTPUTLEN * i);
const uint8_t *output_i = txObj->outputs.data.ptr + (OUTPUTLEN * i);
#if defined(LEDGER_SPECIFIC)
ASSERT_CX_OK(cx_blake2b_update(&ctx, output_i, OUTPUTLEN));
#else
Expand Down Expand Up @@ -149,7 +149,7 @@ parser_error_t transaction_signature_hash(parser_tx_t *txObj, uint8_t output[HAS
// Burns
const uint16_t BURNLEN = 32 + 8;
for (uint64_t i = 0; i < txObj->burns.elements; i++) {
uint8_t *burn_i = txObj->burns.data.ptr + (BURNLEN * i);
const uint8_t *burn_i = txObj->burns.data.ptr + (BURNLEN * i);
#if defined(LEDGER_SPECIFIC)
ASSERT_CX_OK(cx_blake2b_update(&ctx, burn_i, BURNLEN));
#else
Expand Down
4 changes: 2 additions & 2 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ parser_error_t parser_getItem(const parser_context_t *ctx, uint8_t displayIdx, c
return parser_ok;
case 4: {
snprintf(outKey, outKeyLen, "TxnHash");
pageStringHex(outVal, outValLen, ctx->tx_obj->transactionHash, sizeof(ctx->tx_obj->transactionHash), pageIdx,
pageCount);
pageStringHex(outVal, outValLen, (const char *)ctx->tx_obj->transactionHash,
sizeof(ctx->tx_obj->transactionHash), pageIdx, pageCount);
return parser_ok;
}
default:
Expand Down
10 changes: 5 additions & 5 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static parser_error_t readSpends(parser_context_t *ctx, vec_spend_description_t
const uint16_t SPENDLEN = 32 + 192 + 32 + 32 + 4 + 32 + 64;
spends->data.ptr = ctx->buffer + ctx->offset;
spends->data.len = 0;
uint8_t *tmpPtr = NULL;
const uint8_t *tmpPtr = NULL;
for (uint64_t i = 0; i < spends->elements; i++) {
CHECK_ERROR(readBytes(ctx, &tmpPtr, SPENDLEN));
spends->data.len += SPENDLEN;
Expand All @@ -60,7 +60,7 @@ static parser_error_t readOutputs(parser_context_t *ctx, vec_output_description_
const uint16_t OUTPUTLEN = 192 + 328;
outputs->data.ptr = ctx->buffer + ctx->offset;
outputs->data.len = 0;
uint8_t *tmpPtr = NULL;
const uint8_t *tmpPtr = NULL;
for (uint64_t i = 0; i < outputs->elements; i++) {
CHECK_ERROR(readBytes(ctx, &tmpPtr, OUTPUTLEN));
outputs->data.len += OUTPUTLEN;
Expand All @@ -77,7 +77,7 @@ static parser_error_t readMints(parser_context_t *ctx, vec_mint_description_t *m
const uint16_t MINTLEN = 32 + 192 + 193 + 8;
mints->data.ptr = ctx->buffer + ctx->offset;
mints->data.len = 0;
uint8_t *tmpPtr = NULL;
const uint8_t *tmpPtr = NULL;
for (uint64_t i = 0; i < mints->elements; i++) {
CTX_CHECK_AVAIL(ctx, (MINTLEN + 1));
const uint8_t transferOwnershipToLen = mints->data.ptr[MINTLEN] == 1 ? 33 : 1;
Expand All @@ -95,7 +95,7 @@ static parser_error_t readBurns(parser_context_t *ctx, vec_burn_description_t *b
const uint16_t BURNLEN = 32 + 8;
burns->data.ptr = ctx->buffer + ctx->offset;
burns->data.len = 0;
uint8_t *tmpPtr = NULL;
const uint8_t *tmpPtr = NULL;
for (uint64_t i = 0; i < burns->elements; i++) {
CHECK_ERROR(readBytes(ctx, &tmpPtr, BURNLEN));
burns->data.len += BURNLEN;
Expand All @@ -104,7 +104,7 @@ static parser_error_t readBurns(parser_context_t *ctx, vec_burn_description_t *b
}

parser_error_t _read(parser_context_t *ctx, parser_tx_t *v) {
CHECK_ERROR(readTransactionVersion(ctx, v));
CHECK_ERROR(readTransactionVersion(ctx, &v->transactionVersion));
CHECK_ERROR(readUint64(ctx, &v->spends.elements));
CHECK_ERROR(readUint64(ctx, &v->outputs.elements));
CHECK_ERROR(readUint64(ctx, &v->mints.elements));
Expand Down
4 changes: 2 additions & 2 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
******************************************************************************* */

import Zemu, { ButtonKind, zondaxMainmenuNavigation } from '@zondax/zemu'
import { PATH, defaultOptions, expectedKeys, models, spend_1_output_1, spend_1_output_4_mint_1_burn_1, txBlobExample } from './common'
import { PATH, defaultOptions, expectedKeys, models, spend_1_output_1, spend_1_output_4_mint_1_burn_1 } from './common'
import IronfishApp, { IronfishKeys, ResponseAddress, ResponseProofGenKey, ResponseViewKey } from '@zondax/ledger-ironfish'

jest.setTimeout(20000)
Expand Down Expand Up @@ -197,7 +197,7 @@ describe('Standard', function () {
}
})

test.only.each(models)('blind-signing2', async function (m) {
test.concurrent.each(models)('blind-signing2', async function (m) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
Expand Down

0 comments on commit 39640cc

Please sign in to comment.