Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
chcmedeiros committed Nov 29, 2024
1 parent 2830295 commit 692ab42
Show file tree
Hide file tree
Showing 83 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/src/evm/eth_eip191.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ parser_error_t eip191_msg_parse() {
// or first char is not printable.
if (messageLength > 0 && (npc * 100) / messageLength >= 40 && !app_mode_blindsign()) {
return parser_blindsign_required;
} else if ((npc * 100) / messageLength < 40) {
} else if (messageLength > 0 && (npc * 100) / messageLength < 40) {
app_mode_skip_blindsign_ui();
}

Expand Down
1 change: 1 addition & 0 deletions app/src/evm/parser_eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>

#include "parser_impl.h"

Expand Down
8 changes: 6 additions & 2 deletions app/src/evm/parser_impl_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ eth_tx_t eth_tx_obj;
#define DATA_BYTES_TO_PRINT 10
#define TMP_DATA_ARRAY_SIZE 40
#define ERC20_TRANSFER_OFFSET 4 + 12
#define ETHEREUM_RECOVERY_OFFSET 27
#define EIP155_V_BASE 35

static parser_error_t readChainID(parser_context_t *ctx, rlp_t *chainId) {
if (ctx == NULL || chainId == NULL) {
Expand Down Expand Up @@ -484,8 +486,10 @@ parser_error_t _computeV(parser_context_t *ctx, eth_tx_t *tx_obj, unsigned int i
}

uint8_t parity = (info & CX_ECCINFO_PARITY_ODD) == 1;

/// No chain id in the transaction use ETHEREUM_RECOVERY_OFFSET
if (personal_msg) {
*v = 27 + parity;
*v = ETHEREUM_RECOVERY_OFFSET + parity;
return parser_ok;
}

Expand All @@ -504,7 +508,7 @@ parser_error_t _computeV(parser_context_t *ctx, eth_tx_t *tx_obj, unsigned int i
CHECK_ERROR(be_bytes_to_u64(tx_obj->chainId.ptr, tx_obj->chainId.rlpLen, &id));
}

uint32_t cv = 35 + parity;
uint32_t cv = EIP155_V_BASE + parity;
cv = saturating_add_u32(cv, (uint32_t)id * 2);
*v = (uint8_t)cv;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions tests_zemu/tests/eip191.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
******************************************************************************* */
import Zemu, { ButtonKind, isTouchDevice } from '@zondax/zemu'
import { SeiApp } from '@zondax/ledger-sei'
import { FlareApp } from '@zondax/ledger-flare'
import { ETH_PATH, EXPECTED_ETH_ADDRESS, EXPECTED_ETH_PK, defaultOptions, models } from './common'
import { ec } from 'elliptic'
jest.setTimeout(90000)
Expand All @@ -23,26 +23,35 @@ const SIGN_TEST_DATA = [
{
name: 'personal_sign_msg',
message: Buffer.from('Hello World!', 'utf8'),
blind: false,
},
{
name: 'personal_sign_big_msg',
message: Buffer.from('Just a big dummy message to be sign. To test if ew are parsing the chunks in the right way. By: Zondax', 'utf8'),
blind: false,
},
{
name: 'personal_sign_non_printable_msg',
message: Buffer.from('\x00\x00\x00\x00\x00zx', 'utf8'),
blind: true,
},
]
describe.each(models)('EIP191', function (m) {
test.concurrent.each(SIGN_TEST_DATA)('sign transaction: $name', async function (data) {
const sim = new Zemu(m.path)
try {
await sim.start({ ...defaultOptions, model: m.name })
const app = new SeiApp(sim.getTransport())
const app = new FlareApp(sim.getTransport())
const msgData = data.message

await sim.toggleBlindSigning()
if (data.blind) {
await sim.toggleBlindSigning()
}
// do not wait here..
const signatureRequest = app.signPersonalMessage(ETH_PATH, msgData.toString('hex'))
// Wait until we are not in the main menu
await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot())
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-eth-${data.name}`)
await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-eth-${data.name}`, true, 0, 1500, data.blind)
let resp = await signatureRequest
console.log(resp)
const header = Buffer.from('\x19Ethereum Signed Message:\n', 'utf8')
Expand Down

0 comments on commit 692ab42

Please sign in to comment.