-
Notifications
You must be signed in to change notification settings - Fork 14
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
Eth addresscase #107
Conversation
cb4eeda
to
3bbbd0f
Compare
api/firmware/eth_test.go
Outdated
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("") |
There was a problem hiding this comment.
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
api/firmware/eth_test.go
Outdated
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("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
2f3bb3e
to
10ccf55
Compare
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
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.
10ccf55
to
cccb6e3
Compare
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>
cccb6e3
to
b8e2672
Compare
// 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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
See commits for detailed explanation.