Expand description
WebRTC Signaling Data Structures
This module defines the core signaling data structures used in OpenMina’s WebRTC peer-to-peer communication system. It provides the message types for WebRTC connection establishment, including offers, answers, and connection responses.
§Overview
WebRTC requires a signaling mechanism to exchange connection metadata between peers before establishing a direct peer-to-peer connection. This module defines the data structures for:
- Offers: Initial connection requests containing SDP data and peer information
- Answers: Responses to offers containing SDP data and identity verification
- Connection Responses: Acceptance, rejection, and error handling for connections
- Encryption Support: Encrypted versions of signaling messages for security
§WebRTC Signaling Flow
- Peer A creates an
Offer
with SDP data, chain ID, and target peer information - The offer is transmitted through a signaling method (HTTP, WebSocket, etc.)
- Peer B receives and validates the offer (chain ID, peer ID, capacity)
- Peer B responds with a
P2pConnectionResponse
:P2pConnectionResponse::Accepted
with anAnswer
containing SDP dataP2pConnectionResponse::Rejected
with aRejectionReason
- Error variants for decryption failures or internal errors
- If accepted, both peers use the SDP data to establish the WebRTC connection
- Connection authentication occurs using
ConnectionAuth
derived from SDP hashes
§Security Features
- Chain ID Verification: Ensures peers are on the same blockchain network
- Identity Authentication: Uses public key cryptography to verify peer identity
- Encryption Support: Messages can be encrypted using
EncryptedOffer
andEncryptedAnswer
- Connection Authentication: SDP hashes used for secure handshake verification
Structs§
- Answer
- WebRTC connection answer responding to an offer.
- Encrypted
Answer - Encrypted WebRTC connection response for secure signaling.
- Encrypted
Offer - Encrypted WebRTC offer for secure signaling.
- Offer
- WebRTC connection offer containing SDP data and peer information.
Enums§
- P2pConnection
Response - Response to a WebRTC connection offer.
- Rejection
Reason - Reasons why a WebRTC connection offer might be rejected.
- Signal
- Union type for WebRTC signaling messages.
Functions§
- sdp_
hash 🔒 - Computes SHA-256 hash of SDP (Session Description Protocol) data.