broadcast - Echo Broadcast Protocol¶
Overview¶
The broadcast module implements Bracha’s reliable broadcast protocol for
Byzantine fault tolerant message delivery in multi-party computation (MPC) protocols.
This is a critical component for ensuring consistency in distributed cryptographic
protocols like DKLS23 threshold ECDSA.
The echo broadcast protocol ensures that if any honest party accepts a message from a sender, all honest parties accept the same message. This prevents equivocation attacks where a malicious sender attempts to send different messages to different recipients.
Key Features¶
Byzantine Fault Tolerance: Tolerates up to f = (n-1)/3 Byzantine (malicious) parties
Consistency Guarantee: All honest parties receive identical messages from each sender
Equivocation Detection: Detects and reports when a sender sends conflicting messages
Hash-Based Verification: Uses SHA-256 for efficient message comparison across parties
Flexible Message Types: Supports bytes, dictionaries, and any serializable Python objects
Use Cases¶
Distributed Key Generation (DKG): Ensures all parties receive consistent commitments during the DKLS23 DKG protocol
Threshold Signature Protocols: Verifies broadcast consistency in presigning rounds
Secure Multi-Party Computation: General-purpose broadcast for any MPC protocol requiring agreement on messages
Example Usage¶
from charm.toolbox.broadcast import EchoBroadcast
# Initialize for 5 parties with default fault tolerance
broadcast = EchoBroadcast(num_parties=5)
# Party 1 creates a broadcast message
msg = broadcast.create_broadcast_message(party_id=1, message={'value': 42})
# Other parties process echoes and verify consistency
echo_state = {}
for verifier_id in [1, 2, 3, 4, 5]:
echo_state = broadcast.process_echo(
verifier_id=verifier_id,
sender_id=1,
msg_hash=msg['hash'],
echo_state=echo_state
)
# Verify all parties received consistent messages
is_consistent = broadcast.verify_consistency(echo_state) # Returns True
API Reference¶
Echo Broadcast Protocol Implementation
Implements Bracha’s reliable broadcast protocol for Byzantine fault tolerance. Ensures all honest parties receive the same message from each sender.
- Authors:
Elton de Souza
- Date:
01/2026
- class broadcast.EchoBroadcast(num_parties: int, fault_threshold: int | None = None)[source]¶
Bases:
objectEcho broadcast protocol for Byzantine fault tolerant message delivery.
Ensures that if any honest party accepts a message from a sender, all honest parties accept the same message (consistency).
This implements echo broadcast verification as used in distributed key generation (DKG) protocols to prevent equivocation attacks where a malicious sender sends different messages to different recipients.
- Attributes:
n: Number of parties in the protocol f: Byzantine fault threshold (default: (n-1)//3)
- Example:
>>> broadcast = EchoBroadcast(num_parties=5) >>> msg = broadcast.create_broadcast_message(1, {'value': 42}) >>> 'sender_id' in msg and 'hash' in msg True
- compute_message_hash(message: Any) bytes[source]¶
Compute hash of a message for echo comparison.
Parameters¶
- messageAny
The message to hash. Can be bytes, dict, or any serializable type.
Returns¶
- bytes
SHA-256 hash of the message
- create_broadcast_message(party_id: int, message: Any) Dict[str, Any][source]¶
Create a broadcast message with its hash for echo verification.
Parameters¶
- party_idint
The sender’s party identifier
- messageAny
The message content to broadcast
Returns¶
- dict
Broadcast message containing: - sender_id: The sender’s party ID - message: The original message content - hash: SHA-256 hash of the message
- process_echo(verifier_id: int, sender_id: int, msg_hash: bytes, echo_state: Dict[int, Dict[int, bytes]] | None = None) Dict[int, Dict[int, bytes]][source]¶
Process an echo from another party.
Records what message hash a verifier claims to have received from a sender.
Parameters¶
- verifier_idint
ID of the party reporting what they received
- sender_idint
ID of the original sender
- msg_hashbytes
Hash of the message the verifier claims to have received
- echo_statedict, optional
Current echo state to update. If None, creates new state.
Returns¶
- dict
Updated echo state: {verifier_id: {sender_id: msg_hash}}
- verify_consistency(echo_msgs: Dict[int, Dict[int, bytes]]) bool[source]¶
Verify all parties received consistent messages from each sender.
Checks that for each sender, all verifiers report the same message hash. If any sender sent different messages to different recipients (equivocation), raises ValueError with details about the inconsistency.
Parameters¶
- echo_msgsdict
Echo state mapping {verifier_id: {sender_id: msg_hash}}
Returns¶
- bool
True if all messages are consistent
Raises¶
- ValueError
If broadcast inconsistency is detected, with details about which sender sent different messages to different recipients
- Example:
>>> broadcast = EchoBroadcast(num_parties=3) >>> # All parties received same hash from sender 1 >>> echo_msgs = {1: {1: b'hash1'}, 2: {1: b'hash1'}, 3: {1: b'hash1'}} >>> broadcast.verify_consistency(echo_msgs) True