Skip to content

Commit

Permalink
Merge pull request #222 from Zondax/carlosala-stax
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala committed Apr 19, 2024
2 parents 1a04347 + ad7336d commit b8778d7
Show file tree
Hide file tree
Showing 807 changed files with 1,228 additions and 1,106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Analyse
strategy:
matrix:
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK"]
sdk: ["$NANOS_SDK", "$NANOX_SDK", "$NANOSP_SDK", "$STAX_SDK"]
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder-legacy:latest
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ jobs:
cd ./app/rust
cargo clippy --version
cargo clippy --all-features --all-targets || true
# - name: audit
# run: |
# cd ./app/rust
# cargo audit --version
# cargo audit
# - name: audit
# run: |
# cd ./app/rust
# cargo audit --version
# cargo audit
- name: run tests
run: |
cd ./app/rust
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
- run: |
echo "LNS app size: ${{needs.build_ledger.outputs.size}} KiB"
[ ${{needs.build_ledger.outputs.size}} -le $NANOS_LIMIT_SIZE ]
build_ledger_val:
needs: configure
runs-on: ubuntu-latest
Expand Down Expand Up @@ -294,7 +294,7 @@ jobs:
COIN=val make zemu_test
build_package_nanos:
needs: [ configure, build, build_ledger, test_zemu ]
needs: [configure, build, build_ledger, test_zemu]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:
prerelease: false

build_package_nanos_plus:
needs: [ configure, build, build_ledger, test_zemu ]
needs: [configure, build, build_ledger, test_zemu]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -370,14 +370,14 @@ jobs:
prerelease: false

build_package_validator:
needs: [ configure, build, build_ledger_val, test_zemu_val ]
needs: [configure, build, build_ledger_val, test_zemu_val]
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
container:
image: zondax/ledger-app-builder:latest
options: --user ${{ needs.configure.outputs.uid_gid }}
env:
BOLOS_SDK: /opt/nanosplus-secure-sdk
BOLOS_SDK: /opt/nanos-secure-sdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -394,10 +394,10 @@ jobs:
- name: Set tag
id: nanos_val
run: echo ::set-output name=tag_name::$(./app/pkg/installer_nanos_validator.sh version)
run: echo "tag_name=$(./app/pkg/installer_nanos_validator.sh version)" >> $GITHUB_OUTPUT

- name: Update Release
id: create_release_1
- name: Create Release
id: create_release_0
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "deps/picohash"]
path = deps/picohash
url = https://github.com/kazuho/picohash
[submodule "deps/stax-secure-sdk"]
path = deps/stax-secure-sdk
url = https://github.com/LedgerHQ/ledger-secure-sdk.git
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TESTS_JS_PACKAGE = "@zondax/ledger-oasis"
TESTS_JS_DIR = $(CURDIR)/js

ifeq ($(BOLOS_SDK),)
ZXLIB_COMPILE_STAX ?= 1
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk
else
default:
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ APPNAME = "OasisVal"
APPPATH = "43'/474'"
APPCURVE = --curve ed25519

ifeq ($(TARGET_NAME),TARGET_NANOX)
$(error "Oasis Validator App is not supported in Nano X")
ifneq ($(TARGET_NAME),TARGET_NANOS)
$(error "Oasis Validator App only available for Nano S")
endif

else
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APPVERSION_M=2
APPVERSION_N=5
APPVERSION_P=10
APPVERSION_N=6
APPVERSION_P=0
Binary file removed app/glyphs/digit_dot.gif
Binary file not shown.
Binary file removed app/glyphs/icon_back.gif
Binary file not shown.
Binary file removed app/glyphs/icon_close.gif
Binary file not shown.
Binary file removed app/glyphs/icon_crossmark.gif
Binary file not shown.
Binary file removed app/glyphs/icon_dashboard.gif
Binary file not shown.
Binary file removed app/glyphs/icon_eye.gif
Binary file not shown.
Binary file added app/glyphs/icon_stax_32.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/glyphs/icon_stax_64.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/glyphs/icon_validate.gif
Binary file not shown.
Binary file removed app/glyphs/icon_validate_14.gif
Binary file not shown.
Binary file removed app/glyphs/icon_warning.gif
Binary file not shown.
Empty file.
6 changes: 6 additions & 0 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ __Z_INLINE void handleSignSecp256k1(volatile uint32_t *flags, volatile uint32_t
#if defined(APP_CONSUMER)
CHECK_APP_CANARY()
view_review_init(tx_getItem, tx_getNumItems, app_sign_secp256k1);
#ifndef TARGET_STAX
view_inspect_init(tx_getInnerItem, tx_getNumInnerItems, tx_canInspectItem);
#endif
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
#endif
Expand Down Expand Up @@ -393,7 +395,9 @@ __Z_INLINE void handleSignEd25519(volatile uint32_t *flags, volatile uint32_t *t
#if defined(APP_CONSUMER)
CHECK_APP_CANARY()
view_review_init(tx_getItem, tx_getNumItems, app_sign_ed25519);
#ifndef TARGET_STAX
view_inspect_init(tx_getInnerItem, tx_getNumInnerItems, tx_canInspectItem);
#endif
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
#elif defined(APP_VALIDATOR)
Expand Down Expand Up @@ -473,7 +477,9 @@ __Z_INLINE void handleSignSr25519(volatile uint32_t *flags, volatile uint32_t *t
#if defined(APP_CONSUMER)
CHECK_APP_CANARY()
view_review_init(tx_getItem, tx_getNumItems, app_sign_sr25519);
#ifndef TARGET_STAX
view_inspect_init(tx_getInnerItem, tx_getNumInnerItems, tx_canInspectItem);
#endif
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
#endif
Expand Down
4 changes: 2 additions & 2 deletions app/src/common/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "zxmacros.h"
#include "parser_common.h"

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2)
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
#define RAM_BUFFER_SIZE 8192
#define FLASH_BUFFER_SIZE 16384
#elif defined(TARGET_NANOS)
Expand All @@ -38,7 +38,7 @@ typedef struct {
uint8_t buffer[FLASH_BUFFER_SIZE];
} storage_t;

#if defined(TARGET_NANOS) || defined(TARGET_NANOX) || defined(TARGET_NANOS2)
#if defined(TARGET_NANOS) || defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
storage_t NV_CONST N_appdata_impl __attribute__ ((aligned(64)));
#define N_appdata (*(NV_VOLATILE storage_t *)PIC(&N_appdata_impl))
#endif
Expand Down
8 changes: 4 additions & 4 deletions app/src/consumer/parser_consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static const char *blindSignWarning =

const char addressV0_Secp256k1_ethContext[40] = "oasis-runtime-sdk/address: secp256k1eth";

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2)
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
// For some reason NanoX requires this function
void __assert_fail(__Z_UNUSED const char * assertion, __Z_UNUSED const char * file, __Z_UNUSED unsigned int line, __Z_UNUSED const char * function){
while(1) {};
Expand Down Expand Up @@ -72,14 +72,14 @@ parser_error_t parser_parse(parser_context_t *ctx, const uint8_t *data, size_t d
CHECK_PARSER_ERR(parser_init(ctx, data, dataLen))
return _readEth(ctx, &eth_tx_obj);
}

CHECK_PARSER_ERR(parser_init(ctx, data, dataLen))
CHECK_PARSER_ERR(_readContext(ctx, &parser_tx_obj))
CHECK_PARSER_ERR(_extractContextSuffix(&parser_tx_obj))

// Read after we determine context
CHECK_PARSER_ERR(_read(ctx, &parser_tx_obj));
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
if ((parser_tx_obj.oasis.runtime.call.method >= contractsInstantiate)
&& (parser_tx_obj.type == runtimeType) && !app_mode_expert()) {
return parser_required_expert_mode;
Expand Down Expand Up @@ -287,7 +287,7 @@ parser_error_t parser_printInnerField(ui_field_t *ui_field) {

uint8_t elements_print = 0;
elements_print = (type == CborMapType ? 2 : 1);

for (int i = 0; i< ui_field->displayIdx; i++) {
if (type == CborMapType) {
cbor_value_advance(&current);
Expand Down
8 changes: 4 additions & 4 deletions app/src/consumer/parser_impl_con.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "parser_txdef_con.h"
#include "sha512.h"
#include "zxformat.h"
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
#include "cx.h"
#else
#include "picohash.h"
Expand Down Expand Up @@ -165,7 +165,7 @@ const char *parser_getErrorDescription(parser_error_t err) {
}
}

#if !defined(TARGET_NANOS) && !defined(TARGET_NANOS2) && !defined(TARGET_NANOX)
#if !defined(TARGET_NANOS) && !defined(TARGET_NANOS2) && !defined(TARGET_NANOX) && !defined(TARGET_STAX)
parser_error_t parser_picoHash(uint8_t *src, size_t srcLen, uint8_t *dest, size_t destLen) {
if(destLen < KECCAK256_HASH_LEN) {
return parser_unexpected_buffer_size;
Expand Down Expand Up @@ -1379,7 +1379,7 @@ __Z_INLINE parser_error_t _readRuntimeEncrypted(parser_tx_t *v, CborValue *rootI
CHECK_CBOR_ERR(_cbor_value_get_string_chunk(&dataField, (const void **) &buffer, &buffer_size, NULL))

MEMZERO(&v->oasis.runtime.call.body.encrypted.data_hash, sizeof(v->oasis.runtime.call.body.encrypted.data_hash));
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
cx_sha256_t ctx;
memset(&ctx, 0, sizeof(ctx));
cx_sha256_init_no_throw(&ctx);
Expand Down Expand Up @@ -1428,7 +1428,7 @@ __Z_INLINE parser_error_t _readRuntimeEvmBody(parser_tx_t *v, CborValue *rootIte
CHECK_CBOR_ERR(_cbor_value_get_string_chunk(&dataField, (const void **) &buffer, &buffer_size, NULL))

MEMZERO(&v->oasis.runtime.call.body.evm.data_hash, sizeof(v->oasis.runtime.call.body.evm.data_hash));
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
cx_sha256_t ctx;
memset(&ctx, 0, sizeof(ctx));
cx_sha256_init_no_throw(&ctx);
Expand Down
2 changes: 1 addition & 1 deletion app/src/parser_impl_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ parser_error_t _getItemEth(const parser_context_t *ctx, uint8_t displayIdx,

// we need to get keccak hash of the transaction data
uint8_t hash[32] = {0};
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
keccak_digest(ctx->buffer, ctx->bufferLen, hash, 32);
#endif
// now get the hex string of the hash
Expand Down
2 changes: 1 addition & 1 deletion app/src/validator/parser_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "coin.h"
#include "vote_fsm.h"

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2)
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
// For some reason NanoX requires this function
void __assert_fail(const char * assertion, const char * file, unsigned int line, const char * function){
while(1) {};
Expand Down
Binary file added app/stax_icon.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion deps/nanosplus-secure-sdk
2 changes: 1 addition & 1 deletion deps/nanox-secure-sdk
Submodule nanox-secure-sdk updated 2059 files
1 change: 1 addition & 0 deletions deps/stax-secure-sdk
Submodule stax-secure-sdk added at 51f898
2 changes: 1 addition & 1 deletion ledger_app.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[app]
build_directory = "./app/"
sdk = "C"
devices = ["nanos", "nanox", "nanos+"]
devices = ["nanos", "nanox", "nanos+", "stax"]

[tests]
unit_directory = ""
Binary file modified tests_zemu/snapshots/s-adr0008-0-mainmenu/00004.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-adr0008-0-mainmenu/00007.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-adr0008-0-mainmenu/00010.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-adr0008-5-mainmenu/00004.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-adr0008-5-mainmenu/00007.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-adr0008-5-mainmenu/00010.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified tests_zemu/snapshots/s-cast_vote_yes_testnet/00003.png
Binary file modified tests_zemu/snapshots/s-cast_vote_yes_testnet/00005.png
Binary file modified tests_zemu/snapshots/s-cast_vote_yes_testnet/00006.png
Binary file modified tests_zemu/snapshots/s-cast_vote_yes_testnet/00007.png
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/s-mainmenu/00007.png
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/s-sign_basic_allow_testnet/00003.png
Binary file modified tests_zemu/snapshots/s-sign_basic_allow_testnet/00004.png
Binary file modified tests_zemu/snapshots/s-sign_basic_allow_testnet/00006.png
Binary file modified tests_zemu/snapshots/s-sign_basic_allow_testnet/00007.png
Binary file modified tests_zemu/snapshots/s-sign_basic_allow_testnet/00008.png
Binary file modified tests_zemu/snapshots/sp-adr0008-0-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/sp-adr0008-0-mainmenu/00007.png
Binary file modified tests_zemu/snapshots/sp-adr0008-0-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/sp-adr0008-5-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/sp-adr0008-5-mainmenu/00007.png
Binary file modified tests_zemu/snapshots/sp-adr0008-5-mainmenu/00010.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_mainnet/00001.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_mainnet/00005.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_mainnet/00006.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_mainnet/00007.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00001.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00004.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00005.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00006.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00007.png
Binary file modified tests_zemu/snapshots/sp-cast_vote_yes_testnet/00008.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00007.png
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_mainnet/00002.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_mainnet/00003.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_mainnet/00005.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_mainnet/00006.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_mainnet/00007.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00002.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00003.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00004.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00005.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00006.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00007.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_allow_testnet/00008.png
Binary file added tests_zemu/snapshots/st-add_escrow/00000.png
Binary file added tests_zemu/snapshots/st-add_escrow/00001.png
Binary file added tests_zemu/snapshots/st-add_escrow/00002.png
Binary file added tests_zemu/snapshots/st-add_escrow/00003.png
Binary file added tests_zemu/snapshots/st-add_escrow/00004.png

0 comments on commit b8778d7

Please sign in to comment.