tf-shell


Nametf-shell JSON
Version 0.1.12 PyPI version JSON
download
home_pagehttps://github.com/google/tf-shell
SummaryTF-Shell: Privacy preserving machine learning with Tensorflow and the SHELL encryption library, built for python 3.10.
upload_time2024-11-05 23:45:06
maintainerNone
docs_urlNone
authorGoogle Inc.
requires_python>=3.9
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tf-shell

The `tf-shell` library supports privacy preserving machine learning with
homomorphic encryption via the
[SHELL](https://github.com/google/shell-encryption/) library and tensorflow.

This is not an officially supported Google product.

## Getting Started

```bash
pip install tf-shell
```

See `./examples/` for how to use the library.

## Background

Homomorphic encryption allows computation on encrypted data. For example, given
two ciphertexts `a` and `b` representing the numbers `3` and `4`, respectively,
one can compute a ciphertext `c` representing the number `7` without decrypting
`a` or `b`. This is useful for privacy preserving machine learning because it
allows training a model on encrypted data.

The SHELL encryption library supports homomorphic encryption with respect to
addition and multiplication. This means that one can compute the sum of two
ciphertexts or the product of two ciphertexts without decrypting them. SHELL
does not support _fully_ homomorphic encryption, meaning computing functions of
ciphertexts with arbitrary depth. That said, because machine learning models are
of bounded depth, the performance benefits of leveled schemes (without
bootstrapping, e.g. SHELL) outweight limitations in circuit depth.

## Design

This library has two modules, `tf_shell` which supports Tensorflow Tensors
containing ciphertexts with homomorphic properties, and `tf_shell_ml` some (very)
simple machine learning tools supporting privacy preserving training.

`tf-shell` is designed for Label-DP SGD where training data is vertically
partitioned, e.g. one party holds features while another party holds labels. The
party who holds the features would like to train a model without learning the
labels. The resultant trained model is differentially private with respect to
the labels.

## Building

### Build From Source

1. Install bazel and python3 or use the devcontainer.

2. Run the tests.

    ```bash
    bazel test //tf_shell/...
    bazel test //tf_shell_ml/...  # Large tests, requires 128GB of memory.
    ```

3. Build the code.

    ```bash
    bazel build //:wheel
    bazel run //:wheel_rename
    ```

4. (Optional) Install the wheel, e.g. to try out the `./examples/`.
    You may first need to copy the wheel out of the devcontainer's filesystem.

    ```bash
    cp -f bazel-bin/*.whl ./  # Run in devcontainer if using.
    ```

    Then install.

    ```bash
    pip install --force-reinstall tf_shell-*.whl  # Run in target environment.
    ```

Note the cpython api is not compatible across minor python versions (e.g. 3.10,
3.11) so the wheel must be rebuilt for each python version.

### Code Formatters and Counters

```bash
bazel run //:bazel_formatter
bazel run //:python_formatter
bazel run //:clang_formatter
```

```bash
cloc ./ --fullpath --not-match-d='/(bazel-.*|.*\.venv)/'
```

### Update Python Dependencies

Update requirements.in and run the following to update the requirements files
for each python version.

```bash
for ver in 3_9 3_10 3_11 3_12; do
  rm requirements_${ver}.txt
  touch requirements_${ver}.txt
  bazel run //:requirements_${ver}.update
done

bazel clean --expunge
```

If updating the tensorflow dependency, other dependencies may also need to
change, e.g. abseil (see `MODULE.bazel`). This issue usually manifests as a
missing symbols error in the tests when trying to import the tensorflow DSO. In
this case, `c++filt` will help to decode the mangled symbol name and `nm
--defined-only .../libtensorflow_framework.so | grep ...` may help find what the
symbol changed to, and which dependency is causing the error.

## Contributing

See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.

## License

Apache 2.0; see [`LICENSE`](LICENSE) for details.

## Disclaimer

This project is not an official Google project. It is not supported by
Google and Google specifically disclaims all warranties as to its quality,
merchantability, or fitness for a particular purpose.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/google/tf-shell",
    "name": "tf-shell",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Google Inc.",
    "author_email": "jchoncholas@gmail.com",
    "download_url": null,
    "platform": null,
    "description": "# tf-shell\n\nThe `tf-shell` library supports privacy preserving machine learning with\nhomomorphic encryption via the\n[SHELL](https://github.com/google/shell-encryption/) library and tensorflow.\n\nThis is not an officially supported Google product.\n\n## Getting Started\n\n```bash\npip install tf-shell\n```\n\nSee `./examples/` for how to use the library.\n\n## Background\n\nHomomorphic encryption allows computation on encrypted data. For example, given\ntwo ciphertexts `a` and `b` representing the numbers `3` and `4`, respectively,\none can compute a ciphertext `c` representing the number `7` without decrypting\n`a` or `b`. This is useful for privacy preserving machine learning because it\nallows training a model on encrypted data.\n\nThe SHELL encryption library supports homomorphic encryption with respect to\naddition and multiplication. This means that one can compute the sum of two\nciphertexts or the product of two ciphertexts without decrypting them. SHELL\ndoes not support _fully_ homomorphic encryption, meaning computing functions of\nciphertexts with arbitrary depth. That said, because machine learning models are\nof bounded depth, the performance benefits of leveled schemes (without\nbootstrapping, e.g. SHELL) outweight limitations in circuit depth.\n\n## Design\n\nThis library has two modules, `tf_shell` which supports Tensorflow Tensors\ncontaining ciphertexts with homomorphic properties, and `tf_shell_ml` some (very)\nsimple machine learning tools supporting privacy preserving training.\n\n`tf-shell` is designed for Label-DP SGD where training data is vertically\npartitioned, e.g. one party holds features while another party holds labels. The\nparty who holds the features would like to train a model without learning the\nlabels. The resultant trained model is differentially private with respect to\nthe labels.\n\n## Building\n\n### Build From Source\n\n1. Install bazel and python3 or use the devcontainer.\n\n2. Run the tests.\n\n    ```bash\n    bazel test //tf_shell/...\n    bazel test //tf_shell_ml/...  # Large tests, requires 128GB of memory.\n    ```\n\n3. Build the code.\n\n    ```bash\n    bazel build //:wheel\n    bazel run //:wheel_rename\n    ```\n\n4. (Optional) Install the wheel, e.g. to try out the `./examples/`.\n    You may first need to copy the wheel out of the devcontainer's filesystem.\n\n    ```bash\n    cp -f bazel-bin/*.whl ./  # Run in devcontainer if using.\n    ```\n\n    Then install.\n\n    ```bash\n    pip install --force-reinstall tf_shell-*.whl  # Run in target environment.\n    ```\n\nNote the cpython api is not compatible across minor python versions (e.g. 3.10,\n3.11) so the wheel must be rebuilt for each python version.\n\n### Code Formatters and Counters\n\n```bash\nbazel run //:bazel_formatter\nbazel run //:python_formatter\nbazel run //:clang_formatter\n```\n\n```bash\ncloc ./ --fullpath --not-match-d='/(bazel-.*|.*\\.venv)/'\n```\n\n### Update Python Dependencies\n\nUpdate requirements.in and run the following to update the requirements files\nfor each python version.\n\n```bash\nfor ver in 3_9 3_10 3_11 3_12; do\n  rm requirements_${ver}.txt\n  touch requirements_${ver}.txt\n  bazel run //:requirements_${ver}.update\ndone\n\nbazel clean --expunge\n```\n\nIf updating the tensorflow dependency, other dependencies may also need to\nchange, e.g. abseil (see `MODULE.bazel`). This issue usually manifests as a\nmissing symbols error in the tests when trying to import the tensorflow DSO. In\nthis case, `c++filt` will help to decode the mangled symbol name and `nm\n--defined-only .../libtensorflow_framework.so | grep ...` may help find what the\nsymbol changed to, and which dependency is causing the error.\n\n## Contributing\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.\n\n## License\n\nApache 2.0; see [`LICENSE`](LICENSE) for details.\n\n## Disclaimer\n\nThis project is not an official Google project. It is not supported by\nGoogle and Google specifically disclaims all warranties as to its quality,\nmerchantability, or fitness for a particular purpose.\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "TF-Shell: Privacy preserving machine learning with Tensorflow and the SHELL encryption library, built for python 3.10.",
    "version": "0.1.12",
    "project_urls": {
        "Homepage": "https://github.com/google/tf-shell"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0bcbbb9b45c1e6eeba23646e4a1c62e68e9dcf74f2a1cc9146085baa712a92d1",
                "md5": "12993b667787b37306a6eb944ab23f6e",
                "sha256": "35133a45de92817555ce76c88e9c8e9aa0d4a36ce72c0a660f7f01c37c79c9ee"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.12-cp310-cp310-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "12993b667787b37306a6eb944ab23f6e",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.9",
            "size": 1948025,
            "upload_time": "2024-11-05T23:45:06",
            "upload_time_iso_8601": "2024-11-05T23:45:06.369568Z",
            "url": "https://files.pythonhosted.org/packages/0b/cb/bb9b45c1e6eeba23646e4a1c62e68e9dcf74f2a1cc9146085baa712a92d1/tf_shell-0.1.12-cp310-cp310-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "982eb7a02c1ea6e565234966f5ecf4bb0473fd7564dbea8222c5ab375a08fb69",
                "md5": "379b378b47c020f5c7a4734c1f470c11",
                "sha256": "a96248d6fcce3d148a80d6585d148841e9f9dda24cd862223b4d2f061507ca9e"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.12-cp311-cp311-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "379b378b47c020f5c7a4734c1f470c11",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.9",
            "size": 1948025,
            "upload_time": "2024-11-05T23:45:08",
            "upload_time_iso_8601": "2024-11-05T23:45:08.094026Z",
            "url": "https://files.pythonhosted.org/packages/98/2e/b7a02c1ea6e565234966f5ecf4bb0473fd7564dbea8222c5ab375a08fb69/tf_shell-0.1.12-cp311-cp311-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "562bb2eb5a22b503c542e6b3d263d188f5c9186a1e6702f83a736b91fe2ac172",
                "md5": "40768a8ac9604f12e1c9c006d71b6f74",
                "sha256": "4157449bf7a7cdd952892b773852610a3de67b0197754c4ecd35246b1f98ee64"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.12-cp39-cp39-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "40768a8ac9604f12e1c9c006d71b6f74",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3.9",
            "size": 1948024,
            "upload_time": "2024-11-05T23:45:09",
            "upload_time_iso_8601": "2024-11-05T23:45:09.720539Z",
            "url": "https://files.pythonhosted.org/packages/56/2b/b2eb5a22b503c542e6b3d263d188f5c9186a1e6702f83a736b91fe2ac172/tf_shell-0.1.12-cp39-cp39-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 23:45:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "google",
    "github_project": "tf-shell",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tf-shell"
}
        
Elapsed time: 0.40340s