foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Can't verify signature with Trezor One

Open fedealconada opened this issue 1 year ago • 1 comments

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!

fedealconada avatar May 24 '24 10:05 fedealconada

I think this is because the signature r value of the generated signature is 01 and should be 1B (27)?

fedealconada avatar May 24 '24 11:05 fedealconada

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

DaniPopes avatar Jun 04 '24 16:06 DaniPopes

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

zerosnacks avatar Jul 16 '24 10:07 zerosnacks

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

zerosnacks avatar Jul 22 '24 14:07 zerosnacks