Encryption and decryption are handled exclusively by the Telegram clients, which are open source. To encrypt each particular element of Telegram Passport, the client generates a random secret. The secret is a 32-byte number with the modulo 255 sum of bytes equal to 239.
