Skip to main content

DAVE (Discord Audio/Video End-to-End Encryption) protocol library — pure data and state layer on rfc9420

Project description

sorrydave

Production-quality Python library for the DAVE (Discord Audio/Video End-to-End Encryption) protocol. It implements the protocol as a pure data-transformation and state-management layer on top of rfc9420 (PyMLS), with no I/O or networking: you pass in bytes (Voice Gateway opcodes, encoded media frames) and get back bytes (opcode payloads, encrypted/decrypted frames).

Features

  • MLS integration: Key packages, external sender handling, proposals, commit/welcome (opcodes 25–30), exporter-based sender keys
  • Sender key ratchet: Per-sender, per-epoch keys via MLS-Exporter + HKDF; cache for out-of-order decryption
  • Frame transform: Codec-aware encrypt/decrypt (OPUS, VP9, VP8, H264, H265, AV1), ULEB128, truncated AES128-GCM, DAVE footer (0xFAFA)
  • Identity: Pairwise fingerprint (scrypt) and displayable codes (45-digit / 30-digit)

Install

pip install -e .

Requires Python 3.9+, rfc9420, cryptography, and pycryptodome.

Minimal lifecycle

  1. Create a session: DaveSession(local_user_id=123456789).
  2. On select_protocol_ack (or prepare_epoch with epoch=1), call session.prepare_epoch(1) and send the returned bytes as opcode 26 (Key Package).
  3. On opcode 25 (External Sender Package), call session.handle_external_sender_package(package_bytes).
  4. On opcode 27 (Proposals), call session.handle_proposals(proposal_bytes); if it returns bytes, send them as opcode 28.
  5. On opcode 29 (Announce Commit), call session.handle_commit(transition_id, commit_bytes).
  6. On opcode 30 (Welcome), call session.handle_welcome(transition_id, welcome_bytes).
  7. On opcode 22 (Execute Transition), parse with parse_execute_transition(payload) to get transition_id, then call session.execute_transition(transition_id).
  8. Use session.get_encryptor().encrypt(frame, codec="OPUS") and session.get_decryptor(sender_id).decrypt(protocol_frame) for media.

Error recovery: On InvalidCommitError, send build_invalid_commit_welcome(transition_id) as opcode 31 to the voice gateway, then call session.prepare_epoch(1) and send the returned key package as opcode 26.

API overview

  • DaveSession: handle_external_sender_package, prepare_epoch, handle_proposals, handle_commit, handle_welcome, execute_transition, leave_group, get_encryptor, get_decryptor
  • FrameEncryptor.encrypt(encoded_frame, codec) / FrameDecryptor.decrypt(protocol_frame)
  • generate_fingerprint(local_id, local_pub, remote_id, remote_pub) → 45-digit string
  • displayable_code(data, total_digits, group_size) for epoch authenticator (e.g. 30 digits, group 5)

Scope

  • In scope: MLS state, ratchet, OPUS/VP9/VP8/H264/H265/AV1 codec handling, frame encrypt/decrypt, identity fingerprint, opcode 22 parse and opcode 31 build for transition and error recovery.
  • Out of scope: Voice Gateway WebSocket I/O, SFU silence packets, WebRTC depacketizer patches.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sorrydave-0.4.0.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sorrydave-0.4.0-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file sorrydave-0.4.0.tar.gz.

File metadata

  • Download URL: sorrydave-0.4.0.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sorrydave-0.4.0.tar.gz
Algorithm Hash digest
SHA256 007550c6ce6ae89c5be3c2dc7b2001adaddbb95629c9bfc0e5f1a5258b91f822
MD5 1c220eb57a7469bc3565409c3c877111
BLAKE2b-256 d8b57df96383c5821a488135160f2fcb4ba7e35ed075918d8f7625dbc9c5e3d6

See more details on using hashes here.

File details

Details for the file sorrydave-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: sorrydave-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 28.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for sorrydave-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fec90f37725404e7010d9eec98cbf2dd9cab97dddc97422b8dba5fbcaf0286bb
MD5 2c6021a7ecf296ddf3b95c1994d12a2a
BLAKE2b-256 17faf9799619e8ae46c6e807b00596ecd48503dd09a95c1c21bfc834d822e1e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page