3434from lean_spec .subspecs .ssz .hash import hash_tree_root
3535from lean_spec .subspecs .xmss .containers import PublicKey , SecretKey , Signature
3636from lean_spec .subspecs .xmss .interface import TEST_SIGNATURE_SCHEME , GeneralizedXmssScheme
37- from lean_spec .types import Uint64 , ValidatorIndex
37+ from lean_spec .types import Uint64
3838
3939if TYPE_CHECKING :
4040 from collections .abc import Mapping
@@ -87,7 +87,7 @@ def with_secret(self, secret: SecretKey) -> KeyPair:
8787
8888
8989@cache
90- def load_keys () -> dict [ValidatorIndex , KeyPair ]:
90+ def load_keys () -> dict [Uint64 , KeyPair ]:
9191 """
9292 Load pre-generated keys from disk (cached after first call).
9393
@@ -102,7 +102,7 @@ def load_keys() -> dict[ValidatorIndex, KeyPair]:
102102 f"Keys not found: { KEYS_FILE } \n Run: python -m consensus_testing.keys"
103103 )
104104 data = json .loads (KEYS_FILE .read_text ())
105- return {ValidatorIndex (i ): KeyPair .from_dict (kp ) for i , kp in enumerate (data )}
105+ return {Uint64 (i ): KeyPair .from_dict (kp ) for i , kp in enumerate (data )}
106106
107107
108108class XmssKeyManager :
@@ -119,8 +119,8 @@ class XmssKeyManager:
119119
120120 Examples:
121121 >>> mgr = XmssKeyManager()
122- >>> mgr[ValidatorIndex (0)] # Get key pair
123- >>> mgr.get_public_key(ValidatorIndex (1)) # Get public key only
122+ >>> mgr[Uint64 (0)] # Get key pair
123+ >>> mgr.get_public_key(Uint64 (1)) # Get public key only
124124 >>> mgr.sign_attestation(attestation) # Sign with auto-advancement
125125 """
126126
@@ -132,38 +132,38 @@ def __init__(
132132 """Initialize the manager with optional custom configuration."""
133133 self .max_slot = max_slot or DEFAULT_MAX_SLOT
134134 self .scheme = scheme
135- self ._state : dict [ValidatorIndex , KeyPair ] = {}
135+ self ._state : dict [Uint64 , KeyPair ] = {}
136136
137137 @property
138- def keys (self ) -> dict [ValidatorIndex , KeyPair ]:
138+ def keys (self ) -> dict [Uint64 , KeyPair ]:
139139 """Lazy access to immutable base keys."""
140140 return load_keys ()
141141
142- def __getitem__ (self , idx : ValidatorIndex ) -> KeyPair :
142+ def __getitem__ (self , idx : Uint64 ) -> KeyPair :
143143 """Get key pair, returning advanced state if available."""
144144 if idx in self ._state :
145145 return self ._state [idx ]
146146 if idx not in self .keys :
147147 raise KeyError (f"Validator { idx } not found (max: { len (self .keys ) - 1 } )" )
148148 return self .keys [idx ]
149149
150- def __contains__ (self , idx : ValidatorIndex ) -> bool :
150+ def __contains__ (self , idx : Uint64 ) -> bool :
151151 """Check if validator index exists."""
152152 return idx in self .keys
153153
154154 def __len__ (self ) -> int :
155155 """Number of available validators."""
156156 return len (self .keys )
157157
158- def __iter__ (self ) -> Iterator [ValidatorIndex ]:
158+ def __iter__ (self ) -> Iterator [Uint64 ]:
159159 """Iterate over validator indices."""
160160 return iter (self .keys )
161161
162- def get_public_key (self , idx : ValidatorIndex ) -> PublicKey :
162+ def get_public_key (self , idx : Uint64 ) -> PublicKey :
163163 """Get a validator's public key."""
164164 return self [idx ].public
165165
166- def get_all_public_keys (self ) -> dict [ValidatorIndex , PublicKey ]:
166+ def get_all_public_keys (self ) -> dict [Uint64 , PublicKey ]:
167167 """Get all public keys (from base keys, not advanced state)."""
168168 return {idx : kp .public for idx , kp in self .keys .items ()}
169169
0 commit comments