Skip to content
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

Improve Blindsign UI #2

Merged
merged 16 commits into from
Jan 15, 2025
Merged

Improve Blindsign UI #2

merged 16 commits into from
Jan 15, 2025

Conversation

chcmedeiros
Copy link

@chcmedeiros chcmedeiros commented Jan 7, 2025

  • Add new Blindsign ui flow;
  • Add eip191 personal message signing;
  • Small updates.

chcmedeiros and others added 16 commits November 13, 2024 15:22
* remove js package

* add js submodule

* update tests

* update snapshots
* update submodules

* add blindsign ui

* update tests

* update snapshots

* update test and snapshots for sign hash

* fix error return
* update deps and submodules

* coin asset depending on chain id

* update zxlib

* add blindsign required flag

* update tests

* update snapshots
* move files to evm folder

* update remaining code structure

* update fuzzer and tests

* small argument fix
* add sign_personal

* update js package

* update snapshots
* update zxlib

* update deps

* update snapshots
* add switch to coin asset

* update snapshots

* add test

* update snapshots
* add  flare CLA extra verification

* remove not needed DER signature from response

* update zxlib

* bump version

* update fuzzer

* update docs

* update docs
* add  flare CLA extra verification

* remove not needed DER signature from response

* update zxlib

* bump version

* update fuzzer

* update docs

* update docs
Comment on lines +143 to +218
switch (payloadType) {
case P1_ETH_FIRST:
tx_initialize();
tx_reset();
extract_eth_path(rx, OFFSET_DATA);
// there is not warranties that the first chunk
// contains the serialized path only;
// so we need to offset the data to point to the first transaction
// byte
uint32_t path_len = sizeof(uint32_t) * hdPathEth_len;

// plus the first offset data containing the path len
data += path_len + 1;
if (len < path_len) {
THROW(APDU_CODE_WRONG_LENGTH);
}

// now process the chunk
len -= path_len + 1;
if (get_tx_rlp_len(data, len, &read, &to_read) != rlp_ok) {
THROW(APDU_CODE_DATA_INVALID);
}

// get remaining data len
max_len = saturating_add(read, to_read);
max_len = MIN(max_len, len);

added = tx_append(data, max_len);
if (added != max_len) {
THROW(APDU_CODE_OUTPUT_BUFFER_TOO_SMALL);
}

tx_initialized = true;

// if the number of bytes read and the number of bytes to read
// is the same as what we read...
if ((saturating_add(read, to_read) - len) == 0) {
return true;
}
return false;
case P1_ETH_MORE:
if (!tx_initialized) {
THROW(APDU_CODE_TX_NOT_INITIALIZED);
}

uint64_t buff_len = tx_get_buffer_length();
uint8_t *buff_data = tx_get_buffer();

if (get_tx_rlp_len(buff_data, buff_len, &read, &to_read) != rlp_ok) {
THROW(APDU_CODE_DATA_INVALID);
}

uint64_t rlp_read = buff_len - read;

// either the entire buffer of the remaining bytes we expect
uint64_t missing = to_read - rlp_read;
max_len = len;

if (missing < len) {
max_len = missing;
}
added = tx_append(data, max_len);

if (added != max_len) {
tx_initialized = false;
THROW(APDU_CODE_OUTPUT_BUFFER_TOO_SMALL);
}

// check if this chunk was the last one
if (missing - len == 0) {
tx_initialized = false;
return true;
}

return false;
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
0 (38 lines)
.
Switch has at least one case that is too long:
128 (34 lines)
.
Copy link

@iartemov-ledger iartemov-ledger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chcmedeiros ,maybe in a next PR:

@iartemov-ledger iartemov-ledger merged commit f281b8f into LedgerHQ:develop Jan 15, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants