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