Decryptor
Decrypts incoming media frames using the DAVE protocol.
A Decryptor is created per remote participant stream. When the MLS group transitions
to a new epoch, call transitionToKeyRatchet with the ratchet derived for that
participant; the decryptor will maintain both the old and new ratchets for a short
overlap window to absorb in-flight frames. Before the group is ready, call
transitionToPassthroughMode(true) so frames pass through without attempting
decryption.
local dec = Dave.Decryptor.new()
dec:transitionToKeyRatchet(session:getKeyRatchet(remoteUserId))
local plaintext = dec:decrypt(Dave.sys.mediaType.audio, encryptedFrame)Summary
Properties
Decryptor.handle :: Sys.DecryptorHandleMethods
Decryptor:transitionToKeyRatchet(keyRatchet: KeyRatchet.KeyRatchet)Decryptor:transitionToPassthroughMode(enabled: boolean)Decryptor:getMaxPlaintextByteSize(mediaType: number, encryptedFrameSize: number) → numberDecryptor:decrypt(mediaType: number, encryptedFrame: buffer) → bufferDecryptor:getStats(mediaType: number) → DecryptorStatsDecryptor:destroy()Functions
Decryptor.new() → DecryptorProperties
Section titled “Properties”handle
Section titled “handle”Methods
Section titled “Methods”transitionToKeyRatchet
Section titled “transitionToKeyRatchet”Decryptor : transitionToKeyRatchet ( keyRatchet ) -> ()
Transitions the decryptor to use a new key ratchet, typically called after each MLS
epoch change. The library retains both the old and new ratchets for a short overlap
window so in-flight frames encrypted under the previous epoch are still accepted.
Obtain a ratchet from Session:getKeyRatchet(remoteUserId).
Parameters
| keyRatchet: KeyRatchet |
transitionToPassthroughMode
Section titled “transitionToPassthroughMode”Decryptor : transitionToPassthroughMode ( enabled ) -> ()
Transitions the decryptor into or out of passthrough mode. When enabled, frames are
returned from decrypt unchanged without any key material being consumed. Use this
while the MLS group is not yet established.
Parameters
| enabled: boolean |
getMaxPlaintextByteSize
Section titled “getMaxPlaintextByteSize”Decryptor : getMaxPlaintextByteSize ( mediaType , encryptedFrameSize ) -> number
Returns the maximum number of plaintext bytes that decrypt may produce for an
encrypted frame of encryptedFrameSize bytes on mediaType. Useful for
pre-allocating receive buffers.
decrypt
Section titled “decrypt”Decryptor : decrypt ( mediaType , encryptedFrame ) -> buffer
Decrypts encryptedFrame and returns the plaintext as a new buffer. Logs an error
and halts the calling coroutine on any non-success result code (missing ratchet,
invalid nonce, etc.).
Parameters
| mediaType: number | |
| encryptedFrame: buffer |
Returns
| buffer |
getStats
Section titled “getStats”Decryptor : getStats ( mediaType ) -> DecryptorStats
Returns a snapshot of decryption statistics for mediaType. Statistics are cumulative
since the decryptor was created. mediaType should be a value from Dave.sys.mediaType.
Parameters
| mediaType: number |
Returns
| DecryptorStats |
destroy
Section titled “destroy”Decryptor : destroy ( ) -> ()
Destroys the decryptor and frees all associated libdave resources. The decryptor must not be used after this call.
Functions
Section titled “Functions”Decryptor . new ( ) -> Decryptor
Constructs a new Decryptor.
Returns
| Decryptor |