Module signal

Module signal 

Source
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

  1. Peer A creates an Offer with SDP data, chain ID, and target peer information
  2. The offer is transmitted through a signaling method (HTTP, WebSocket, etc.)
  3. Peer B receives and validates the offer (chain ID, peer ID, capacity)
  4. Peer B responds with a P2pConnectionResponse:
  5. If accepted, both peers use the SDP data to establish the WebRTC connection
  6. 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 and EncryptedAnswer
  • Connection Authentication: SDP hashes used for secure handshake verification

Structs§

Answer
WebRTC connection answer responding to an offer.
EncryptedAnswer
Encrypted WebRTC connection response for secure signaling.
EncryptedOffer
Encrypted WebRTC offer for secure signaling.
Offer
WebRTC connection offer containing SDP data and peer information.

Enums§

P2pConnectionResponse
Response to a WebRTC connection offer.
RejectionReason
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.