{"id":13569332,"url":"https://github.com/facebookresearch/CrypTen","last_synced_at":"2025-04-04T05:32:18.655Z","repository":{"id":37611890,"uuid":"202443088","full_name":"facebookresearch/CrypTen","owner":"facebookresearch","description":"A framework for Privacy Preserving Machine Learning","archived":false,"fork":false,"pushed_at":"2024-10-19T03:44:21.000Z","size":14526,"stargazers_count":1538,"open_issues_count":89,"forks_count":280,"subscribers_count":43,"default_branch":"main","last_synced_at":"2024-10-29T15:05:24.266Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facebookresearch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-15T00:00:31.000Z","updated_at":"2024-10-27T13:12:30.000Z","dependencies_parsed_at":"2024-01-12T03:35:29.070Z","dependency_job_id":"5054a3e2-011d-4135-a0c6-1fd68a4ee813","html_url":"https://github.com/facebookresearch/CrypTen","commit_stats":{"total_commits":342,"total_committers":36,"mean_commits":9.5,"dds":0.6461988304093567,"last_synced_commit":"cc57fb18bea3025788b15b5bcd0464c326b14950"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookresearch%2FCrypTen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookresearch%2FCrypTen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookresearch%2FCrypTen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookresearch%2FCrypTen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facebookresearch","download_url":"https://codeload.github.com/facebookresearch/CrypTen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223100121,"owners_count":17087387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T14:00:38.659Z","updated_at":"2024-11-05T01:32:12.014Z","avatar_url":"https://github.com/facebookresearch.png","language":"Python","funding_links":[],"categories":["Python","Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Pytorch \u0026 related libraries","隐私机器学习","其他_机器学习与深度学习","隐私新技术","1.4 Courses","PyTorch Tools, Libraries, and Frameworks","Framework","Topics","Software","Awesome Privacy Engineering [![Awesome](https://awesome.re/badge.svg)](https://awesome.re)"],"sub_categories":["Other libraries｜其他库:","Other libraries:","隐私相关领域法规/条例","2022","System","Frameworks","Retired software","Differential Privacy and Federated Learning"],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"70%\" src=\"https://raw.githubusercontent.com/facebookresearch/CrypTen/master/docs/_static/img/CrypTen_Identity_Horizontal_Lockup_01_FullColor.png\" alt=\"CrypTen logo\" /\u003e\u003c/p\u003e\n\n[![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat\u0026labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/facebookresearch/CrypTen/blob/master/LICENSE) [![CircleCI](https://circleci.com/gh/facebookresearch/CrypTen.svg?style=shield)](https://circleci.com/gh/facebookresearch/CrypTen/tree/master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/facebookresearch/CrypTen/blob/master/CONTRIBUTING.md)\n\n--------------------------------------------------------------------------------\n\nCrypTen is a framework for Privacy Preserving Machine Learning built on PyTorch.\nIts goal is to make secure computing techniques accessible to Machine Learning practitioners.\nIt currently implements [Secure Multiparty Computation](https://en.wikipedia.org/wiki/Secure_multi-party_computation)\nas its secure computing backend and offers three main benefits to ML researchers:\n\n1. It is machine learning first. The framework presents the protocols via a `CrypTensor`\n   object that looks and feels exactly like a PyTorch `Tensor`. This allows the user to use\n   automatic differentiation and neural network modules akin to those in PyTorch.\n\n2. CrypTen is library-based. It implements a tensor library just as PyTorch does.\n   This makes it easier for practitioners to debug, experiment on, and explore ML models.\n\n3. The framework is built with real-world challenges in mind. CrypTen does not scale back or\n   oversimplify the implementation of the secure protocols.\n\nHere is a bit of CrypTen code that encrypts and decrypts tensors and adds them\n\n```python\nimport torch\nimport crypten\n\ncrypten.init()\n\nx = torch.tensor([1.0, 2.0, 3.0])\nx_enc = crypten.cryptensor(x) # encrypt\n\nx_dec = x_enc.get_plain_text() # decrypt\n\ny_enc = crypten.cryptensor([2.0, 3.0, 4.0])\nsum_xy = x_enc + y_enc # add encrypted tensors\nsum_xy_dec = sum_xy.get_plain_text() # decrypt sum\n```\n\nIt is currently not production ready and its main use is as a research framework.\n\n## Installing CrypTen\n\nCrypTen currently runs on Linux and Mac with Python 3.7.\nWe also support computation on GPUs.\nWindows **is not** supported.\n\n_For Linux or Mac_\n```bash\npip install crypten\n```\n\nIf you want to run the examples in the `examples` directory, you should also do the following\n```bash\npip install -r requirements.examples.txt\n```\n\n## Examples\nTo run the examples in the `examples` directory, you additionally need to clone the repo and\n\n```bash\npip install -r requirements.examples.txt\n```\n\nWe provide examples covering a range of models in the `examples` directory\n\n1. The linear SVM example, `mpc_linear_svm`, generates random data and trains a\n  SVM classifier on encrypted data.\n2. The LeNet example, `mpc_cifar`, trains an adaptation of LeNet on CIFAR in\n  cleartext and encrypts the model and data for inference.\n3. The TFE benchmark example, `tfe_benchmarks`, trains three different network\n  architectures on MNIST in cleartext, and encrypts the trained model and data\n  for inference.\n4. The bandits example, `bandits`, trains a contextual bandits model on\n  encrypted data (MNIST).\n5. The imagenet example, `mpc_imagenet`, performs inference on pretrained\n  models from `torchvision`.\n\nFor examples that train in cleartext, we also provide pre-trained models in\ncleartext in the `model` subdirectory of each example subdirectory.\n\nYou can check all example specific command line options by doing the following;\nshown here for `tfe_benchmarks`:\n\n```bash\npython examples/tfe_benchmarks/launcher.py --help\n```\n\n## How CrypTen works\n\nWe have a set of tutorials in the `tutorials` directory to show how\nCrypTen works. These are presented as Jupyter notebooks so please install\nthe following in your conda environment\n\n```bash\nconda install ipython jupyter\npip install -r requirements.examples.txt\n```\n\n1. `Introduction.ipynb` - an introduction to Secure Multiparty Compute; CrypTen's\n   underlying secure computing protocol; use cases we are trying to solve and the\n   threat model we assume.\n2. `Tutorial_1_Basics_of_CrypTen_Tensors.ipynb` - introduces `CrypTensor`, CrypTen's\n   encrypted tensor object, and shows how to use it to do various operations on\n   this object.\n3. `Tutorial_2_Inside_CrypTensors.ipynb` – delves deeper into `CrypTensor` to show\n   the inner workings; specifically how `CrypTensor` uses `MPCTensor` for its\n   backend and the two different kind of _sharings_, arithmetic and binary, are\n   used for two different kind of functions. It also shows CrypTen's\n   [MPI](https://en.wikipedia.org/wiki/Message_Passing_Interface)-inspired\n   programming model.\n4. `Tutorial_3_Introduction_to_Access_Control.ipynb` - shows how to train a linear\n   model using CrypTen and shows various scenarios of data labeling, feature\n   aggregation, dataset augmentation and model hiding where this is applicable.\n5. `Tutorial_4_Classification_with_Encrypted_Neural_Networks.ipynb` – shows how\n   CrypTen can load a pre-trained PyTorch model, encrypt it and then do inference\n   on encrypted data.\n6. `Tutorial_5_Under_the_hood_of_Encrypted_Networks.ipynb` - examines how CrypTen\n   loads PyTorch models, how they are encrypted and how data moves through a multilayer\n   network.\n7. `Tutorial_6_CrypTen_on_AWS_instances.ipynb` - shows how to use `scrips/aws_launcher.py`\n   to launch our examples on AWS. It can also work with your code written in CrypTen.\n8. `Tutorial_7_Training_an_Encrypted_Neural_Network.ipynb` - introduces the\n   automatic differentiation functionality of `CrypTensor`. This functionality\n   makes it easy to train neural networks in CrypTen.\n\n\n## Documentation and citing\nCrypTen is documented [here](https://crypten.readthedocs.io/en/latest/).\n\nThe protocols and design protocols implemented in CrypTen are described in [this paper](https://arxiv.org/pdf/2109.00984.pdf). If you want to cite CrypTen in your papers (much appreciated!), you can cite it as follows:\n```\n@inproceedings{crypten2020,\n  author={B. Knott and S. Venkataraman and A.Y. Hannun and S. Sengupta and M. Ibrahim and L.J.P. van der Maaten},\n  title={CrypTen: Secure Multi-Party Computation Meets Machine Learning},\n  booktitle={arXiv 2109.00984},\n  year={2021},\n}\n```\n\n## Join the CrypTen community\nPlease contact [us](mailto:ssengupta@fb.com) to join the CrypTen community on [Slack](https://cryptensor.slack.com)\n\nSee the [CONTRIBUTING](CONTRIBUTING.md) file for how to help out.\n\n## License\nCrypTen is MIT licensed, as found in the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookresearch%2FCrypTen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacebookresearch%2FCrypTen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebookresearch%2FCrypTen/lists"}