{"id":13689817,"url":"https://github.com/LatticeX-Foundation/Rosetta","last_synced_at":"2025-05-02T06:31:35.184Z","repository":{"id":37104055,"uuid":"254110428","full_name":"LatticeX-Foundation/Rosetta","owner":"LatticeX-Foundation","description":"A Privacy-Preserving Framework Based on TensorFlow","archived":false,"fork":false,"pushed_at":"2022-04-26T02:21:22.000Z","size":17583,"stargazers_count":556,"open_issues_count":6,"forks_count":111,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-15T05:04:50.946Z","etag":null,"topics":["federated-learning","homomorphic-encryption","privacy-preserving-machine-learning","secure-computation","secure-multiparty-computation","zero-knowledge-proofs"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LatticeX-Foundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING.LESSER","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-08T14:25:50.000Z","updated_at":"2025-04-05T12:57:32.000Z","dependencies_parsed_at":"2022-07-12T15:31:20.188Z","dependency_job_id":null,"html_url":"https://github.com/LatticeX-Foundation/Rosetta","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LatticeX-Foundation%2FRosetta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LatticeX-Foundation%2FRosetta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LatticeX-Foundation%2FRosetta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LatticeX-Foundation%2FRosetta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LatticeX-Foundation","download_url":"https://codeload.github.com/LatticeX-Foundation/Rosetta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251998471,"owners_count":21677987,"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":["federated-learning","homomorphic-encryption","privacy-preserving-machine-learning","secure-computation","secure-multiparty-computation","zero-knowledge-proofs"],"created_at":"2024-08-02T16:00:27.906Z","updated_at":"2025-05-02T06:31:30.195Z","avatar_url":"https://github.com/LatticeX-Foundation.png","language":"C++","funding_links":[],"categories":["Open-source FL Framework","Privacy and Security","C++","Applications","federated learning framework","4.2 FHE Applications","Framework"],"sub_categories":["Vertical FL","table","2022"],"readme":"![LOGO](https://github.com/LatticeX-Foundation/Rosetta/blob/master/doc/_static/figs/LOGO.png)\n\n[![github license](https://img.shields.io/badge/license-LGPLv3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0.en.html)\n\n[![Build-and-Test](https://github.com/LatticeX-Foundation/Rosetta/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/LatticeX-Foundation/Rosetta/actions/workflows/build-and-test.yml) [![Performance Test](https://github.com/LatticeX-Foundation/Rosetta/actions/workflows/performance-test.yml/badge.svg)](https://github.com/LatticeX-Foundation/Rosetta/actions/workflows/performance-test.yml)\n\n------\n\n[中文版](./README_CN.md)\n\n\n## Overview\n\nRosetta is a privacy-preserving framework based on [TensorFlow](https://www.tensorflow.org). It integrates with mainstream privacy-preserving computation technologies, including cryptography, federated learning and trusted execution environment. Rosetta aims to provide privacy-preserving solutions for artificial intelligence without requiring expertise in cryptography, federated learning and trusted execution environment. Rosetta reuses the APIs of TensorFlow and allows to transfer traditional TensorFlow codes into a privacy-preserving manner with minimal changes. E.g., just add the following line.\n\n```python\nimport latticex.rosetta\n```\n\nThe current version integrates the secure multi-party computation protocols for 3 parties. The underlying protocols are [SecureNN](https://eprint.iacr.org/2018/442.pdf) and Helix. They are secure in the semi-honest model with honest majority.\n\nRosetta has also integrated an efficient zero-knowledge proof protocol, [Mystique](https://eprint.iacr.org/2021/730), for secure inference tasks of sophisticated AI models, such as ResNet. Please refer to [example](example/zkp_resnet/README.md) for its usage.\n\n\n## Installation\n\nFor now, Rosetta runs on Ubuntu 18.04, and is based on TensorFlow 1.14 with CPUs (Windows OS is not currently supported yet). You can install Rosetta as follows.\n\nFirst, please check that your local system meets our [base environment requirement](doc/DEPLOYMENT.md#rosetta-deployment-guide).\n\nThen install the native TensorFlow with the following codes. Note that you could also install it from source code, check [here](doc/TENSORFLOW_INSTALL.md) for details.\n\n```bash\n# install tensorflow\npip3 install tensorflow==1.14.0\n```\n\nAnd then build and install Rosetta with our all-in-one script as follows.\n\n```bash\n# clone rosetta git repository\ngit clone --recurse https://github.com/LatticeX-Foundation/Rosetta.git\n\nor (Note: due to recent github change of personal token, SSH is still working, please refer to github for latest updates)\ngit clone git@github.com:LatticeX-Foundation/Rosetta.git\ngit submodule update --init --recursive\ncd Rosetta\n# compile, install. You may check more compilation options by checking `rosetta.sh --help`\n./rosetta.sh compile --enable-protocol-mpc-securenn; ./rosetta.sh install\n```\n\nBefore running your program, you should configure with your network topology so that a distributed network can be established for parties to communicate with each other.\n\n\u003cimg src='doc/_static/figs/deployment.png'  width = \"667\" height = \"400\" align=\"middle\"/\u003e\n\nYou could use an example to check everything runs OK. Please refer to [Deployment Guide](doc/DEPLOYMENT.md) for the detailed steps of installation, configuration and deployment of Rosetta.\n\n## Usage\n\nThe following is a toy [example](example/tutorials/code/rosetta_demo.py) for matrix multiplication using Rosetta.\n\nIn this example, we assume that three guys want to get the product of their private matrix, while do not want others to know what they hold. For brevity, we call them P0, P1 and P2.\n\nWith Rosetta, each of them can run the following script, from which you can see that only a small amount of codes are needed besides the native TensorFlow lines.\n\n```python\n#!/usr/bin/env python3\n\n# Import rosetta package\nimport latticex.rosetta as rtt\nimport tensorflow as tf\n\n# You can activate a backend protocol, here we use SecureNN\nrtt.activate(\"SecureNN\")\n\n# Get private data from every party\nmatrix_a = tf.Variable(rtt.private_console_input(0, shape=(3, 2)))\nmatrix_b = tf.Variable(rtt.private_console_input(1, shape=(2, 1)))\nmatrix_c = tf.Variable(rtt.private_console_input(2, shape=(1, 4)))\n\n# Just use the native tf.matmul operation.\ncipher_result = tf.matmul(tf.matmul(matrix_a, matrix_b), matrix_c)\n\n# Start execution\nwith tf.Session() as sess:\n    sess.run(tf.global_variables_initializer())\n    # Take a glance at the ciphertext\n    cipher_result = sess.run(cipher_result)\n    print('local ciphertext result:', cipher_result)\n    # Set only party a and c can get plain result\n    a_and_c_can_get_plain = 0b101 \n    # Get the result of Rosetta matmul\n    print('plaintext matmul result:', sess.run(rtt.SecureReveal(cipher_result, a_and_c_can_get_plain)))\n```\n\nTo run this jointly, after configuring networks, the three guys can run the following command-line respectively:\n\n```bash\npython rosetta_demo.py --party_id=0\n```\n\n,\n\n```bash\npython rosetta_demo.py --party_id=1\n```\n\nand\n\n```bash\npython rosetta_demo.py --party_id=2\n```\n\nThen each party will be prompted to input his private matrix, for example P0 may have:\n\n\u003e 2021-10-22 09:46:08.571|info|Rosetta: Protocol [SecureNN] backend initialization succeeded! task: , node id: P0\n\u003e \n\u003e please input the private data (float or integer, 6 items, separated by space): 2 3 1 7 6 2\n\nwhile P1 has:\n\n\u003e 2021-10-22 09:46:08.571|info|Rosetta: Protocol [SecureNN] backend initialization succeeded! task: , node id: P1\n\u003e\n\u003e please input the private data (float or integer, 2 items, separated by space): 1 2\n\nwhile P2 has:\n\n\u003e 2021-10-22 09:46:08.571|info|Rosetta: Protocol [SecureNN] backend initialization succeeded! task: , node id: P2\n\u003e\n\u003e please input the private data (float or integer, 4 items, separated by space): 2 1 4 3\n\nNote that input from console like this is purely for pedagogical purpose in this toy example. See our [Doc](doc/API_DOC.md) for production-ready data APIs.\n\nAt the end, P0 and P2 will get the plaintext output while P1 dose not, just as required. Specifically, P0 and P2 may have:\n\n\u003e plaintext matmul result: [[b'16.000000' b'8.000000' b'32.000000' b'24.000000']\n\u003e\n\u003e  [b'30.000000' b'15.000000' b'60.000000' b'45.000000']\n\u003e\n\u003e  [b'20.000000' b'10.000000' b'40.000000' b'30.000000']]\n\u003e\n\u003e 2021-10-22 09:49:58.888|info|Rosetta: Protocol [SecureNN] backend has been released.\n\nwhile P1 has:\n\n\u003e plaintext matmul result: [[b'0.000000' b'0.000000' b'0.000000' b'0.000000']\n\u003e\n\u003e  [b'0.000000' b'0.000000' b'0.000000' b'0.000000']\n\u003e\n\u003e  [b'0.000000' b'0.000000' b'0.000000' b'0.000000']]\n\u003e\n\u003e 2021-10-22 09:49:58.887|info|Rosetta: Protocol [SecureNN] backend has been released.\n\nThat's all, you can see Rosetta is so easy to use.\n\n\n\u003cbr/\u003e\n\nSo, how to use ZKP in Rosetta quickly? Similar to MPC above, here is a simple [example](example/tutorials/code/rosetta_demo_zkp.py).\n\n\n```python\n#!/usr/bin/env python3\n\n# Import rosetta package\nimport latticex.rosetta as rtt\nimport tensorflow as tf\n\n# You can activate a backend protocol, here we use Mystique\nrtt.activate(\"Mystique\")\n\n# P0 is the Prover, providing all the witnesses(private), and\n# P1 is the Verifier\nmatrix_a = tf.Variable(rtt.private_console_input(0, shape=(3, 2)))\nmatrix_b = tf.Variable(rtt.private_console_input(0, shape=(2, 3)))\n\n# Just use the native tf.matmul operation.\ncipher_result = tf.matmul(matrix_a, matrix_b)\n\n# Start execution\nwith tf.Session() as sess:\n    sess.run(tf.global_variables_initializer())\n    # Take a glance at the ciphertext\n    cipher_result_v = sess.run(cipher_result)\n    print('local ciphertext result:', cipher_result_v)\n    # Get the result of Rosetta matmul\n    print('plaintext result:', sess.run(rtt.SecureReveal(cipher_result)))\n\nrtt.deactivate()\n```\n\nHere P0 is the Prover, providing all the witnesses(private), and the input is as follows:\n\n\n\u003e 2021-10-22 18:12:46.629|info|Rosetta: Protocol [Mystique] backend initialization succeeded! task: , node id: P0\n\u003e \n\u003e 2021-10-22 18:12:46.629|info|create and activate ok. task:  for protocol: Mystique\n\u003e \n\u003e please input the private data (float or integer, 6 items, separated by space): 0 1 2 3 4 5\n\u003e \n\u003e please input the private data (float or integer, 6 items, separated by space): 5 4 3 2 1 0\n\n\nHere P1 is the Verifier, at the end, the verification is successful, and the plaintext result is output as follows:\n\n\u003e 2021-10-22 18:13:12.860|info|succeed in verifying zk!!\n\u003e \n\u003e plaintext result: [[b'2.000000' b'1.000000' b'0.000000']\n\u003e \n\u003e  [b'16.000000' b'11.000000' b'6.000000']\n\u003e \n\u003e  [b'30.000000' b'21.000000' b'12.000000']]\n\u003e \n\u003e 2021-10-22 18:13:13.009|info|Rosetta: Protocol [Mystique] backend has been released.\n\n\u003cbr/\u003e\n\nFor more details, please check [Tutorials](doc/TUTORIALS.md) and [Examples](./example).\n\n\u003e Note: Currently Rosetta already supports 128-bit integer data type, which can be enabled by configuring the environment variable `export ROSETTA_MPC_128=ON` and adding option `--enable-128bit` when compiling.\n\n## Getting Started\n\nTo help you start with your first workable program with Rosetta easily, our [Tutorials](doc/TUTORIALS.md) will lead you to this fantastic world. In this detailed tutorials, we will assist you learn the basic concepts about Rosetta, then show you how to use the interfaces that we provide by easy-to-understand examples, and finally help you build a workable privacy-preserving machine learning model on real-world datasets.\n\nHopefully, this tutorial, and more other examples in [Examples](./example), will whet your appetite to dive in knowing more about this privacy-preserving framework.\n\n## How Rosetta Works\n\nRosetta works by extending and hacking both Python frontend and the Operation Kernels in backend of TensorFlow. It decouples the development of TensorFlow-related components and privacy technology so that both developers from AI and cryptography can focus on what they are interested.\n\n\u003cimg src='doc/_static/figs/architecture_detail_en.png' width = \"700\" height = \"600\" align=\"middle\"/\u003e\n\nWhen running your Rosetta program, firstly the native TensorFlow data flow graph will be converted, and during this process the native Operations within the graph will be replaced with SecureOps.\n\n\u003cimg src='doc/_static/figs/static_pass.png' width = \"800\" height = \"400\" align=\"middle\"/\u003e\n\nAnd at the second stage, the backend kernels of operations, implemented with specific cryptographic protocol, will be called to carry out underlying secure computation.\n\n\u003cimg src='doc/_static/figs/dynamic_pass.png' width = \"800\" height = \"400\" align=\"middle\"/\u003e\n\n## Contributing to Rosetta\n\nRosetta is an open source project developed under the LPGLv3 license and maintained by [LatticeX Foundation](https://latticex.foundation/). Contributions from individuals and organizations are all welcome. Before beginning, please take a look at our [contributing guidelines](CONTRIBUTING.md). Our project adheres to [code of conduct](CODE_OF_CONDUCT.md). By participating in our community, you are expected to uphold this code. You could also open an issue by clicking [here](https://github.com/LatticeX-Foundation/Rosetta/issues/new).\n\n## Documents List\n\n* [Rosetta Tutorials](doc/TUTORIALS.md)\n\n* [Rosetta Deployment Guide](doc/DEPLOYMENT.md)\n\n* [Rosetta User API](doc/API_DOC.md)\n\n* [Rosetta WhitePaper](doc/Rosetta_whitepaper.pdf)\n\n* [Rosetta Glossary](doc/GLOSSARY.md)\n\n* [Rosetta Release Notes](RELEASE.md)\n  \n* [FAQ](https://github.com/LatticeX-Foundation/Rosetta/wiki/FAQ)\n\n\n## Citation\n\nYou can cite our work as folllows:\n```latex \n    @misc{Rosetta,\n      author = {Yuanfeng Chen and Gaofeng Huang and Junjie Shi and Xiang Xie and Yilin Yan},\n      title = {{Rosetta: A Privacy-Preserving Framework Based on TensorFlow}},\n      howpublished = {\\url{https://github.com/LatticeX-Foundation/Rosetta}},\n      year={2020}\n    }\n```\n\n## Reference\n\nCheck this [wiki page](https://github.com/LatticeX-Foundation/Rosetta/wiki/Reference) for the reference.\n\n## Contact\n\nYou could reach us by [email](mailto:rosetta@latticex.foundation). **And you are welcome to join Rosetta community on [Slack](https://join.slack.com/t/latticexrosetta/shared_invite/zt-dum6j65d-MTxp~Bxq5OwouJW8zUKB1Q) to ask any questions and discuss on any interesting topics with other developers**.\n\n## License\n\nThe Rosetta library is licensed under the [GNU Lesser General Public License v3.0](COPYING.LESSER).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLatticeX-Foundation%2FRosetta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLatticeX-Foundation%2FRosetta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLatticeX-Foundation%2FRosetta/lists"}