Skip to content

feat(keepkey): expose firmware-reported pre-image hash on EthSignTx#40

Open
BitHighlander wants to merge 2 commits into
masterfrom
feat/eth-sign-tx-device-hash
Open

feat(keepkey): expose firmware-reported pre-image hash on EthSignTx#40
BitHighlander wants to merge 2 commits into
masterfrom
feat/eth-sign-tx-device-hash

Conversation

@BitHighlander
Copy link
Copy Markdown
Collaborator

Summary

  • EthereumSignedTx (KeepKey custom proto) carries an optional hash field — the keccak256 pre-image the firmware actually signed. The SDK previously ignored it.
  • Capture it and surface as deviceSignedHash on the returned signed tx so callers can pin firmware behavior in tests / diagnostics.
  • Non-breaking: purely additive, optional field, older firmware silently skips (try/catch).

Motivation

EIP-1559 tx hash regression where ethers.Transaction.from() reconstruction recovers the wrong signer. With the firmware-reported hash exposed, we can narrow the divergence to RLP-construction vs. signing instead of guessing.

Test plan

  • Existing ETH-sign tests still green (no shape change for callers that don't read deviceSignedHash).
  • On firmware that supports the hash field: signed tx response includes deviceSignedHash as a 32-byte hex string.
  • On older firmware lacking the field: deviceSignedHash is undefined; nothing else changes.
  • Diagnostic harness (separate repo) recovers expectedSigner from (deviceSignedHash, r, s, v) for the regression fixture.

…esponse

EthereumSignedTx (KeepKey custom proto) carries an optional `hash` field —
the keccak256 pre-image the firmware actually signed. Until now the SDK
ignored it, so the only way to verify which message bytes the device hashed
was to recover the signer client-side and compare to the expected address.

Surface the hash as `deviceSignedHash` on the returned signed tx so callers
can pin the exact firmware behavior in tests/diagnostics. Older firmware
doesn't populate the field; absence is non-fatal (try/catch, optional).

Motivating use case: EIP-1559 tx hash regression where ethers'
Transaction.from() reconstruction recovers the wrong signer — having the
firmware-reported hash narrows the divergence to RLP construction vs.
signing, instead of guessing.

Non-breaking: purely additive. Existing consumers see the same shape.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hdwallet-sandbox Ready Ready Preview, Comment May 8, 2026 4:10pm

Request Review

…d it

Review feedback on PR #40: the previous commit attached deviceSignedHash via a
local cast in hdwallet-keepkey, but ETHSignedTx in hdwallet-core didn't declare
the field — TypeScript callers couldn't read it without their own cast, which
defeated the diagnostic purpose.

Add deviceSignedHash?: string to ETHSignedTx (optional, KeepKey-only) and drop
the local cast. The shape is identical at runtime; this just makes the field
visible to consumers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant