Skip to content

Commit 594b9c6

Browse files
fix: Render full 48-byte ETH2 deposit BLS pubkey on validator screen
The ETH2 deposit plugin reassembled the 48-byte BLS12-381 G1 compressed pubkey from two parameter chunks, then passed the raw buffer to getEthDisplayableAddress() to produce the screen string. That helper is hard-coded for 20-byte Ethereum addresses: its inner getEthAddressStringFromBinary() loops `for (i = 0; i < 20; i++)` and silently ignores the trailing 28 bytes of the pubkey. The validator "deposit address" shown to the user was therefore only the first 20 bytes of the 48-byte pubkey, hex-encoded, leaving the user unable to verify they were approving the intended validator. Keep the pubkey stored as raw 48 bytes and render it on screen as "0x" + bytes_to_lowercase_hex() inside the QUERY_CONTRACT_UI handler. Lowercase matches the casing the original getEthDisplayableAddress path produced for the truncated display. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent cec3fbb commit 594b9c6

17 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/plugins/eth2/eth2_plugin.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,12 @@ void eth2_plugin_call(eth_plugin_msg_t message, void *parameters) {
105105
}
106106
case 4 + (PARAMETER_LENGTH * 6): // deposit pubkey 2
107107
{
108-
// Copy the last 16 bytes.
108+
// Copy the last 16 bytes. Storage stays raw (48-byte BLS
109+
// G1 compressed pubkey); the screen renders the full
110+
// value as hex in the QUERY_CONTRACT_UI handler.
109111
memcpy(context->deposit_address + PARAMETER_LENGTH,
110112
msg->parameter,
111113
sizeof(context->deposit_address) - PARAMETER_LENGTH);
112-
113-
// Use a temporary buffer to store the string representation.
114-
char tmp[BLS12381_G1_COMPRESSED_PUBKEY_LENGTH];
115-
if (!getEthDisplayableAddress((uint8_t *) context->deposit_address,
116-
tmp,
117-
sizeof(tmp),
118-
g_chain_config->chain_id)) {
119-
msg->result = ETH_PLUGIN_RESULT_ERROR;
120-
return;
121-
}
122-
123-
// Copy back the string to the global variable.
124-
strlcpy(context->deposit_address, tmp, BLS12381_G1_COMPRESSED_PUBKEY_LENGTH);
125114
msg->result = ETH_PLUGIN_RESULT_OK;
126115
break;
127116
}
@@ -212,7 +201,19 @@ void eth2_plugin_call(eth_plugin_msg_t message, void *parameters) {
212201
} break;
213202
case 1: { // Deposit pubkey screen
214203
strlcpy(msg->title, "Validator", msg->titleLength);
215-
strlcpy(msg->msg, context->deposit_address, msg->msgLength);
204+
if (msg->msgLength < 3) {
205+
msg->result = ETH_PLUGIN_RESULT_ERROR;
206+
break;
207+
}
208+
msg->msg[0] = '0';
209+
msg->msg[1] = 'x';
210+
if (bytes_to_lowercase_hex(&msg->msg[2],
211+
msg->msgLength - 2,
212+
context->deposit_address,
213+
sizeof(context->deposit_address)) != 0) {
214+
msg->result = ETH_PLUGIN_RESULT_ERROR;
215+
break;
216+
}
216217
msg->result = ETH_PLUGIN_RESULT_OK;
217218
} break;
218219
default:
-1.7 KB
Loading
3.67 KB
Loading
-8 KB
Loading
16.2 KB
Loading
199 Bytes
Loading
281 Bytes
Loading
98 Bytes
Loading
140 Bytes
Loading
298 Bytes
Loading

0 commit comments

Comments
 (0)