Can't verify signature with Trezor One
Component
Cast
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
forge 0.2.0 (b1f4684 2024-05-24T00:20:26.633676000Z)
What command(s) is the bug in?
cast wallet sign "message" --trezor
Operating System
macOS (Apple Silicon)
Describe the bug
I'm trying to sign a message using my Trezor One, which seems to work, but then fails when I try to verify it.
You can reproduce this by copy-pasting the below script on your command line. It simply signs a message with --trezor and then tries to verify it: Validation failed. Address 0xADDRESS did not sign this message.
This same script works well using --private-key or --ledger.
# Set the message
MESSAGE="some message"
# Check the address that will be used for signing
echo "Checking address with Trezor..."
SIGNER_ADDRESS=$(cast wallet address --trezor)
echo "Signer Address: $SIGNER_ADDRESS"
# Generate the signature using Trezor
echo "Signing message $MESSAGE with Trezor..."
SIGNATURE=$(cast wallet sign "$MESSAGE" --trezor)
echo "Signature: $SIGNATURE"
# Verify the signature using the original message
echo "Verifying the signature..."
cast wallet verify --address "$SIGNER_ADDRESS" "$MESSAGE" "$SIGNATURE"
Thanks!
I think this is because the signature r value of the generated signature is 01 and should be 1B (27)?
Do you mean v value? In anyway that's strange because we're just passing through the values we get from the Trezor device directly. cc @klkvr
Related: https://github.com/foundry-rs/foundry/issues/7660 + https://github.com/foundry-rs/foundry/issues/7342 + https://github.com/alloy-rs/alloy/pull/1045 + https://github.com/trezor/trezor-firmware/pull/3952
Fix will be included in the next Alloy release
Marking as resolved by https://github.com/alloy-rs/alloy/releases/tag/v0.2.0 and Foundry having been bumped to 0.2.0 in https://github.com/foundry-rs/foundry/pull/8305/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542
Please re-open if this is still an issue