kord icon indicating copy to clipboard operation
kord copied to clipboard

Implement AES Encryption for Voice

Open viztea opened this issue 1 year ago • 4 comments

I tested voice send/receive for all 3 xsalsa20 poly1305 nonce strategies, all work as expected.

viztea avatar Dec 12 '23 11:12 viztea

i'm not very familiar with voice connections, can you explain a bit why this is needed?

lukellmann avatar Dec 20 '23 18:12 lukellmann

i'm not very familiar with voice connections, can you explain a bit why this is needed?

It kinda is and kinda isn't. I initially wanted to implement AES because it was faster than xsalsa but after doing a couple benchmarks it looks like xsalsa is a little bit more consistent and a couple microseconds faster.

This isn't really that surprising considering Kord Voice isn't the most efficient voice library, it doesn't help that Java relies on ByteBuffers to be performant.

viztea avatar Dec 20 '23 23:12 viztea

Functionality-wise LGTM. It likely will make adding/working with encryption a bit easier in the future too, if (or rather when) Discord decides to change things up.

lost-illusi0n avatar Dec 23 '23 10:12 lost-illusi0n

  • Implemented voice receive for AES, had to refactor a bit of the code to support passing of AEAD data.
  • Removed VoiceEncryption#supportsDecryption
  • Removed the sealed modifier for VoiceEncryption to allow external implementations (??)
  • Added kdoc to the VoiceEncryption interface.

Not sure if removing supportsDecryption is a good idea with it being an open interface now 🤷🏼

viztea avatar Jun 05 '24 08:06 viztea