Giter Site home page Giter Site logo

ishaq / spdz-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bristolcrypto/spdz-2

0.0 2.0 0.0 367 KB

Multiparty computation with SPDZ online phase and MASCOT offline phase

License: Other

C++ 58.32% Python 40.80% Makefile 0.24% C 0.44% Shell 0.20%

spdz-2's Introduction

(C) 2017 University of Bristol. See License.txt

Software for the SPDZ and MASCOT secure multi-party computation protocols. See Programs/Source/ for some example MPC programs, and tutorial.md for a basic tutorial.

See also https://www.cs.bris.ac.uk/Research/CryptographySecurity/SPDZ

Requirements:

  • GCC
  • MPIR library, compiled with C++ support (use flag --enable-cxx when running configure)
  • libsodium library, tested against 1.0.11
  • CPU supporting AES-NI and PCLMUL
  • Python 2.x, ideally with gmpy package (for testing)

OS X:

  • g++ might actually refer to clang, in which case you need to change CONFIG to use GCC instead.
  • It has been reported that MPIR has to be compiled with GCC for the linking to work: ./configure CC=<path to GCC gcc> CXX=<path to GCC g++> --enable-cxx

To compile SPDZ:

  1. Optionally, edit CONFIG and CONFIG.mine so that the following variables point to the right locations:
  • PREP_DIR: this should be a local, unversioned directory to store preprocessing data (defaults to Player-Data in the working directory)
  1. Run make (use the flag -j for faster compilation with multiple threads)

To setup for the online phase

Run:

Scripts/setup-online.sh

This sets up parameters for the online phase for 2 parties with a 128-bit prime field and 40-bit binary field, and creates fake offline data (multiplication triples etc.) for these parameters.

Parameters can be customised by running

Scripts/setup-online.sh <nparties> <nbitsp> <nbits2>

To compile a program

To compile the program in ./Programs/Source/tutorial.mpc, run:

./compile.py tutorial

This creates the bytecode and schedule files in Programs/Bytecode/ and Programs/Schedules/

To run a program

To run the above program (on one machine), first run:

./Server.x 2 5000 &

(or replace 5000 with your desired port number)

Then run both parties' online phase:

./Player-Online.x -pn 5000 0 tutorial

./Player-Online.x -pn 5000 1 tutorial (in a separate terminal)

Or, you can use a script to do the above automatically:

Scripts/run-online.sh tutorial

To run a program on two different machines, firstly the preprocessing data must be copied across to the second machine (or shared using sshfs), and secondly, Player-Online.x needs to be passed the machine where Server.x is running. e.g. if this machine is name diffie on the local network:

./Player-Online.x -pn 5000 -h diffie 0 tutorial

./Player-Online.x -pn 5000 -h diffie 1 tutorial

Compiling and running programs from external directories

Programs can also be edited, compiled and run from any directory with the above basic structure. So for a source file in ./Programs/Source/, all SPDZ scripts must be run from ./. The setup-online.sh script must also be run from ./ to create the relevant data. For example:

spdz$ cd ../
$ mkdir myprogs
$ cd myprogs
$ mkdir -p Programs/Source
$ vi Programs/Source/test.mpc
$ ../spdz/compile.py test.mpc
$ ls Programs/
Bytecode  Public-Input  Schedules  Source
$ ../spdz/Scripts/setup-online.sh
$ ls
Player-Data Programs
$ ../spdz/Scripts/run-online.sh test

Offline phase (MASCOT)

In order to compile the MASCOT code, the following must be set in CONFIG or CONFIG.mine:

USE_GF2N_LONG = 1

It also requires SimpleOT:

git submodule update --init SimpleOT
cd SimpleOT
make

If SPDZ has been built before, any compiled code needs to be removed:

make clean

HOSTS must contain the hostnames or IPs of the players, see HOSTS.example for an example.

Then, MASCOT can be run as follows:

host1:$ ./ot-offline.x -p 0 -c

host2:$ ./ot-offline.x -p 1 -c

spdz-2's People

Contributors

ishaq avatar mkskeller avatar ocalex86 avatar pascholl avatar rdragos avatar risingnote avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.