Giter Site home page Giter Site logo

emp-tool's Introduction

emp-tool

arm x86

Installation

  1. wget https://raw.githubusercontent.com/emp-toolkit/emp-readme/master/scripts/install.py
  2. python install.py -install -tool
    1. By default it will build for Release. -DCMAKE_BUILD_TYPE=[Release|Debug] option is also available.
    2. No sudo? Change CMAKE_INSTALL_PREFIX.

Usage

Basic Primitives

Pseudorandom generator

PRG is implemented as AES-NI in the CTR mode. Usage is presented as the following code sample.

#include<emp-tool/emp-tool.h>
using namespace emp;
PRG prg;//using a secure random seed

int rand_int, rand_ints[100];
block rand_block[3];
mpz_t integ;mpz_init(integ);

prg.random_data(&rand_int, sizeof(rand_int)); //fill rand_int with 32 random bits
prg.random_block(rand_block, 3);	      //fill rand_block with 128*3 random bits

prg.reseed(&rand_block[1]);                   //reset the seed and counter in prg
prg.random_data_unaligned(rand_ints+2, sizeof(int)*98);  //when the array is not 128-bit-aligned
prg.random_mpz(integ, 1024);                  //random number with 1024 bits.

Pseudorandom permutation

PRP is implemented based on AES-NI. Code sample:

block key;
PRG().random_block(&key,1)
PRP prp(key); //if no parameter is provided, a public, fixed key will be used

block rand_block[3], b3[3];
int rand_ints[100];

prp.permute_block(rand_block, 3);//applying pi on each block of data
prp.permute_data(rand_ints, sizeof(int)*100);

block b2 = prp.H(rand_block[1], 1); //b2 = pi(r)\xor r, where r = doubling(random_block)\xor 1

prp.H<3>(b3, rand_block, 0);// apply the above H on three blocks using counter 0, 1, and 2 resp.

Hash function

Essentially a wrapper of <openssl/sha.h>

Hash hash;

char * data = new char[1024*1024], dig[Hash::DIGEST_SIZE];

hash.put(data, 1024*1024);
hash.digest(dig);

Commitment

Commitment c;

char * data = new char[1024*1024];
Com com;
Decom decom;

c.commit(decom, com, data, 1024*1024); // commit, will fill values decom and com
assert(c.open(decom, com, data, 1024*1024)); // open, return if the decommitment is valid or not

On-the-fly Circuit Compiler

Acknowledgement, Reference, and Questions

emp-tool's People

Contributors

bhemen avatar bl4ck5un avatar carlweng avatar dymil avatar fabrice102 avatar fionser avatar kw-xyz avatar nglaeser avatar schoppmp avatar wangxiao1254 avatar weikengchen 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.