@@ -72,8 +72,18 @@ def setUp(self):
7272 b"\xd9 Y\xf2 \x81 [\x16 \xf8 \x17 \x98 H:\xda w&\xa3 \xc4 e]\xa4 \xfb \xfc \x0e \x11 "
7373 b"\x08 \xa8 \xfd \x17 \xb4 H\xa6 \x85 T\x19 \x9c G\xd0 \x8f \xfb \x10 \xd4 \xb8 "
7474 )
75+
76+ self .public_key_xonly = (
77+ "1baf348d377cf9a73b39807b051bd7e6921bd9e5f4e78e5640803f1fd9b90501"
78+ )
79+ self .public_key_xonly_bytes = (
80+ b"\x1b \xaf 4\x8d 7|\xf9 \xa7 ;9\x80 {\x05 \x1b \xd7 \xe6 \x92 \x1b \xd9 \xe5 \xf4 \xe7 "
81+ b"\x8e V@\x80 ?\x1f \xd9 \xb9 \x05 \x01 6\xee 2\x0c \xfa \xb9 \xaa \x93 \xb5 \xbf \x82 "
82+ b",'\xa9 \xe7 \xd5 \xc3 cN\xb9 \xad ~rh\xc5 \xb0 \x14 \xae Y\xa0 Y\xc4 "
83+ )
84+
7585 self .address = "1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm"
76-
86+
7787 # Message public key recovery tests
7888 self .valid_message = "Hello, Bitcoin!"
7989 # 65-byte Bitcoin signature (1-byte recovery ID + 64-byte ECDSA signature)
@@ -87,6 +97,10 @@ def test_pubkey_creation(self):
8797 pub2 = PublicKey (self .public_key_hexc )
8898 self .assertEqual (pub2 .to_bytes (), self .public_key_bytes )
8999
100+ def test_pubkey_creation_xonly (self ):
101+ xonly = PublicKey (self .public_key_xonly )
102+ self .assertEqual (xonly .to_bytes (), self .public_key_xonly_bytes )
103+
90104 def test_pubkey_uncompressed (self ):
91105 pub = PublicKey (self .public_key_hex )
92106 self .assertEqual (pub .to_hex (compressed = False ), self .public_key_hex )
@@ -106,7 +120,7 @@ def test_pubkey_to_hash160(self):
106120 def test_pubkey_x_only (self ):
107121 pub = PublicKey (self .public_key_hex )
108122 self .assertEqual (pub .to_x_only_hex (), self .public_key_hex [2 :66 ])
109-
123+
110124 #Tests for PublicKey recovery from message and signature
111125 def test_public_key_recovery_valid (self ):
112126 """Test successful public key recovery from a valid message and signature"""
@@ -351,6 +365,6 @@ def test_legacy_address_from_mnemonic(self):
351365 hdw .from_path ("m/44'/1'/0'/0/3" )
352366 address = hdw .get_private_key ().get_public_key ().get_address ()
353367 self .assertTrue (address .to_string (), self .legacy_address_m_44_1h_0h_0_3 )
354-
368+
355369if __name__ == "__main__" :
356370 unittest .main ()
0 commit comments