From 235b4b1863c4f7a74f904153673606a60110b46d Mon Sep 17 00:00:00 2001 From: BTChip github Date: Mon, 2 Nov 2020 23:01:53 +0100 Subject: [PATCH] Fix Withdrawal key derivation path --- doc/ethapp.asc | 2 +- src_plugins/eth2/eth2_plugin.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ethapp.asc b/doc/ethapp.asc index 716cd9a..878223c 100644 --- a/doc/ethapp.asc +++ b/doc/ethapp.asc @@ -360,7 +360,7 @@ This command has been supported since firmware version 1.5.0 #### Description -This command sets the index of the Withdrawal key used as withdrawal credentials in an ETH2 deposit contract call signature. The path of the Withdrawal key starts with 12381/3600/0 according to EIP 2333 (https://eips.ethereum.org/EIPS/eip-2333) +This command sets the index of the Withdrawal key used as withdrawal credentials in an ETH2 deposit contract call signature. The path of the Withdrawal key is defined as m/12381/3600/index/0 according to EIP 2334 (https://eips.ethereum.org/EIPS/eip-2334) The default index used is 0 if this method isn't called before the deposit contract transaction is sent to the device to be signed diff --git a/src_plugins/eth2/eth2_plugin.c b/src_plugins/eth2/eth2_plugin.c index bd9b7f7..9346088 100644 --- a/src_plugins/eth2/eth2_plugin.c +++ b/src_plugins/eth2/eth2_plugin.c @@ -11,7 +11,7 @@ void getEth2PublicKey(uint32_t *bip32Path, uint8_t bip32PathLength, uint8_t *out #define WITHDRAWAL_KEY_PATH_1 12381 #define WITHDRAWAL_KEY_PATH_2 3600 -#define WITHDRAWAL_KEY_PATH_3 0 +#define WITHDRAWAL_KEY_PATH_4 0 #define ETH2_DEPOSIT_PUBKEY_OFFSET 0x80 #define ETH2_WITHDRAWAL_CREDENTIALS_OFFSET 0xE0 @@ -95,8 +95,8 @@ void eth2_plugin_call(int message, void *parameters) { uint32_t withdrawalKeyPath[4]; withdrawalKeyPath[0] = WITHDRAWAL_KEY_PATH_1; withdrawalKeyPath[1] = WITHDRAWAL_KEY_PATH_2; - withdrawalKeyPath[2] = WITHDRAWAL_KEY_PATH_3; - withdrawalKeyPath[3] = eth2WithdrawalIndex; + withdrawalKeyPath[2] = eth2WithdrawalIndex; + withdrawalKeyPath[3] = WITHDRAWAL_KEY_PATH_4; getEth2PublicKey(withdrawalKeyPath, 4, tmp); PRINTF("eth2 plugin computed withdrawal public key %.*H\n", 48, tmp); cx_hash_sha256(tmp, 48, tmp, 32);