Giter VIP home page Giter VIP logo

ivory-runtime's Introduction

The Ivory Secure Computation Runtime

Ivory Logo

The Ivory Runtime is a C++ library that aims to make secure computation easier to use. At a high level, Ivory achieves this by bringing together the protocol and the binary/arithmetic circuit compiler into a single integrated system.

Instead of requiring the user provide the circuit to be computed, the runtime pre-compiles many of the most useful opertions into mini-circuits/operations, e.g. addition, subtraction, multiplication, etc. The runtime then provides easy to use abstrations for declaring input variables, and computing with them.

While at of this push, only semi-honest garbled circuit is supported, eventually other paradigms will be supported in a generic way. That is, you will be able to write a program that builds on Ivory's generic MPC API and then select the desired protocol to run in the background. E.g. semi-honest, malicious, garbled circuit, lego, mascot, etc...

Consider the following code snippet. It takes 64 bit input from two parties and adds, subtracts, multiplies, etc them together. Each party is then revealed a different set of the computation.

void program(std::array<Party, 2> parties, i64 myInput)
{
    // declare some secret inputs, one for each party
    sInt input0 = parties[0].isLocalParty() ?
        parties[0].input<sInt>(myInput, 64) :
        parties[0].input<sInt>(64);

    sInt input1 = parties[1].isLocalParty() ?
        parties[1].input<sInt>(myInput, 64) :
        parties[1].input<sInt>(64);

    // perform some generic secure computation 
    auto add = input1 + input0;
    auto sub = input1 - input0;
    auto mul = input1 * input0;
    auto div = input1 / input0;

    // logical operations
    auto gteq = input1 >= input0;
    auto lt   = input1 <  input0;

    // conditional operation
    auto max = gteq.ifelse(input1, input0);


    // mark these values as being revealed to party 0
    // at some point in the future (asynchronous).
    parties[0].reveal(add);
    parties[0].reveal(sub);
    parties[0].reveal(mul);
    parties[0].reveal(div);

    // and these ones to party 1
    parties[1].reveal(gteq);
    parties[1].reveal(lt);
    parties[1].reveal(max);

    // The parties now waits for their results and prints them.
    if (parties[0].isLocalParty()) 
    {
        std::cout << "add  " << add.getValue() << std::endl;
        std::cout << "sub  " << sub.getValue() << std::endl;
        std::cout << "mul  " << mul.getValue() << std::endl;
        std::cout << "div  " << div.getValue() << std::endl;
    } else {
        std::cout << "gteq " << gteq.getValue() << std::endl;
        std::cout << "lt   " << lt.getValue() << std::endl;
        std::cout << "max  " << max.getValue() << std::endl;
    }

}

Building

To build the library on linux, libOTe v1.6.0 must be built. Important, build libOTe with (Miracl or Relic) and enable the circuit implementation. Checkout version 1.6 and follow the instructions on the associated readme. Once build, ensure that Ivory-Runtime and libOTe are contained in the same parent directory.

git clone https://github.com/osu-crypto/libOTe.git --recursive
cd libOTe
git pull origin v1.6.0
git checkout v1.6.0
python3 build.py -DENABLE_CIRCUITS=true -DENABLE_ALL_OT=true
cd ..
git clone https://github.com/ladnir/Ivory-Runtime.git
cd Ivory-Runtime/thirdparty/linux
bash ./ntl.get
cd ../..
cmake -S . -B out/build/linux
cmake --build out/build/linux

This will produce produce several libraries which will need to be linked. libOTe can be linked via cmake. See the libOTe repo for instructions. The ivory library at Ivory-Runtime/bin should also be linked.

With regards to includes folders, libOTe must be included via cmake and Ivory-Runtime/ivory should also be included.

Similar instruction on windows can be followed with the exception that visual studio solutions are provided in lue of cmake.

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.