@@ -262,91 +262,6 @@ def on_attestation(
262262 }
263263 )
264264
265- def _validate_block_signatures (
266- self ,
267- signed_block_with_attestation : SignedBlockWithAttestation ,
268- ) -> bool :
269- """
270- Verify all XMSS signatures in a signed block.
271-
272- This method ensures that every attestation included in the block
273- (both on-chain attestations from the block body and the proposer's
274- own attestation) is properly signed by the claimed validator using
275- their registered XMSS public key.
276-
277- Args:
278- signed_block_with_attestation: Complete signed block containing:
279- - Block body with included attestations
280- - Proposer's attestation for this block
281- - XMSS signatures for all attestations (ordered)
282-
283- Returns:
284- True if all signatures are cryptographically valid.
285-
286- Raises:
287- AssertionError: If signature verification fails, including:
288- - Signature count mismatch
289- - Parent state not found in store
290- - Validator index out of range
291- - XMSS signature verification failure
292- """
293- # Unpack the signed block components
294- message = signed_block_with_attestation .message
295- block = message .block
296- signatures = signed_block_with_attestation .signature
297-
298- # Combine all attestations that need verification
299- #
300- # This creates a single list containing both:
301- # 1. Block body attestations (from other validators)
302- # 2. Proposer attestation (from the block producer)
303- all_attestations = list (block .body .attestations ) + [message .proposer_attestation ]
304-
305- # Verify signature count matches attestation count
306- #
307- # Each attestation must have exactly one corresponding signature.
308- #
309- # The ordering must be preserved:
310- # 1. Block body attestations,
311- # 2. The proposer attestation.
312- assert len (signatures ) == len (all_attestations ), (
313- "Number of signatures does not match number of attestations"
314- )
315-
316- # Retrieve parent state to access validator public keys
317- #
318- # We use the parent state because:
319- # - Validator set is determined at the parent block
320- # - Public keys must be registered before signing
321- # - State root is committed in the block header
322- parent_state = self .states .get (block .parent_root )
323- assert parent_state is not None , "Parent state not found"
324-
325- validators = parent_state .validators
326-
327- # Verify each attestation signature
328- for attestation , signature in zip (all_attestations , signatures , strict = True ):
329- # Identify the validator who created this attestation
330- validator_id = attestation .validator_id .as_int ()
331-
332- # Ensure validator exists in the active set
333- assert validator_id < len (validators ), "Validator index out of range"
334- validator = validators [validator_id ]
335-
336- # Verify the XMSS signature
337- #
338- # This cryptographically proves that:
339- # - The validator possesses the secret key for their public key
340- # - The attestation has not been tampered with
341- # - The signature was created at the correct epoch (slot)
342- assert signature .verify (
343- validator .get_pubkey (),
344- attestation .data .slot .as_int (),
345- bytes (hash_tree_root (attestation )),
346- ), "Attestation signature verification failed"
347-
348- return True
349-
350265 def _process_block_body_attestations (
351266 self , block : Block , signatures : BlockSignatures
352267 ) -> "Store" :
@@ -491,7 +406,7 @@ def on_block(self, signed_block_with_attestation: SignedBlockWithAttestation) ->
491406 )
492407
493408 # Validate cryptographic signatures
494- valid_signatures = self . _validate_block_signatures ( signed_block_with_attestation )
409+ valid_signatures = signed_block_with_attestation . verify_signatures ( parent_state )
495410
496411 # Execute state transition function to compute post-block state
497412 post_state = copy .deepcopy (parent_state ).state_transition (block , valid_signatures )
0 commit comments