discord_luau/dave

Discord Luau Dave - Implementation of the End to End encryption DAVE protocol for discord.

discord-luau

Implementation of Discord's DAVE end-to-end encryption protocol for voice and video streams.

Source: packages/dave

Installation

pesde add discord_luau/dave

Example

local Dave = require("./luau_packages/dave")

local session = Dave.Session.new("auth-session-id", function(source, reason)
    print("MLS failure from", source, ":", reason)
end)

session:init(1, channelGroupId, selfUserId)
session:setExternalSender(externalSenderBytes)

local keyPackage = session:getMarshalledKeyPackage()

voiceServer:sendKeyPackage(keyPackage)

local commit = session:processProposals(proposalsBytes, recognizedUserIds)

if commit then
    voiceServer:sendCommit(commit)
end

local result = session:processCommit(commitBytes)

if not result:isFailed() then
    local ratchet = session:getKeyRatchet(selfUserId)

    local encryptor = Dave.Encryptor.new()

    encryptor:assignSsrcToCodec(ssrc, Dave.sys.codec.opus)
    encryptor:setKeyRatchet(ratchet)

    local encrypted = encryptor:encrypt(Dave.sys.mediaType.audio, ssrc, rawFrame)
end

Full documentation at discordluau-docs.devcomp.workers.dev.

Contributing

Contributions are welcome via the repository at github.com/DiscordLuau/discord-luau.

License

This package is licensed under the MIT License.