tf-shell


Nametf-shell JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/google/tf-shell
SummaryTF-Shell: Privacy preserving machine learning with Tensorflow and the SHELL encryption library
upload_time2024-04-26 17:37:50
maintainerNone
docs_urlNone
authorGoogle Inc.
requires_python==3.10.*
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 Bazelisk and python3 or use the devcontainer.

2. Run the tests.

    ```bash
    bazelisk test --config test ...
    ```

3. Build the code.

    ```bash
    bazelisk build --config release //:wheel
    bazelisk 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 tf_shell-...-manylinux.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
bazelisk run //:bazel_formatter
bazelisk run //:python_formatter
bazelisk 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; do
  touch requirements_${ver}.txt
  bazelisk run //:requirements_${ver}.update
done

bazelisk 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.10.*",
    "maintainer_email": null,
    "keywords": null,
    "author": "Google Inc.",
    "author_email": "jchoncholas@google.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 Bazelisk and python3 or use the devcontainer.\n\n2. Run the tests.\n\n    ```bash\n    bazelisk test --config test ...\n    ```\n\n3. Build the code.\n\n    ```bash\n    bazelisk build --config release //:wheel\n    bazelisk 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 tf_shell-...-manylinux.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\nbazelisk run //:bazel_formatter\nbazelisk run //:python_formatter\nbazelisk 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; do\n  touch requirements_${ver}.txt\n  bazelisk run //:requirements_${ver}.update\ndone\n\nbazelisk 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",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/google/tf-shell"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56075c18fd5e626031e4f280449cb70d164d96cba2c1e1927aa837816ed4ce02",
                "md5": "3873f8bf08e3730c95df99d0e959e8d3",
                "sha256": "6f5182dafb00771cc49596c8d8d2b606cdd231b920d810691aa30e69780380dd"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.2-cp310-cp310-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "3873f8bf08e3730c95df99d0e959e8d3",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": "==3.10.*",
            "size": 16017062,
            "upload_time": "2024-04-26T17:37:50",
            "upload_time_iso_8601": "2024-04-26T17:37:50.467854Z",
            "url": "https://files.pythonhosted.org/packages/56/07/5c18fd5e626031e4f280449cb70d164d96cba2c1e1927aa837816ed4ce02/tf_shell-0.1.2-cp310-cp310-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a2b7b1ca677a23616f54154693dabd9ee58c017a70cd8d4c4c0aceb368380c0",
                "md5": "bf92089b16ffc1ae88d869f4cf303a0c",
                "sha256": "25e6a110cabbfd2e87a9f51794bd03230da5ce66020a13b353d181b8a9ef2001"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.2-cp311-cp311-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "bf92089b16ffc1ae88d869f4cf303a0c",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": "==3.10.*",
            "size": 16017062,
            "upload_time": "2024-04-26T17:37:53",
            "upload_time_iso_8601": "2024-04-26T17:37:53.578474Z",
            "url": "https://files.pythonhosted.org/packages/4a/2b/7b1ca677a23616f54154693dabd9ee58c017a70cd8d4c4c0aceb368380c0/tf_shell-0.1.2-cp311-cp311-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2befd9ac6086105bfa62ecc04b7a6b7f6de41deba37cc21cac73a441173354a8",
                "md5": "230cc85e3257231bf47b625bb7ca2f50",
                "sha256": "36298334747462948a49e2e0034ea629ced8faeb140cc54520f43aa1d52086f0"
            },
            "downloads": -1,
            "filename": "tf_shell-0.1.2-cp39-cp39-manylinux_2_35_x86_64.whl",
            "has_sig": false,
            "md5_digest": "230cc85e3257231bf47b625bb7ca2f50",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": "==3.10.*",
            "size": 16017063,
            "upload_time": "2024-04-26T17:37:56",
            "upload_time_iso_8601": "2024-04-26T17:37:56.641988Z",
            "url": "https://files.pythonhosted.org/packages/2b/ef/d9ac6086105bfa62ecc04b7a6b7f6de41deba37cc21cac73a441173354a8/tf_shell-0.1.2-cp39-cp39-manylinux_2_35_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 17:37:50",
    "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.27403s