pysecurecircuit


Namepysecurecircuit JSON
Version 0.0.3 PyPI version JSON
download
home_page
SummaryPython library for secure multi-party computation using garbled circuits
upload_time2023-05-01 00:53:18
maintainer
docs_urlNone
authorYash Amin
requires_python
license
keywords python mpc secure mpc garbled circuit multi party computation
VCS
bugtrack_url
requirements attrs Automat black cffi click constantly cryptography hyperlink idna incremental mypy-extensions packaging pathspec platformdirs pyasn1 pyasn1-modules pycparser pyOpenSSL pyzmq rsa service-identity six tomli typing_extensions zope.interface
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pySecureCircuit

pySecureCircuit is a Python library that allows secure multiparty computation using Yao's garbled circuit technique. The library provides a way for multiple parties to securely compute a function on their private inputs without revealing them to each other, using a combination of encryption, randomization, and computation over circuits.

## Getting Started

### Installation

Run the following command to install the library: 
```sh
pip install pysecurecircuit
```

## Usage

Here's a simple example of how to use pySecureCircuit for the Millionaire's Problem for two parties.

Write your function logic in a python script.

```python
from pysecurecircuit.circuit import Circuit
from pysecurecircuit.server import Server


def main():
    # Create circuit with 2 party
    circuit = Circuit(name="Millionaires' Problem", num_parties=2)

    # Define input variable
    alice_wealth = circuit.newSecureInteger()
    bob_wealth = circuit.newSecureInteger()

    # Circuit logic
    alice_richer_than_bob = alice_wealth > bob_wealth

    # Assign input variables to alice and bob
    circuit.assign_to_party(party_idx=0, name="Wealth (Alice)", variable=alice_wealth)
    circuit.assign_to_party(party_idx=1, name="Wealth (Bob)", variable=bob_wealth)

    # Set circuit's output
    circuit.set_output(name="Alice richer than Bob", variable=alice_richer_than_bob)

    # Start server
    Server(circuit, "0.0.0.0", 5000).start()

main()
```

#### Server

To start server for the circuit creator run

```sh
python3 script.py --host HOST --port PORT
```

#### Client

For circuit evaluator, run the following command

```sh
python3 -m pysecurecircuit --client-id CLIENT_ID --host HOST --port PORT
```

Where `CLIENT_ID` is the identifier of the client that starts from 1, `HOST` is the IP address or hostname of the server, and `PORT` is the port number to connect to.

## Contributing

Contributions are welcome! If you'd like to contribute to pySecureCircuit, please fork the repository and create a pull request.

## Acknowledgments

This library is based on Yao's garbled circuit technique, and builds on existing work in secure multiparty computation. Thank you to the researchers and developers who have contributed to this field.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pysecurecircuit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,mpc,secure mpc,garbled circuit,multi party computation",
    "author": "Yash Amin",
    "author_email": "yamin@hawk.iit.edu",
    "download_url": "https://files.pythonhosted.org/packages/22/84/427f7afe8f19a3d1e4cf385192ac6ad5b7884def83f1b2e678a19b6ec4f1/pysecurecircuit-0.0.3.tar.gz",
    "platform": null,
    "description": "# pySecureCircuit\n\npySecureCircuit is a Python library that allows secure multiparty computation using Yao's garbled circuit technique. The library provides a way for multiple parties to securely compute a function on their private inputs without revealing them to each other, using a combination of encryption, randomization, and computation over circuits.\n\n## Getting Started\n\n### Installation\n\nRun the following command to install the library: \n```sh\npip install pysecurecircuit\n```\n\n## Usage\n\nHere's a simple example of how to use pySecureCircuit for the Millionaire's Problem for two parties.\n\nWrite your function logic in a python script.\n\n```python\nfrom pysecurecircuit.circuit import Circuit\nfrom pysecurecircuit.server import Server\n\n\ndef main():\n    # Create circuit with 2 party\n    circuit = Circuit(name=\"Millionaires' Problem\", num_parties=2)\n\n    # Define input variable\n    alice_wealth = circuit.newSecureInteger()\n    bob_wealth = circuit.newSecureInteger()\n\n    # Circuit logic\n    alice_richer_than_bob = alice_wealth > bob_wealth\n\n    # Assign input variables to alice and bob\n    circuit.assign_to_party(party_idx=0, name=\"Wealth (Alice)\", variable=alice_wealth)\n    circuit.assign_to_party(party_idx=1, name=\"Wealth (Bob)\", variable=bob_wealth)\n\n    # Set circuit's output\n    circuit.set_output(name=\"Alice richer than Bob\", variable=alice_richer_than_bob)\n\n    # Start server\n    Server(circuit, \"0.0.0.0\", 5000).start()\n\nmain()\n```\n\n#### Server\n\nTo start server for the circuit creator run\n\n```sh\npython3 script.py --host HOST --port PORT\n```\n\n#### Client\n\nFor circuit evaluator, run the following command\n\n```sh\npython3 -m pysecurecircuit --client-id CLIENT_ID --host HOST --port PORT\n```\n\nWhere `CLIENT_ID` is the identifier of the client that starts from 1, `HOST` is the IP address or hostname of the server, and `PORT` is the port number to connect to.\n\n## Contributing\n\nContributions are welcome! If you'd like to contribute to pySecureCircuit, please fork the repository and create a pull request.\n\n## Acknowledgments\n\nThis library is based on Yao's garbled circuit technique, and builds on existing work in secure multiparty computation. Thank you to the researchers and developers who have contributed to this field.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python library for secure multi-party computation using garbled circuits",
    "version": "0.0.3",
    "project_urls": {
        "Source Code": "https://github.com/Yash-Amin/pySecureCircuit"
    },
    "split_keywords": [
        "python",
        "mpc",
        "secure mpc",
        "garbled circuit",
        "multi party computation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b365874feb0cca8bdf177b3a09f0d553993ea837b8040ea1dd5072529e454fb",
                "md5": "8ce19f1365d71e9c1a6e84a9a760b4f4",
                "sha256": "cc3641295d39527f9670a42bdc92ed7f85fd5c288bfa5e49fa82c18bd21b141d"
            },
            "downloads": -1,
            "filename": "pysecurecircuit-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8ce19f1365d71e9c1a6e84a9a760b4f4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23284,
            "upload_time": "2023-05-01T00:53:16",
            "upload_time_iso_8601": "2023-05-01T00:53:16.661437Z",
            "url": "https://files.pythonhosted.org/packages/4b/36/5874feb0cca8bdf177b3a09f0d553993ea837b8040ea1dd5072529e454fb/pysecurecircuit-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2284427f7afe8f19a3d1e4cf385192ac6ad5b7884def83f1b2e678a19b6ec4f1",
                "md5": "0fadd98f8145ef85407e7500058c26c2",
                "sha256": "44992bb523cb80a57e16ce0fada6b45b5d80ce181aefe145b53a52d40d493c5b"
            },
            "downloads": -1,
            "filename": "pysecurecircuit-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0fadd98f8145ef85407e7500058c26c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16489,
            "upload_time": "2023-05-01T00:53:18",
            "upload_time_iso_8601": "2023-05-01T00:53:18.680967Z",
            "url": "https://files.pythonhosted.org/packages/22/84/427f7afe8f19a3d1e4cf385192ac6ad5b7884def83f1b2e678a19b6ec4f1/pysecurecircuit-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-01 00:53:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Yash-Amin",
    "github_project": "pySecureCircuit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "22.2.0"
                ]
            ]
        },
        {
            "name": "Automat",
            "specs": [
                [
                    "==",
                    "22.10.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": [
                [
                    "==",
                    "23.3.0"
                ]
            ]
        },
        {
            "name": "cffi",
            "specs": [
                [
                    "==",
                    "1.15.1"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.3"
                ]
            ]
        },
        {
            "name": "constantly",
            "specs": [
                [
                    "==",
                    "15.1.0"
                ]
            ]
        },
        {
            "name": "cryptography",
            "specs": [
                [
                    "==",
                    "40.0.1"
                ]
            ]
        },
        {
            "name": "hyperlink",
            "specs": [
                [
                    "==",
                    "21.0.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.4"
                ]
            ]
        },
        {
            "name": "incremental",
            "specs": [
                [
                    "==",
                    "22.10.0"
                ]
            ]
        },
        {
            "name": "mypy-extensions",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "23.0"
                ]
            ]
        },
        {
            "name": "pathspec",
            "specs": [
                [
                    "==",
                    "0.11.1"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "pyasn1",
            "specs": [
                [
                    "==",
                    "0.4.8"
                ]
            ]
        },
        {
            "name": "pyasn1-modules",
            "specs": [
                [
                    "==",
                    "0.2.8"
                ]
            ]
        },
        {
            "name": "pycparser",
            "specs": [
                [
                    "==",
                    "2.21"
                ]
            ]
        },
        {
            "name": "pyOpenSSL",
            "specs": [
                [
                    "==",
                    "23.1.1"
                ]
            ]
        },
        {
            "name": "pyzmq",
            "specs": [
                [
                    "==",
                    "25.0.2"
                ]
            ]
        },
        {
            "name": "rsa",
            "specs": [
                [
                    "==",
                    "4.9"
                ]
            ]
        },
        {
            "name": "service-identity",
            "specs": [
                [
                    "==",
                    "21.1.0"
                ]
            ]
        },
        {
            "name": "six",
            "specs": [
                [
                    "==",
                    "1.16.0"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    "==",
                    "4.5.0"
                ]
            ]
        },
        {
            "name": "zope.interface",
            "specs": [
                [
                    "==",
                    "6.0"
                ]
            ]
        }
    ],
    "lcname": "pysecurecircuit"
}
        
Elapsed time: 1.46594s