Back to News for Developers

# ELI5: CrypTen — Secure machine learning with PyTorch

July 19, 2021ByJessica Lin

Machine Learning (ML) researchers who would like to work with data that must be encrypted, either for legal reasons or to ensure privacy, historically have had very limited tools for building secure ML systems.

Because we shouldn’t expect ML researchers to also be cryptography experts, CrypTen was created to provide a framework to easily enable ML researchers to test models using secure computing methods.

To learn more, continue to read this blog or watch the embedded video, where we’ll explain it in a way that is easy to understand.

### Why CrypTen?

CrypTen is a research tool built upon the PyTorch API which allows researchers to experiment with ML models using secure computing techniques. It employs a cryptographic method called Multi-Party Computation (MPC).

Multi-Party Computation works by dividing the original data amongst multiple parties, none of whom can figure out the original data. Here is a simplified, two-party example. Let’s say the original data was the number 12. CrypTen may divide it into the numbers 5 and 7. Each party would perform the same function, multiplying the input by 3 in this example, and give their own outputs: 15 (= 5 x 3) and 21 (= 7 x 3). When the outputs are combined, it's the same result 36 (= 15 + 21) as if the original data went through the system (12 x 3 = 36), but because neither party knows the output of the other, neither can deduce the original data.
This method of encryption and data security is necessary for ML researchers working with data that has to stay secure, such as medical information or compensation, which contain sensitive information that cannot be shared due to privacy.

### Where is it used?

Facebook open sourced CrypTen in October of 2019, and it has allowed our researchers to build privacy-preserving contextual bandit models. These models help improve features such as Facebook’s ranking algorithm without revealing our users’ personal data.

To learn more about CrypTen, visit their website, which contains documentation and the installation script. CrypTen’s GitHub repo goes into more detail with examples and tutorials on how CrypTen integrates with PyTorch libraries and how to use the framework. Also be sure to join their Slack community to stay up to date with the latest information.

For a deep dive into the CrypTen protocols and designs, checkout this blog article or this paper.

If you have any further questions about CrypTen, let us know on our YouTube channel, or by tweeting at us. We always want to hear from you and hope you will find this open source project and the new ELI5 series useful.