Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions node/rustchain_bft_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,17 @@ def _handle_pre_prepare(self, msg: ConsensusMessage) -> Optional[ConsensusMessag
logging.warning(f"PRE-PREPARE not from leader: {msg.node_id}")
return None

# Verify HMAC signature (matches pattern in handle_prepare/handle_commit)
sign_data = f"{MessageType.PRE_PREPARE.value}:{msg.view}:{epoch}:{msg.digest}:{msg.timestamp}"
if not self._verify_signature(msg.node_id, sign_data, msg.signature):
logging.warning(f"Invalid PRE-PREPARE signature from {msg.node_id}")
return None

# Check timestamp freshness
if abs(time.time() - msg.timestamp) > CONSENSUS_MESSAGE_TTL:
logging.warning(f"Stale PRE-PREPARE from {msg.node_id} (age={int(time.time()) - msg.timestamp}s)")
return None

# Validate proposal (hardware attestation checks)
if not self._validate_proposal(msg.proposal):
logging.warning(f"Invalid proposal for epoch {epoch}")
Expand Down
Loading