EDA.Voice.Crypto.ChaCha (EDA v0.3.0)

Copy Markdown View Source

XChaCha20-Poly1305 encryption for Discord voice.

Uses the salchicha library (pure Elixir, no NIF). Implements the aead_xchacha20_poly1305_rtpsize mode.

Summary

Functions

Decrypts an XChaCha20-Poly1305 encrypted voice packet.

Encrypts an audio frame using XChaCha20-Poly1305.

Returns the nonce byte length for this encryption mode.

Functions

decrypt(packet, secret_key, header_size)

@spec decrypt(binary(), binary(), integer()) :: {:ok, binary()} | :error

Decrypts an XChaCha20-Poly1305 encrypted voice packet.

Returns {:ok, plaintext} or :error.

encrypt(frame, secret_key, nonce)

@spec encrypt(binary(), binary(), integer()) :: binary()

Encrypts an audio frame using XChaCha20-Poly1305.

The RTP header (first 12 bytes) is used as AAD and stays plaintext. A 4-byte nonce is appended to the packet.

nonce_length()

Returns the nonce byte length for this encryption mode.