Skip to main content

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:

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.

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).start()

main()

Server

To start server for the circuit creator run

python3 script.py --host 0.0.0.0 --port PORT

Client

For circuit evaluator, run the following command

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.

Metadata

Release files for pysecurecircuit 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysecurecircuit 0.0.4
File Size Uploaded
pysecurecircuit-0.0.4.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysecurecircuit 0.0.4
File Interpreter ABI Platform
pysecurecircuit-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / pysecurecircuit-0.0.4.tar.gz

Download URL pysecurecircuit-0.0.4.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9897f3dc1e41f6b2bb9bb14bfb3e163e9b1be25e986ef0bef70af81946fd7ce9
BLAKE2b-256 checksum
How to use checksums
1b0080d1c654d6cafa7fda2f3c358b2a806b1c5025e09607cdd532a5996b67dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.2

Release files / pysecurecircuit-0.0.4-py3-none-any.whl

Download URL pysecurecircuit-0.0.4-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1641c2c6e6bd75eb3ba32b2a9f1097d7dbbe8054f1b78c06874b68f8048ce1ec
BLAKE2b-256 checksum
How to use checksums
bdf736e9502a5a1a8af0882a48777b67d29eaea46f2ac8bc407b938446be10e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page