Skip to content

Latest commit

 

History

History
234 lines (172 loc) · 7.63 KB

DEPLOYMENT.md

File metadata and controls

234 lines (172 loc) · 7.63 KB

Rosetta Deployment Guide


In this document, we will describe how to install the Rosetta library with source code from scratch, and how to set up the environment to deploy and test the privacy-preserving machine learning application.

System requirements

Currently, Only Ubuntu 18.04 is supported. We will strive to support various systems in the near future after thorough testing.

  • Ubuntu (18.04=)
  • Python3 (3.6+)
  • Pip3 (19.0+)
  • Openssl (1.1.1+)
  • TensorFlow (1.14.0=, cpu-only)
  • CMake (3.10+)
  • Rosetta (latest)

Installation

System components

  • Ubuntu: Check version:

    lsb_release -r         # e.g. Release: 18.04

    Note: If your OS version is less than 18.04, then you should upgrade your operating system and then continue the following steps

  • Python3 & Pip3 & Openssl & CMake Check the version:

    python3 --version     # e.g. Python 3.6.9
    pip3 --version        # e.g. pip 20.0.2
    apt show libssl-dev   # e.g. Version: 1.1.1-1ubuntu2.1~18.04.5
    cmake --version       # e.g. cmake version 3.15.2

    If the above software versions are not met, you may install or upgrade them as follows:

    # install python3, pip3, openssl
    sudo apt update
    sudo apt install python3-dev python3-pip libssl-dev cmake
    # upgrade pip3 to latest 
    sudo pip3 install --upgrade pip

    After the above installation, please check their version again so that we have a suitable base environment.

TensorFlow

We leave the details of TensorFlow installation in a separate document:TensorFlow Installation, please refer to it if needed.

Rosetta

Currently, Rosetta is only supported to be installed from source code. We are working on its installation with binary packages, and will release it as soon as possible.

Source code installation

Since we have wrapped all the steps in a script, so just get the source code and install it as follows:

# clone rosetta git repository
git clone https://github.com/LatticeX-Foundation/Rosetta.git --recursive
# go to Rosetta directory and use auto completion
cd Rosetta && source rtt_completion
# compile, install and run test cases
./rosetta.sh compile --enable-all --enable-tests;./rosetta.sh install

Deployment testing

After Installing Rosetta, we can test whether it works or not. We can do this by building a demo of the millionaire problem. Rosetta uses a 3-party MPC model that requires the deployment of three computing nodes, which can be deployed on real multiple machines or be simulated in s single machine with multi-processes.

Rosetta is based on TensorFlow. Currently, it only supports non-distributed graph execution.

Example

Here we use the famous demo of millionaire's problem as our example.

Note: There are several privacy machine learning development examples available, for details refer to Tutorials

Preparation

Create separate directories for three computing nodes P0, P1, P2, e.g. millionaire0, millionaire1, millionaire2.

mkdir millionaire0 millionaire1 millionaire2
  • Download the demo

Download the python script to millionaire0, millionaire1, millionaire2 directory for P0, P1, P2 respectively.

wget https://github.com/LatticeX-Foundation/Rosetta/tree/master/example/millionaire/millionaire.py
  • Generate server key and certificate

P0, P1, P2 nodes need generate their separate ssl server certificate and private key respectively, execute the command below:

mkdir certs
# generate private key
openssl genrsa -out certs/server-prikey 4096
# if ~/.rnd not exists, generate it with `openssl rand`
if [ ! -f "${HOME}/.rnd" ]; then openssl rand -writerand ${HOME}/.rnd; fi
# generate sign request
openssl req -new -subj '/C=BY/ST=Belarus/L=Minsk/O=Rosetta SSL IO server/OU=Rosetta server unit/CN=server' -key certs/server-prikey -out certs/cert.req
# sign certificate with cert.req
openssl x509 -req -days 365 -in certs/cert.req -signkey certs/server-prikey -out certs/server-nopass.cert

Note: We you deploy your system with Rosetta in production environment, be certain to use real trusted third-party certificates.

Configuration

Write a configuration file CONFIG.json with the following template:

{
  "PARTY_ID": 0,
  "MPC": {
    "FLOAT_PRECISION": 16,
    "P0": {
      "NAME": "PartyA(P0)",
      "HOST": "127.0.0.1",
      "PORT": 11121
    },
    "P1": {
      "NAME": "PartyB(P1)",
      "HOST": "127.0.0.1",
      "PORT": 12144
    },
    "P2": {
      "NAME": "PartyC(P2)",
      "HOST": "127.0.0.1",
      "PORT": 13169
    },
    "SAVER_MODE": 7,
    "RESTORE_MODE": 0
  }
}

Field Description:

  • PARTY_ID: role of Secure Multipart Computation, the valid values are 0,1,2, corresponding to P0, P1, P2 respectively
  • MPC: specify the protocol of Secure Multipart Computation
  • FLOAT_PRECISION: the float-point precision of Secure Multipart Computation
  • P0, P1, P2: Three-Parties-MPC players P0, P1, P2
  • NAME: MPC player name tag
  • HOST: host address
  • PORT: communication port
  • SERVER_CERT: server-side signature certificate
  • SERVER_PRIKEY: server private key
  • SERVER_PRIKEY_PASSWORD: server private key password (empty string if not set)
  • SAVER_MODE: this indicates how the output checkpoint files are saved. Please refer to MpcSaveV2 in our API document for details.
  • RESTORE_MODE: way of model loading, set the model bit plaintext or ciphertext according to the bit, 0: ciphertext, 1: plaintext, such as the value of 0: all participants are ciphertext model, 1: all participants except P0 are ciphertext model, 2: all participants except P1 are ciphertext model

Run the test

Stand-alone testing

Perform stand-alone testing in the Millionaire directory, Firstly, configure the configuration file using the template and save it as CONFIG.json.

Run the Millionaire Problem example:

Note: The console will be prompted for your private inputs at the beginning.

  • P2node
mkdir log
# MPC player 2
python3 millionaire.py --party_id=2
  • P1node
mkdir log
# MPC player 1
python3 millionaire.py --party_id=1
  • P0 node
mkdir log
# MPC player 0
python3 millionaire.py --party_id=0

After execution, output should be like this:

-------------------------------------------------
1.0
-------------------------------------------------

It means that your example has run smoothly and the standalone deployment test has passed, otherwise the test has failed, and please check the above deployment steps.

Multi-machine testing

Multi-machine testing is similar to stand-alone testing, with the difference that the configuration file needs to be set to a different HOST field corresponding to the IP address.