-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blind sign #36
Blind sign #36
Changes from 6 commits
7e0800b
a8bfa95
3e97157
ec5d970
80b12e7
0e8472e
8d62bb4
2d1fbc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# This is the `transaction_version` field of `Runtime` | ||
APPVERSION_M=2 | ||
# This is the `spec_version` field of `Runtime` | ||
APPVERSION_N=1 | ||
APPVERSION_N=2 | ||
# This is the patch version of this release | ||
APPVERSION_P=14 | ||
APPVERSION_P=0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
#include "parser_impl.h" | ||
#include "msgpack.h" | ||
#include "app_mode.h" | ||
|
||
static uint8_t num_items; | ||
static uint8_t common_num_items; | ||
|
@@ -40,6 +41,24 @@ static parser_error_t _findKey(parser_context_t *c, const char *key); | |
counter++; \ | ||
} | ||
|
||
#define DISPLAY_APP_ITEM(appIdx, len, counter, v) \ | ||
if (!app_mode_blindsign()) { \ | ||
for(uint8_t j = 0; j < len; j++) { \ | ||
CHECK_ERROR(addItem(appIdx)) \ | ||
counter++; \ | ||
} \ | ||
} | ||
|
||
#define DISPLAY_COMMON_ITEM(appIdx, len, counter, v) \ | ||
if (v->type == TX_APPLICATION && !app_mode_expert()) { \ | ||
if (appIdx == IDX_COMMON_SENDER || \ | ||
appIdx == IDX_COMMON_REKEY_TO) { \ | ||
DISPLAY_ITEM(appIdx, len, counter) \ | ||
} \ | ||
} else { \ | ||
DISPLAY_ITEM(appIdx, len, counter) \ | ||
} | ||
|
||
parser_error_t parser_init_context(parser_context_t *ctx, | ||
const uint8_t *buffer, | ||
uint16_t bufferSize) { | ||
|
@@ -773,44 +792,44 @@ static parser_error_t _readTxCommonParams(parser_context_t *c, parser_tx_t *v) | |
|
||
CHECK_ERROR(_findKey(c, KEY_COMMON_SENDER)) | ||
CHECK_ERROR(_readBinFixed(c, v->sender, sizeof(v->sender))) | ||
DISPLAY_ITEM(IDX_COMMON_SENDER, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_SENDER, 1, common_num_items, v) | ||
|
||
if (_findKey(c, KEY_COMMON_LEASE) == parser_ok) { | ||
CHECK_ERROR(_readBinFixed(c, v->lease, sizeof(v->lease))) | ||
DISPLAY_ITEM(IDX_COMMON_LEASE, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_LEASE, 1, common_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_COMMON_REKEY) == parser_ok) { | ||
CHECK_ERROR(_readBinFixed(c, v->rekey, sizeof(v->rekey))) | ||
DISPLAY_ITEM(IDX_COMMON_REKEY_TO, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_REKEY_TO, 1, common_num_items, v) | ||
} | ||
|
||
v->fee = 0; | ||
if (_findKey(c, KEY_COMMON_FEE) == parser_ok) { | ||
CHECK_ERROR(_readInteger(c, &v->fee)) | ||
} | ||
DISPLAY_ITEM(IDX_COMMON_FEE, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_FEE, 1, common_num_items, v) | ||
|
||
if (_findKey(c, KEY_COMMON_GEN_ID) == parser_ok) { | ||
CHECK_ERROR(_readString(c, (uint8_t*)v->genesisID, sizeof(v->genesisID))) | ||
DISPLAY_ITEM(IDX_COMMON_GEN_ID, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_GEN_ID, 1, common_num_items, v) | ||
} | ||
|
||
CHECK_ERROR(_findKey(c, KEY_COMMON_GEN_HASH)) | ||
CHECK_ERROR(_readBinFixed(c, v->genesisHash, sizeof(v->genesisHash))) | ||
DISPLAY_ITEM(IDX_COMMON_GEN_HASH, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_GEN_HASH, 1, common_num_items, v) | ||
|
||
if (_findKey(c, KEY_COMMON_GROUP_ID) == parser_ok) { | ||
CHECK_ERROR(_readBinFixed(c, v->groupID, sizeof(v->groupID))) | ||
DISPLAY_ITEM(IDX_COMMON_GROUP_ID, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_GROUP_ID, 1, common_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_COMMON_NOTE) == parser_ok) { | ||
CHECK_ERROR(_readBinSize(c, &v->note_len)) | ||
if(v->note_len > MAX_NOTE_LEN) { | ||
return parser_unexpected_value; | ||
} | ||
DISPLAY_ITEM(IDX_COMMON_NOTE, 1, common_num_items) | ||
DISPLAY_COMMON_ITEM(IDX_COMMON_NOTE, 1, common_num_items, v) | ||
} | ||
|
||
// First and Last valid won't be display --> don't count them | ||
|
@@ -1049,31 +1068,31 @@ static parser_error_t _readTxApplication(parser_context_t *c, parser_tx_t *v) | |
if (_findKey(c, KEY_APP_ID) == parser_ok) { | ||
CHECK_ERROR(_readInteger(c, &application->id)) | ||
} | ||
DISPLAY_ITEM(IDX_APP_ID, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_APP_ID, 1, tx_num_items, v) | ||
|
||
if (_findKey(c, KEY_APP_ONCOMPLETION) == parser_ok) { | ||
CHECK_ERROR(_readInteger(c, &application->oncompletion)) | ||
} | ||
DISPLAY_ITEM(IDX_ON_COMPLETION, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_ON_COMPLETION, 1, tx_num_items, v) | ||
|
||
if (_findKey(c, KEY_APP_BOXES) == parser_ok) { | ||
CHECK_ERROR(_readBoxes(c, application->boxes, &application->num_boxes)) | ||
DISPLAY_ITEM(IDX_BOXES, application->num_boxes, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_BOXES, application->num_boxes, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_FOREIGN_APPS) == parser_ok) { | ||
CHECK_ERROR(_readArrayU64(c, application->foreign_apps, &application->num_foreign_apps, MAX_FOREIGN_APPS)) | ||
DISPLAY_ITEM(IDX_FOREIGN_APP, application->num_foreign_apps, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_FOREIGN_APP, application->num_foreign_apps, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_FOREIGN_ASSETS) == parser_ok) { | ||
CHECK_ERROR(_readArrayU64(c, application->foreign_assets, &application->num_foreign_assets, MAX_FOREIGN_ASSETS)) | ||
DISPLAY_ITEM(IDX_FOREIGN_ASSET, application->num_foreign_assets, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_FOREIGN_ASSET, application->num_foreign_assets, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_ACCOUNTS) == parser_ok) { | ||
CHECK_ERROR(_verifyAccounts(c, &application->num_accounts, MAX_ACCT)) | ||
DISPLAY_ITEM(IDX_ACCOUNTS, application->num_accounts, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_ACCOUNTS, application->num_accounts, tx_num_items, v) | ||
} | ||
|
||
if(application->num_accounts + application->num_foreign_apps + application->num_foreign_assets > ACCT_FOREIGN_LIMIT) { | ||
|
@@ -1082,7 +1101,7 @@ static parser_error_t _readTxApplication(parser_context_t *c, parser_tx_t *v) | |
|
||
if (_findKey(c, KEY_APP_ARGS) == parser_ok) { | ||
CHECK_ERROR(_verifyAppArgs(c, application->app_args_len, &application->num_app_args, MAX_ARG)) | ||
DISPLAY_ITEM(IDX_APP_ARGS, application->num_app_args, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_APP_ARGS, application->num_app_args, tx_num_items, v) | ||
} | ||
|
||
uint16_t app_args_total_len = 0; | ||
|
@@ -1095,30 +1114,30 @@ static parser_error_t _readTxApplication(parser_context_t *c, parser_tx_t *v) | |
|
||
if (_findKey(c, KEY_APP_GLOBAL_SCHEMA) == parser_ok) { | ||
CHECK_ERROR(_readStateSchema(c, &application->global_schema)) | ||
DISPLAY_ITEM(IDX_GLOBAL_SCHEMA, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_GLOBAL_SCHEMA, 1, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_LOCAL_SCHEMA) == parser_ok) { | ||
CHECK_ERROR(_readStateSchema(c, &application->local_schema)) | ||
DISPLAY_ITEM(IDX_LOCAL_SCHEMA, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_LOCAL_SCHEMA, 1, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_EXTRA_PAGES) == parser_ok) { | ||
CHECK_ERROR(_readUInt8(c, &application->extra_pages)) | ||
if (application->extra_pages > 3){ | ||
return parser_too_many_extra_pages; | ||
} | ||
DISPLAY_ITEM(IDX_EXTRA_PAGES, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_EXTRA_PAGES, 1, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_APROG_LEN) == parser_ok) { | ||
CHECK_ERROR(_getPointerBin(c, &application->aprog, &application->aprog_len)) | ||
DISPLAY_ITEM(IDX_APPROVE, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_APPROVE, 1, tx_num_items, v) | ||
} | ||
|
||
if (_findKey(c, KEY_APP_CPROG_LEN) == parser_ok) { | ||
CHECK_ERROR(_getPointerBin(c, &application->cprog, &application->cprog_len)) | ||
DISPLAY_ITEM(IDX_CLEAR, 1, tx_num_items) | ||
DISPLAY_APP_ITEM(IDX_CLEAR, 1, tx_num_items, v) | ||
} | ||
|
||
if (application->id == 0 && application->cprog_len + application->aprog_len > PAGE_LEN *(1+application->extra_pages)){ | ||
|
@@ -1163,7 +1182,17 @@ parser_error_t _read(parser_context_t *c, parser_tx_t *v) | |
CHECK_ERROR(_readTxAssetConfig(c, v)) | ||
break; | ||
case TX_APPLICATION: | ||
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX) || defined(TARGET_FLEX) | ||
if (!app_mode_blindsign() && !app_mode_expert()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I might be missing the goal here. So if Bs not enabled and app in normal mode, we request BS mode ? I was not really in the discussion of this but in my opinion, in this case the BS mode is not required because we will not show certain information, but more of a shortcut mode imitation, thus the user can enable it to skip screens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just saw the 4 possible options on the Slack channel, I guess this is right then. |
||
return parser_blindsign_mode_required; | ||
} | ||
CHECK_ERROR(_readTxApplication(c, v)) | ||
if (app_mode_expert() && !app_mode_blindsign()) { | ||
app_mode_skip_blindsign_ui(); | ||
} | ||
#else | ||
CHECK_ERROR(_readTxApplication(c, v)) | ||
#endif | ||
break; | ||
default: | ||
return parser_unknown_transaction; | ||
|
@@ -1222,6 +1251,8 @@ const char *parser_getErrorDescription(parser_error_t err) { | |
return "display page out of range"; | ||
case parser_unexpected_error: | ||
return "Unexpected error in parser"; | ||
case parser_blindsign_mode_required: | ||
return "Blind signing mode required"; | ||
case parser_unexpected_type: | ||
return "Unexpected type"; | ||
case parser_unexpected_method: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should remove the REVIEW_SCREEN_ENABLE this will lead to the removal of the "Review Address" screen on the show address command.