They do publish https://telegram.org/blog/tdlib so couldn't a client author just do shared key encryption or something?