encryptogroup / MOTION2NX

A framework for generic hybrid two-party computation and private inference with neural networks
MIT License
30 stars 16 forks source link

MOTION2NX -- A Framework for Generic Hybrid Two-Party Computation and Private Inference with Neural Networks

This software is an extension of the MOTION framework for multi-party computation. We additionally implemented five 2PC protocols with passive security together with all 20 possible conversions among each other to enable private evaluation of hybrid circuits:

Moreover, we support private inference with neural networks by providing secure tensor data types and specialized building blocks for common tensor operations. With support of the Open Neural Network Exchange (ONNX) file format, this makes our framework interoperable with industry-standard deep learning frameworks such as TensorFlow and PyTorch.

Compared to the original MOTION codebase, we made architectural improvements to increase flexibility and performance of the framework. Although the interfaces of this work are currently not compatible with the original framework due to the concurrent development of both branches, it is planned to integrate the MOTION2NX features into MOTION itself.

More information about this work is given in this extended abstract which was accepted at the PriML@NeurIPS 2021 workshop. It is the result of Lennart Braun's master's thesis in the ENCRYPTO group at TU Darmstadt supervised by Thomas Schneider and Rosario Cammarota.

This code is provided as a experimental implementation for testing purposes and should not be used in a productive environment. We cannot guarantee security and correctness.

Build Instructions

This software was developed and tested in the following environment (it might also work with older versions):

The build system downloads and builds GoogleTest and Benchmark if required. It also tries to download and build Boost, fmt, and flatbuffers if it cannot find these libraries in the system.

The framework can for example be compiled as follows:

$ CC=gcc CXX=g++ cmake \
    -B build_debwithrelinfo_gcc \
    -DCMAKE_BUILD_TYPE=DebWithRelInfo \
    -DMOTION_BUILD_EXE=On \
    -DMOTION_BUILD_TESTS=On \
    -DMOTION_USE_AVX=AVX2
$ cmake --build build_debwithrelinfo_gcc

Explanation of the flags:

HyCC Support for Hybrid Circuits

To enable support for HyCC circuits, the HyCC library must be compiled and the following flags need additionally be passed to CMake:

This builds the library target motion_hycc and the hycc2motion executable.

ONNX Support for Neural Networks

For ONNX support, the ONNX library must be installed and the following flag needs additionally be passed to CMake:

This builds the library target motion_onnx and the onnx2motion executable.

Examples

Using the MOTION2NX Low-Level API

See here for an example solution of Yao's Millionaires' Problem.

Using the onnx2motion Application

$ ./bin/onnx2motion \
    --my-id ${PARTY_ID} \
    --party 0,::1,7000 \
    --party 1,::1,7001 \
    --arithmetic-protocol GMW \
    --boolean-protocol GMW \
    --model /path/to/model.onnx \
    --json

with "${PARTY_ID}" either 0 or 1.