Skip to content

Eth addresscase #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2024
Merged

Eth addresscase #107

merged 2 commits into from
Aug 29, 2024

Conversation

asi345
Copy link
Contributor

@asi345 asi345 commented Aug 28, 2024

See commits for detailed explanation.

@asi345 asi345 requested a review from benma August 28, 2024 11:50
@asi345 asi345 force-pushed the eth_addresscase branch 2 times, most recently from cb4eeda to 3bbbd0f Compare August 28, 2024 12:30
recipient := [20]byte{0x04, 0xf2, 0x64, 0xcf, 0x34, 0x44, 0x03, 0x13, 0xb4, 0xa0,
0x19, 0x2a, 0x35, 0x28, 0x14, 0xfb, 0xe9, 0x27, 0xb8, 0x85}
value := new(big.Int).SetUint64(530564000000000000)
data := []byte("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just be data := nil

recipient := [20]byte{0x04, 0xf2, 0x64, 0xcf, 0x34, 0x44, 0x03, 0x13, 0xb4, 0xa0,
0x19, 0x2a, 0x35, 0x28, 0x14, 0xfb, 0xe9, 0x27, 0xb8, 0x85}
value := new(big.Int).SetUint64(530564000000000000)
data := []byte("")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@asi345 asi345 force-pushed the eth_addresscase branch 2 times, most recently from 2f3bb3e to 10ccf55 Compare August 28, 2024 15:01
Copy link
Contributor

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, left just small nits.

@@ -141,6 +141,17 @@ func (device *Device) handleSignerNonceCommitment(response *messages.ETHResponse
return signature, nil
}

func ETHIdentifyCase(recipientAddress string) messages.ETHAddressCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a docstring of the form // ETHIdentifyCase .... All exported API functions should come with docs.

return messages.ETHAddressCase_ETH_ADDRESS_CASE_MIXED
}
}

// ETHSign signs an ethereum transaction. It returns a 65 byte signature (R, S, and 1 byte recID).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to the docstring what recipientAddressCase does and mention ETHIdentifyCase exists as a convenience function.

asi345 added 2 commits August 29, 2024 13:53
see : BitBoxSwiss/bitbox02-firmware@055bda6

For ETH signing legacy and EIP1559 transactions, the BitBox02 device
shows confirmation screens for recipient and amount. For recipient, the
device was previously showing the address in mixed case according to
EIP-55, no matter the case user has entered. This created confusions
among the users.

That is why not the go library detects the case of the recipient address
useer inputted and sends this case information to BitBox02 device, which
will in turn show the recipient address in the same case that it got
from the library.

Signed-off-by: asi345 <inanata15@gmail.com>
There was no unit tests for these functionalities before. For any
occasion, we added them so that modifications to these functions will be
tested.

Signed-off-by: asi345 <inanata15@gmail.com>
Comment on lines +144 to +148
// ETHIdentifyCase identifies the case of the recipient address given as hexadecimal string.
// This function exists as a convenience to potentially help clients to determine the case of the
// recipient address. The output of the function goes to ETHSign and ETHSignEIP1559 as the
// recipientAddressCase parameter, which is forwarded to BitBox02 device to reconstruct the address
// in the correct case(the one that the user enters).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

Copy link
Contributor

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@benma benma merged commit a9a0733 into BitBoxSwiss:master Aug 29, 2024
3 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