Skip to content

exfinen/mpc-demo-infra

 
 

Repository files navigation

mpc-demo-infra

A demonstration infrastructure for Multi-Party Computation (MPC) using TLSN and MP-SPDZ.

Table of Contents

DevCon 2024

To participate in our demo ETH Inequality @ DevCon 2024 and win some prizes, please refer to the README for the entire process.

Dependencies

  • python 3
  • poetry
  • cargo
  • TLSN
    • branch: mpspdz-compat
    • clone it as ../tlsn
  • MP-SPDZ (only required for computation party server)
    • branch: demo_client
    • clone it as ../MP-SPDZ
    • need to add MOD = -DGFP_MOD_SZ=5 -DRING_SIZE=257 to CONFIG.mine
    • install: make setup
    • build vm: make replicated-ring-party.x

Getting Started

Run it using docker-compose

Running all the servers locally

  1. Install docker-compose following the instructions here.
  2. Start the servers with the following commands:
    ./configure.py
    docker-compose up --build
  3. Share your ETH balance at Binance with client-cli
    1. Install poetry
    2. Install dependencies with:
    poetry install
    
    1. Run the following command to share data:
    poetry run client-share-data <eth_address> <binance_api_key> <binance_api_secret>
    

Running servers on a separate machine

  1. Follow the README file to set up and run below five servers:

  2. Share your ETH balance at Binance with client-cli

    1. Install poetry
    2. Install dependencies with:
    poetry install
    
    1. Run the following command to share data:
    poetry run client-share-data <eth_address> <binance_api_key> <binance_api_secret>
    

Run it using tests folder

poetry run pytest -s tests/test_integration.py

Run it locally with poetry and manual setup

Note: This section is for running the MPC demo locally. For cloud deployment, you'll need to adjust network configurations.

The demo consists of three main components:

  1. Coordination Server: Coordinates the MPC process.
  2. Computation Party Servers: Run by 3 trusted parties and perform the actual MPC computations.
  3. Client CLI: Used by data provider to share data and query results.

Install dependencies:

./setup_env.sh --setup-mpspdz

Default ports:

  • 8005: coordination server
  • 80068008: computation party server 02
  • 8010~8100: ports used by MPC servers during sharing data and querying results

Please make sure these ports are not used by other services.

Setup coordination server:

In a terminal, run coordination server:

poetry run coord-run

Setup computation party server:

In a terminal, run party 0:

PORT=8006 PARTY_ID=0 poetry run party-run

In another terminal, run party 1:

PORT=8007 PARTY_ID=1 poetry run party-run

In another terminal, run party 2:

PORT=8008 PARTY_ID=2 poetry run party-run

Data provider share data with a generated voucher.

poetry run client-share-data <eth_address> <binance_api_key> <binance_api_secret>

Query computation result

poetry run client-query

Configurations

See available configs in

You can use .env.xxx to override the default configs.

Troubleshooting

If you encounter issues:

  1. Ensure all dependencies are correctly installed.
  2. Check that the required ports (8005-8008, 8010-8100) are not in use.
  3. Verify that TLSN and MP-SPDZ are cloned in the correct locations (../tlsn and ../MP-SPDZ).
  4. For MP-SPDZ issues, ensure
  • you've added MOD = -DGFP_MOD_SZ=5 to CONFIG.mine.
  • you've generated certificates for computation parties. If not, run Scripts/setup-ssl.sh under ../MP-SPDZ.
  • you've rebuilt the VM. If not, run make replicated-ring-party.x under ../MP-SPDZ.
  1. Clean up the Docker environment by running the following commands for Docker-related issues:
    docker system prune -a --volumes
    docker rm -f $(docker ps -aq)
    docker volume prune -a -f
    docker image prune -f

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 90.0%
  • Shell 5.6%
  • Dockerfile 4.4%