Skip to content

Commit 49a75e0

Browse files
committed
Merge remote-tracking branch 'benma/recid'
2 parents 7d73ee7 + 6fa00d5 commit 49a75e0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

py/bitbox02/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelog
2+
3+
## 6.0.0
4+
- Offset the recoverable ID by 27 in the signature returned by `eth_sign_msg()`.

py/bitbox02/bitbox02/bitbox02/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from __future__ import print_function
1717
import sys
1818

19-
__version__ = "5.3.0"
19+
__version__ = "6.0.0"
2020

2121
if sys.version_info.major != 3 or sys.version_info.minor < 6:
2222
print(

py/bitbox02/bitbox02/bitbox02/bitbox02.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,16 @@ def eth_sign_msg(
774774
) -> bytes:
775775
"""
776776
Signs message, the msg will be prefixed with "\x19Ethereum message\n" + len(msg) in the
777-
hardware
777+
hardware. 27 is added to the recID to denote an uncompressed pubkey.
778778
"""
779+
780+
def format_as_uncompressed(sig: bytes) -> bytes:
781+
# 27 is the magic constant to add to the recoverable ID to denote an uncompressed
782+
# pubkey.
783+
s = list(sig)
784+
s[64] += 27
785+
return bytes(s)
786+
779787
request = eth.ETHRequest()
780788
# pylint: disable=no-member
781789
request.sign_msg.CopyFrom(eth.ETHSignMessageRequest(coin=coin, keypath=keypath, msg=msg))
@@ -800,9 +808,10 @@ def eth_sign_msg(
800808
if self.debug:
801809
print(f"Antiklepto nonce verification PASSED")
802810

803-
return signature
811+
return format_as_uncompressed(signature)
804812

805-
return self._eth_msg_query(request, expected_response="sign").sign.signature
813+
signature = self._eth_msg_query(request, expected_response="sign").sign.signature
814+
return format_as_uncompressed(signature)
806815

807816
def reset(self) -> bool:
808817
"""

0 commit comments

Comments
 (0)