Real-time key generation and signing over BLE with mTLS tunnel
Device A (initiator) advertises its availability and Device B discovers it via BLE scanning.
UUID: 550e8400-e29b-41d4-a716-446655440000Name: "CB-MPC-[Device-A-UUID]"Flags: Connectable, LE General DiscoverableTX Power: -6 dBm (range ~20-30m)
BLE advertisement transmits every 20-100ms. Device B sees Device A within 1-2 seconds of scanning. No connection established yet—just discovery.
Device B initiates connection and both devices validate identity using a passphrase-protected QR code.
The QR code serves as a second verification channel. Even if BLE is compromised, the visual confirmation prevents man-in-the-middle attacks. Passphrase adds extra security layer.
Both devices generate ephemeral X.509 certificates and exchange them via short QR codes to establish mTLS tunnel.
QR codes allow out-of-band certificate verification. Certificates are ephemeral (short-lived) and regenerated for each session. Combined with session ID validation, this prevents certificate pinning attacks.
With exchanged certificates, both devices establish a mutually-authenticated TLS tunnel over BLE GATT.
mTLS (mutual TLS) ensures both devices authenticate each other before exchanging cryptographic material. The tunnel is now ready for sensitive protocol execution.
Both devices generate secret polynomials and commit to them without revealing the secrets.
P_A(x) = a₀ + a₁·x (mod p)a₀ = [secret] (Share 0)a₁ = [random slope]
P_B(x) = b₀ + b₁·x (mod p)b₀ = [secret] (Share 1)b₁ = [random slope]
Commitments are binding: they prove knowledge of the polynomial without revealing coefficients. Devices exchange commitments first to enable verification in subsequent rounds.
Each device evaluates its polynomial at the other device's index and sends the share over the encrypted tunnel.
Shares are sent encrypted over the already-secure TLS tunnel. Double encryption ensures that even if TLS is compromised, shares remain protected.
Both devices verify received shares against the commitments and finalize the shared public key.
share_A = b₀ + b₁·0share_A += a₀ (local)pk = EC_Multiply(share_A, G)
share_B = a₀ + a₁·1share_B += b₀ (local)pk = EC_Multiply(share_B, G)
Both devices now hold different shares (one from each device's polynomial evaluation), and both can independently verify that they hold correct shares. The combined shares form a valid 2-of-2 threshold key. Neither device holds the full key.
To sign a message, Device A initiates signing by sending a commitment to a random nonce.
Both devices commit to random nonces before seeing the message hash. This prevents certain attacks where a compromised device could force a predetermined signing result.
Both devices compute partial signatures using their shares and exchange them.
Partial signatures are computed in parallel. Both devices exchange their contributions and then combine them locally to produce the final signature.
Both devices combine the partial signatures into a final signature ready for broadcast.
sig · G = R + H(msg) · PKSignature finalization is local (Device B can also do it independently). Both devices verify the signature is valid before broadcasting it to the blockchain or network.
If BLE connection drops during protocol execution, both devices handle recovery gracefully.
| Scenario | Recovery Action | Time to Recover |
|---|---|---|
| Discovery phase disconnect | Device B rescans from scratch | 1-2 seconds |
| Pairing QR pending | Devices retain session ID, B rescans QR or manually re-enter passphrase | 3-5 seconds |
| During TLS handshake | Restart handshake, regenerate ephemeral certificates | ~1 second |
| During DKG Round 1 | Restart from Round 1 (commitments unchanged) | ~2 seconds |
| During DKG Round 2 (share exchange) | Resend shares (encrypted again with new session key) | ~1 second |
| During signing | Restart signing from commitment phase | ~1.5 seconds |
| Session timeout (5+ minutes idle) | Restart entire protocol from discovery | Full protocol (6-8s) |
BLE is inherently unreliable (best-effort, no guaranteed delivery). Both devices implement timeouts and exponential backoff for retries. After 3 failed attempts, they reset to discovery phase.
Real-world measurements for Bluetooth MultiPeer protocol execution on iOS devices.
| Phase | Duration | Latency Breakdown | Bytes Transferred |
|---|---|---|---|
| Discovery & Advertisement | 1-2s | BLE scan interval (1s) + first packet | ~100 bytes |
| Pairing handshake (with QR verification) | 3-5s | Session ID exchange (300ms) + user QR scan (2-4s) | ~200 bytes |
| TLS certificate exchange | 1-1.5s | QR 1 (500ms) + QR 2 (500ms) + TLS exchange (500ms) | ~2KB |
| mTLS tunnel setup | ~1s | TLS handshake with RTT latency | ~500 bytes |
| DKG Round 1 (commitments) | ~300ms | 2 RTTs (~150ms each) | ~256 bytes |
| DKG Round 2 (shares) | ~400ms | Share transmission + crypto | ~128 bytes |
| DKG Round 3 (verification) | ~300ms | Commitment verification + crypto | ~128 bytes |
| Total DKG | ~6-8 seconds | Discovery + pairing + TLS + DKG | ~4KB |
| Signing (single transaction) | ~1.5s | 3 RTTs (commitment, response, final) | ~512 bytes |
| Signing (bulk, 10 txs) | ~12s | Setup (6s) + 10 × signing (600ms) | ~7KB |
Range: 10-30m (clear line-of-sight)Latency: 20-100ms per round-tripThroughput: 110 KB/s (BLE 5)Reliability: ~99% (with retry)
QR: 1-2 minutes (user scans)BLE: 6-8 seconds (fully automatic)QR: 100% air-gap safeBLE: Requires devices in range
BLE multidevice operations are fast and reliable. The main overhead is initial discovery and TLS handshake. Once connected, subsequent signings reuse the tunnel for near-instant (1.5s) operations. QR transfer is slower but safer for offline/air-gapped scenarios.
| Use Case | BLE MultiPeer | QR Transfer | Recommendation |
|---|---|---|---|
| Initial key generation (2-of-2) | ✓ Real-time, 6-8s | ✓ Offline, 1-2 min | BLE (faster, live confirmation) |
| Key backup to second device | ✓ Periodic syncing | ✓ Air-gap capable | QR (one-time, secure) |
| Signing without internet | ✓ Devices in range | ✗ Not supported | BLE (only option) |
| Signing with confirmation from spouse | ✓ Instant feedback | ✗ Requires device in hand | BLE (better UX) |
| Emergency key recovery (offline, no devices) | ✗ Requires devices | ✓ From printed QR codes | QR (resilience) |
| Key share transfer to family member | ✓ Requires physical presence | ✓ Can be done remotely | QR (flexibility) |
| High-frequency signing (100+/day) | ✓ 1.5s per signature | ✗ 1-2 min per signature | BLE (practical) |
Use BLE when: Both devices are present, speed matters, and you need
real-time confirmation. Best for active signing workflows.
Use QR when: Air-gap security matters, devices are not both present,
or you're doing one-time key backup. Best for recovery and long-term security.