Module pair_code

Module pair_code 

Source
Expand description

Pair code authentication for phone number linking.

This module implements the alternative device linking protocol used when users enter an 8-character code on their phone instead of scanning a QR code.

§Protocol Overview

  1. Stage 1 (companion_hello): Client generates a code and sends encrypted ephemeral public key to server. Server returns a pairing ref.

  2. Stage 2 (companion_finish): When user enters code on phone, server sends notification with primary’s ephemeral key. Client performs DH and sends encrypted key bundle.

§Cryptography

  • Code: 5 random bytes → Crockford Base32 → 8 characters
  • Key derivation: PBKDF2-SHA256 with 131,072 iterations
  • Ephemeral encryption: AES-256-CTR
  • Bundle encryption: AES-256-GCM after HKDF key derivation

Structs§

PairCodeOptions
Options for pair code authentication.
PairCodeUtils
Core pair code cryptographic utilities.

Enums§

PairCodeError
Errors that can occur during pair code operations.
PairCodeState
State machine for pair code authentication flow.
PlatformId
Platform identifiers for companion devices. These match the DeviceProps.PlatformType protobuf enum.