diff --git a/src_plugins/eth2/eth2_plugin.c b/src_plugins/eth2/eth2_plugin.c index a194293..378bdc3 100644 --- a/src_plugins/eth2/eth2_plugin.c +++ b/src_plugins/eth2/eth2_plugin.c @@ -61,7 +61,7 @@ static int check_deposit_contract(ethPluginInitContract_t *msg) { uint8_t destinationLen = getEthDisplayableAddress(destinationAddress, content->destination); if (destinationLen != DEPOSIT_CONTRACT_LENGTH) { - PRINTF("eth2plugin: destination lengths differs. Expected %u got %u\n", + PRINTF("eth2plugin: destination lengths differ. Expected %u got %u\n", DEPOSIT_CONTRACT_LENGTH, destinationLen); return 0; @@ -170,27 +170,27 @@ void eth2_plugin_call(int message, void *parameters) { case 4 + (32 * 8): // withdrawal credentials { - // uint8_t tmp[48]; - // uint32_t withdrawalKeyPath[4]; - // withdrawalKeyPath[0] = WITHDRAWAL_KEY_PATH_1; - // withdrawalKeyPath[1] = WITHDRAWAL_KEY_PATH_2; - // if (eth2WithdrawalIndex > INDEX_MAX) { - // PRINTF("eth2 plugin: withdrawal index is too big\n"); - // PRINTF("Got %u which is higher than INDEX_MAX (%u)\n", - // eth2WithdrawalIndex, INDEX_MAX); context->valid = 0; - // } - // 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); - // tmp[0] = 0; - // if (memcmp(tmp, msg->parameter, 32) != 0) { - // PRINTF("eth2 plugin invalid withdrawal credentials\n"); - // PRINTF("Got %.*H\n", 32, msg->parameter); - // PRINTF("Expected %.*H\n", 32, tmp); - // context->valid = 0; - // } + uint8_t tmp[48]; + uint32_t withdrawalKeyPath[4]; + withdrawalKeyPath[0] = WITHDRAWAL_KEY_PATH_1; + withdrawalKeyPath[1] = WITHDRAWAL_KEY_PATH_2; + if (eth2WithdrawalIndex > INDEX_MAX) { + PRINTF("eth2 plugin: withdrawal index is too big\n"); + PRINTF("Got %u which is higher than INDEX_MAX (%u)\n", + eth2WithdrawalIndex, INDEX_MAX); context->valid = 0; + } + 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); + tmp[0] = 0; + if (memcmp(tmp, msg->parameter, 32) != 0) { + PRINTF("eth2 plugin invalid withdrawal credentials\n"); + PRINTF("Got %.*H\n", 32, msg->parameter); + PRINTF("Expected %.*H\n", 32, tmp); + context->valid = 0; + } msg->result = ETH_PLUGIN_RESULT_OK; } break;