1010 HashDigestList ,
1111 HashDigestVector ,
1212 HashTreeOpening ,
13+ Parameter ,
1314 PublicKey ,
1415 Signature ,
1516)
@@ -21,7 +22,7 @@ class TestPublicKey:
2122 def test_bytes_protocol (self ) -> None :
2223 """Test that PublicKey implements Python's bytes protocol."""
2324 root = HashDigestVector (data = [Fp (value = i ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
24- parameter = [Fp (value = i + 100 ) for i in range (TEST_CONFIG .PARAMETER_LEN )]
25+ parameter = Parameter ( data = [Fp (value = i + 100 ) for i in range (TEST_CONFIG .PARAMETER_LEN )])
2526 pk = PublicKey (root = root , parameter = parameter )
2627
2728 # Test __bytes__()
@@ -32,7 +33,7 @@ def test_bytes_protocol(self) -> None:
3233 def test_to_bytes_with_validation (self ) -> None :
3334 """Test that to_bytes validates field lengths."""
3435 root = HashDigestVector (data = [Fp (value = i ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
35- parameter = [Fp (value = i ) for i in range (TEST_CONFIG .PARAMETER_LEN )]
36+ parameter = Parameter ( data = [Fp (value = i ) for i in range (TEST_CONFIG .PARAMETER_LEN )])
3637 pk = PublicKey (root = root , parameter = parameter )
3738
3839 # Valid serialization
@@ -43,15 +44,14 @@ def test_to_bytes_with_validation(self) -> None:
4344 with pytest .raises (ValueError , match = "requires exactly" ):
4445 HashDigestVector (data = [Fp (value = 0 )] * 5 )
4546
46- # Invalid parameter length
47- invalid_pk = PublicKey (root = root , parameter = [Fp (value = 0 )] * 3 )
48- with pytest .raises (ValueError , match = "Invalid parameter length" ):
49- invalid_pk .to_bytes (TEST_CONFIG )
47+ # Invalid parameter length - Parameter validates length at construction
48+ with pytest .raises (ValueError , match = "requires exactly" ):
49+ Parameter (data = [Fp (value = 0 )] * 3 )
5050
5151 def test_roundtrip_test_config (self ) -> None :
5252 """Test serialization round-trip with TEST_CONFIG."""
5353 root = HashDigestVector (data = [Fp (value = i * 10 ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
54- parameter = [Fp (value = i * 20 ) for i in range (TEST_CONFIG .PARAMETER_LEN )]
54+ parameter = Parameter ( data = [Fp (value = i * 20 ) for i in range (TEST_CONFIG .PARAMETER_LEN )])
5555 original = PublicKey (root = root , parameter = parameter )
5656
5757 # Serialize and deserialize
@@ -65,7 +65,7 @@ def test_roundtrip_test_config(self) -> None:
6565 def test_roundtrip_prod_config (self ) -> None :
6666 """Test serialization round-trip with PROD_CONFIG."""
6767 root = HashDigestVector (data = [Fp (value = i ) for i in range (PROD_CONFIG .HASH_LEN_FE )])
68- parameter = [Fp (value = i + 1000 ) for i in range (PROD_CONFIG .PARAMETER_LEN )]
68+ parameter = Parameter ( data = [Fp (value = i + 1000 ) for i in range (PROD_CONFIG .PARAMETER_LEN )])
6969 original = PublicKey (root = root , parameter = parameter )
7070
7171 data = original .to_bytes (PROD_CONFIG )
@@ -86,7 +86,7 @@ def test_from_bytes_invalid_length(self) -> None:
8686 def test_serialization_format (self ) -> None :
8787 """Test that serialization follows the documented format: root || parameter."""
8888 root = HashDigestVector (data = [Fp (value = i ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
89- parameter = [Fp (value = i + 100 ) for i in range (TEST_CONFIG .PARAMETER_LEN )]
89+ parameter = Parameter ( data = [Fp (value = i + 100 ) for i in range (TEST_CONFIG .PARAMETER_LEN )])
9090 pk = PublicKey (root = root , parameter = parameter )
9191
9292 data = bytes (pk )
@@ -95,7 +95,7 @@ def test_serialization_format(self) -> None:
9595 from typing import List , cast
9696
9797 root_data = Fp .serialize_list (cast (List [Fp ], list (root .data )))
98- parameter_data = Fp .serialize_list (parameter )
98+ parameter_data = Fp .serialize_list (cast ( List [ Fp ], list ( parameter . data )) )
9999
100100 assert data == root_data + parameter_data
101101 assert data [: len (root_data )] == root_data
@@ -255,7 +255,7 @@ class TestSerializationProperties:
255255 def test_public_key_deterministic (self ) -> None :
256256 """Test that serialization is deterministic."""
257257 root = HashDigestVector (data = [Fp (value = i ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
258- parameter = [Fp (value = i ) for i in range (TEST_CONFIG .PARAMETER_LEN )]
258+ parameter = Parameter ( data = [Fp (value = i ) for i in range (TEST_CONFIG .PARAMETER_LEN )])
259259 pk = PublicKey (root = root , parameter = parameter )
260260
261261 # Serialize multiple times
@@ -291,7 +291,7 @@ def test_different_values_produce_different_bytes(self) -> None:
291291 """Test that different values produce different serializations."""
292292 root1 = HashDigestVector (data = [Fp (value = i ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
293293 root2 = HashDigestVector (data = [Fp (value = i + 1 ) for i in range (TEST_CONFIG .HASH_LEN_FE )])
294- parameter = [Fp (value = 0 )] * TEST_CONFIG .PARAMETER_LEN
294+ parameter = Parameter ( data = [Fp (value = 0 )] * TEST_CONFIG .PARAMETER_LEN )
295295
296296 pk1 = PublicKey (root = root1 , parameter = parameter )
297297 pk2 = PublicKey (root = root2 , parameter = parameter )
0 commit comments