@darius Mastodon actually used to have API endpoints for E2EE messaging https://github.com/mastodon/mastodon/pull/13820 which has been dropped due to the lack of clients: https://github.com/mastodon/mastodon/pull/14283. It maybe worthwhile looking into the code for how it looked like. (I'm afraid I'm not an expert :P