Skip to content

Commit

Permalink
sign messages from different script types: tests and bugfix for 49'
Browse files Browse the repository at this point in the history
  • Loading branch information
odudex committed Sep 23, 2024
1 parent 2b02052 commit 5ef6ba9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/krux/pages/home_pages/sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import binascii
from .. import MENU_CONTINUE, LOAD_FROM_CAMERA, LOAD_FROM_SD, Menu
from ..utils import Utils
from ...key import SINGLESIG_SCRIPT_PURPOSE, P2PKH, P2SH, P2WPKH, P2TR
from ...key import SINGLESIG_SCRIPT_PURPOSE, P2PKH, P2WPKH, P2TR, P2SH_P2WPKH
from ...themes import theme
from ...display import (
DEFAULT_PADDING,
Expand Down Expand Up @@ -120,7 +120,7 @@ def get_bitcoin_address(self, derivation_path, script_type=""):
elif script_type == P2PKH:
p2pkh_script = script.p2pkh(pubkey)
addr = p2pkh_script.address(network=network)
elif script_type == P2SH - P2WPKH:
elif script_type == P2SH_P2WPKH:
p2wpkh_script = script.p2wpkh(pubkey)
p2sh_script = script.p2sh(p2wpkh_script)
addr = p2sh_script.address(network=network)
Expand Down
51 changes: 48 additions & 3 deletions tests/pages/home_pages/test_sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_sign_message_at_address(mocker, m5stickv, tdata):
# Message content
# Displayed address
# Signature
(
( # 0 - Sign P2WPKH Mainnet
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Confirm to sign message
Expand All @@ -256,7 +256,7 @@ def test_sign_message_at_address(mocker, m5stickv, tdata):
"3. bc1qgl..cn3",
"IN/4LmcGRaI5sgvBP2mrTXQFvD6FecXd8La03SixPabsb/255ElRGTcXhicT3KFsNJbfQ9te909ZXeKMaqUcaPM=",
),
(
( # 1 - Sign P2WPKH Testnet
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Confirm to sign message
Expand All @@ -271,7 +271,52 @@ def test_sign_message_at_address(mocker, m5stickv, tdata):
"3. tb1qyn..5km",
"ILc30ti8OPSpCtzfj7sNnftANBCuVpyRX7pnM3iAgOk9F9IUtnXNPus0+MF12y5HKYHAB6IVYr66sLmL3Vi3oEE=",
),
( # Save to SD card
( # 2 - Sign P2TR Mainnet
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Confirm to sign message
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
BUTTON_ENTER, # Check QR code
],
"signmessage m/86h/0h/0h/0/3 ascii:a test message with a colon ':' character.",
None,
False,
"a test message with a colon ':' character.",
"3. bc1py0..ler",
"H3Z5VioeLaC0rpdI2CflUu34IANgGxum0Rr9lmCziQRfUQv+vFND+nHvxHmJZA0uvLLI1/mTEEHD2bBfN6Y2d6w=",
),
( # 3 - Sign Legacy Mainnet
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Confirm to sign message
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
BUTTON_ENTER, # Check QR code
],
"signmessage m/44h/0h/0h/0/3 ascii:a test message with a colon ':' character.",
None,
False,
"a test message with a colon ':' character.",
"3. 1MVGa1..rsJ",
"IEpq8rUwSmDxO3GgwaZ75tw3DArtHtLi08kgQuRNXdteMI5KNEAWbpzsY8gRzGkspZN4YFiRu4RNCM+IsKkWys8=",
),
( # 4 - Sign Nested Segwit Mainnet
[
BUTTON_ENTER, # Load from camera
BUTTON_ENTER, # Confirm to sign message
BUTTON_ENTER, # Check signature
BUTTON_ENTER, # Sign to QR code
BUTTON_ENTER, # Check QR code
],
"signmessage m/49h/0h/0h/0/3 ascii:a test message with a colon ':' character.",
None,
False,
"a test message with a colon ':' character.",
"3. 38Cahk..EAN",
"HyH8898c2S6eF8hTPGhRqLC6UQrJrhw/fdguBeFG0cCrOFkbG8TCVURXOgxXaEV93vrFlHyxNGEvL10IcsLtvvI=",
),
( # - Sign P2WPKH Mainnet - Save to SD card
[
BUTTON_ENTER, # Confirm load from camera
BUTTON_ENTER, # Confirm to sign message
Expand Down

0 comments on commit 5ef6ba9

Please sign in to comment.