@@ -856,6 +856,22 @@ def test_hybrid_decoding_with_blocked_format(self):
856856
857857 self .assertIn ("Invalid X9.62 encoding" , str (exp .exception ))
858858
859+ def test_hybrid_decoding_with_inconsistent_encoding_and_no_validation (self ):
860+ sk = SigningKey .from_secret_exponent (123456789 )
861+ vk = sk .verifying_key
862+
863+ enc = vk .to_string ("hybrid" )
864+ self .assertEqual (enc [:1 ], b'\x06 ' )
865+ enc = b'\x07 ' + enc [1 :]
866+
867+ b = VerifyingKey .from_string (
868+ enc ,
869+ valid_encodings = ("hybrid" ,),
870+ validate_point = False
871+ )
872+
873+ self .assertEqual (vk , b )
874+
859875 def test_compressed_decoding_with_blocked_format (self ):
860876 enc = (
861877 b"\x02 "
@@ -898,6 +914,17 @@ def test_decoding_with_inconsistent_hybrid(self):
898914 with self .assertRaises (MalformedPointError ):
899915 VerifyingKey .from_string (b"\x07 " + enc )
900916
917+ def test_decoding_with_inconsistent_hybrid_odd_point (self ):
918+ sk = SigningKey .from_secret_exponent (123456791 )
919+ vk = sk .verifying_key
920+
921+ enc = vk .to_string ("hybrid" )
922+ self .assertEqual (enc [:1 ], b'\x07 ' )
923+ enc = b'\x06 ' + enc [1 :]
924+
925+ with self .assertRaises (MalformedPointError ):
926+ b = VerifyingKey .from_string (enc , valid_encodings = ("hybrid" ,))
927+
901928 def test_decoding_with_point_not_on_curve (self ):
902929 enc = (
903930 b"\x0c \xe0 \x1d \xe0 d\x1c \x8e S\x8a \xc0 \x9e K\xa8 x !\xd5 \xc2 \xc3 "
0 commit comments