Skip to content

Commit

Permalink
Merge pull request #4 from thesis/fix-withdrawal-domain-hash-calculat…
Browse files Browse the repository at this point in the history
…ion-testnet

Update Chain ID for testnet domain hash calculation in withdrawal signing
https://ledgerhq.atlassian.net/browse/B2CA-1833
  • Loading branch information
cedelavergne-ledger authored Nov 27, 2024
2 parents cebe71e + 3021f20 commit 4f0c92e
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ PATH_APP_LOAD_PARAMS = ""
# Application version
APPVERSION_M = 1
APPVERSION_N = 1
APPVERSION_P = 4
APPVERSION_P = 5
APPVERSION_SUFFIX = # if not empty, appended at the end. Do not add a dash.

ifeq ($(APPVERSION_SUFFIX),)
Expand Down
6 changes: 4 additions & 2 deletions src/handler/withdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ static unsigned char const BSM_SIGN_MAGIC[] = {'\x18', 'B', 'i', 't', 'c', 'o',
#error "COIN_VARIANT is not defined"
#elif COIN_VARIANT == COIN_VARIANT_ACRE
// Mainnet hash
// Mainnet Chain ID - 1 (0x01)
static const uint8_t abi_encoded_chain_id[32] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
#elif COIN_VARIANT == COIN_VARIANT_ACRE_TESTNET
// Testnet hash
// Sepolia Chain ID - 11155111 (0xaa36a7)
static const uint8_t abi_encoded_chain_id[32] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x05, 0x77};
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x36, 0xa7};
#else
#error "Unsupported COIN_VARIANT value"
#endif
Expand Down Expand Up @@ -823,4 +825,4 @@ void handler_withdraw(dispatcher_context_t* dc, uint8_t protocol_version) {
PRINTF("Error in ui_post_processing_confirm_withdraw");
}
return;
}
}
Binary file modified tests/snapshots/flex/test_dashboard/00001.png
Loading
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/snapshots/nanosp/test_dashboard/00001.png
Loading
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/snapshots/nanox/test_dashboard/00001.png
Loading
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/snapshots/stax/test_dashboard/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/test_sign_withdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def test_sign_withdraw(navigator: Navigator, firmware: Firmware, client: RaggerC
gasToken= "0x0000000000000000000000000000000000000000",
refundReceiver= "0x0000000000000000000000000000000000000000",
nonce= "0x8",
) # tx_hash: 0xed3a7a50496ccca6173ddd9a1ad786d61ea737b70541887ab2c2fadcbe36eeaf
) # tx_hash: 0xa580c0c5a0b8e731f7b7fe8ea3ee41cf0dbe78b352b55ae090160659e2d7410c
path = "m/44'/0'/0'/0/0"
result = client.sign_withdraw(data, path, navigator,
instructions=withdrawal_instruction_approve(firmware),
testname=test_name)
assert result == "IEZDsLh2JweulEOzl2dgLrYvtIqWUW8gFeYdMLAYSk7PeH72uN0JQJGVCYZSpJ5HYRaKZrmSBiG3Ypl+oelXEAM="
assert result == "Hy2UpLBXRUkHBRfXIEYFB8PEteLtjxrqJ7kJ3Qe+i67wP0bzDkFl5Z4bYBFfT/3+xwgPrw3T0rkq6dv53Cff+p0="

def test_sign_withdraw_wrong_address(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str):
data = AcreWithdrawalData(
Expand Down

0 comments on commit 4f0c92e

Please sign in to comment.