Davey Protocol Implementation

0.1.5 · active · verified Thu Apr 16

Davey is a Python library that provides an implementation of the Discord Audio & Video End-to-End Encryption (DAVE) Protocol. It acts as a Python binding to a Rust-based implementation that leverages OpenMLS. The library is currently in beta (0.1.5) but actively maintained, with recent updates focusing on security fixes related to its internal OpenMLS dependency.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate a P256 signing key pair and a displayable verification code, which are core components of the DAVE protocol. Proper integration requires interaction with Discord's voice server APIs for session management and media handling.

from davey import SigningKeyPair, generate_p256_keypair, generate_displayable_code
import os

# Note: In a real application, keys and session data should be securely managed
# and integrated with Discord's voice gateway interactions. This is a minimal example.

# 1. Generate a P256 signing key pair
# This key pair is fundamental for establishing trust in DAVE sessions.
key_pair = generate_p256_keypair()
print(f"Generated Private Key (truncated): {key_pair.private.hex()[:10]}...")
print(f"Generated Public Key (truncated): {key_pair.public.hex()[:10]}...")

# 2. Generate a displayable code for user verification
# The 'data' parameter would typically be a unique session identifier or
# derived from shared secrets in a real DAVE handshake.
example_data_for_code = os.urandom(32) # Using random bytes for demonstration
display_code = generate_displayable_code(
    data=example_data_for_code,
    desired_length=12, # Total length of the code string
    group_size=4       # How many characters per group (e.g., AAAA-BBBB-CCCC)
)
print(f"Generated Displayable Code: {display_code}")

# Further steps would involve Discord API interaction to manage DAVE sessions,
# process proposals, and handle media encryption/decryption, which is highly
# application-specific and not directly covered by simple library calls here.
# Refer to the DAVE Protocol whitepaper and library's typings for advanced usage.

view raw JSON →