Skip to content

feat: add Trezor hardware wallet support#31

Merged
aviggiano merged 1 commit into
Recon-Fuzz:mainfrom
Telcoin-Association:feat/hardware-wallet-support
May 14, 2026
Merged

feat: add Trezor hardware wallet support#31
aviggiano merged 1 commit into
Recon-Fuzz:mainfrom
Telcoin-Association:feat/hardware-wallet-support

Conversation

@chasebrownn
Copy link
Copy Markdown
Contributor

@chasebrownn chasebrownn commented May 12, 2026

Trezor hardware wallet support

Motivation

The library previously only supported Ledger for signing. Teams using Trezor had no path to propose transactions through safe-utils.

What's added

Safe.sol — Trezor signing path in sign()

The sign() function now reads a HARDWARE_WALLET environment variable (defaults to ledger) and branches accordingly:

HARDWARE_WALLET=trezor forge script ... --ffi

When trezor is selected, sign() calls cast wallet sign --trezor <safeTxHash> via vm.ffi instead of using Ledger's EIP-712 --data path. One post-processing step is required: Trezor signs via eth_sign, which prepends \x19Ethereum Signed Message:\n32 to the hash. Safe's checkNSignatures detects this signature type by checking v >= 31, so the recovery byte is incremented by 4 (output[64] += 4) before returning.

README.md

  • Clarified that the derivation path argument applies to both Ledger and Trezor.
  • Added the HARDWARE_WALLET=trezor env var usage example.
  • Updated the sign() note to cover both --ledger and --trezor flags.

Why not --trezor directly?

cast wallet sign --trezor --data <EIP-712 json> is not supported by Trezor's firmware — it only handles raw message signing (eth_sign), not structured data (eth_signTypedData). Passing the raw safeTxHash and adjusting v is the correct workaround.

@chasebrownn chasebrownn marked this pull request as ready for review May 13, 2026 15:23
Copy link
Copy Markdown
Collaborator

Hi there,

Thanks for your submission. I will review this until the end of the week and we'll get this merge soon

@aviggiano
Copy link
Copy Markdown
Collaborator

Hey

This looks go to be merged

I don't have a Trezor so haven't tested it, and the unit testing support for this library is very inconvenient. So we should expect users to do their own testing

@aviggiano aviggiano merged commit 67ba334 into Recon-Fuzz:main May 14, 2026
2 checks passed
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.

2 participants