Git Product home page Git Product logo

ezpc's People

Contributors

agrawal-d avatar anuwu avatar aseemr avatar bhatuzdaname avatar bhatuzdanamemsr avatar cmzoo avatar deevashwer avatar drunkenlegend avatar jaskiratsingh2000 avatar kanav99 avatar mayank0403 avatar neha-jawalkar avatar nishanthchandran avatar nishkum avatar rahsharmar avatar sharmar avatar shubhamugare avatar trajore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ezpc's Issues

Signed ints are output as unsigned in ezpc.h

Today if signed ints are used in output statement, their unsigned versions are output.
For example,
def void main(){
int32_al x = -1;
output(SERVER, x);
}

The above function will print (1<<32)-1 and not -1.
Solution:
Fix ezpc.h so that output queue has output variable type in account.

Running Ezpc with 64bit numbers, gives malloc(): memory corruption Aborted (core dumped)

Hello,
I am trying to run a 64 bit ezpc program to find input 'a' raised to exponent 'b' Mod 998244353 where 'b' is also input. I wrote a fast exponentiation algorithm to do so similar to .This algorithm in Geeksforgeeks But i need modular exponentiation, so I incorporated the library function unsignedmodbl(uint64_bl x, uint64_bl y) which uses the function longDivision(uint64_bl x, uint64_bl y, bool_pl getQuotient) which is defined in EZPC/library/Library64.ezpc to take mod operation , I am able to compile the program ,but on running the client/server, it gives me the following error:
code

[max_pool] [avg_pool] Output mismatch when padding="SAME"

Reproduce error;

pytest -rs . -k "test_pool[avg_pool-float32-a_shape1-ksize1-strides1-SAME-NHWC]" --backend="CPP"
pytest -rs . -k "test_pool[max_pool-float32-a_shape1-ksize1-strides1-SAME-NHWC]" --backend="CPP"

Expected output:
[ 0.09, -0.44, -0.06, -0.72, 0.02, 1.31, 1. , -1.01, -0.4 ]
Actual output:
[ 0.09, -0.44, -0.03, -0.72, 0.02, 0.66, 0.5 , -0.51, -0.1 ]

Error compiling ResNet

I'm getting the following error after running the instructions in the ResNet readme and then ./CompileTF.sh -f Networks/ResNet/ResNet_main.py in Athos:

Traceback (most recent call last):
  File "SeeDot.py", line 94, in <module>
    obj.runCompilerDriver()
  File "SeeDot.py", line 88, in runCompilerDriver
    obj.run()
  File "/home/marcel/EzPC/Athos/SeeDot/Compiler.py", line 124, in run
    GC.run([mtdAST])
  File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 173, in run
    self.visit(self.ast, args)
  File "/home/marcel/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 114, in visit
    return self.visitLet(node, args)
  File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 188, in visitLet
    self.visit(node.expr, args)
(...)
  File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 188, in visitLet
    self.visit(node.expr, args)
  File "/home/marcel/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 114, in visit
    return self.visitLet(node, args)
  File "/home/marcel/EzPC/Athos/SeeDot/Optimizations/GarbageCollector.py", line 192, in visitLet
    assert False, " visit of {} not implemented in GarbageCollector pass".format(str(type(node.decl)))
AssertionError:  visit of <class 'AST.AST.FusedBatchNorm'> not implemented in GarbageCollector pass

[squeeze] Generic squeeze not supported

We need to add general support for tf.squeeze

A squeeze of a tensor of shape [1, 2, 1, 3, 1, 1] should result in a tensor of shape [2,3].

Squeeze also has an axis dim where we can specify to collapse only specified dims. Add support for that to.

Currently we only support squeeze of 4D->2D, 4D->3D, 3D->2D in Library_common.ezpc. We should generate squeeze code instead of using library functions.

[matmul] Assertion error in SCI HE

Assertion error for 2PC_HE: FCField::matrix_multiplication Assertion `num_cols == 1' failed.

pytest -rs . -k "test_matmul" --backend="2PC_HE"

[bias_add] Support for "NC.." input

Add support for "NC.." data format for bias_add node.

For tf.nn.bias_add(value, bias)

bias is a 1-D vector with shape equal to that of channel dimension.

We currently support broadcasting when value is "N..C". This falls in the normal broadcasting rules of numpy, ([1,250,250,3] + [3])

However when value is "NC..", then normal broadcasting doesn't work. eg: [1,3,250,250] + [3].

Failing test case: test_bias_add

Trouble with compiling SCI library

Hello EzPC team,

I'm following the instructions in the SCI directory trying to compile the library. I am running ubuntu on a docker image.

I have the first two commands working,

mkdir build && cd build
cmake .. [-DBUILD_TESTS=ON] [-DBUILD_NETWORKS=ON]

but when running the make command after I get the following error.
Screen Shot 2021-03-18 at 23 33 24

I have libomp installed, so I am not sure why the error comes up.
Screen Shot 2021-03-18 at 23 35 37

I have all the required packages downloaded and in the correct version.
Any help would be welcomed. Thanks!

[floor] Floor1 not implemented

Add support for Floor1 in ezpc lib.

Reproduce error:
pytest -rs . -k "test_uop[floor-float32-a_shape1]" --backend="CPP"

References?

Thanks for your great work! I wonder if there are any references for coding except your paper in EuroS&P2019, which contains not enough coding examples. Thank you.

Incomplete ABY code genration in 64-bit boolean circuit

In the below EzPC code,

def int64_bl expSigmoidA(int64_bl index)
{
    return 0L;
}
def int64_bl expSigmoidB(int64_bl index)
{
    return 0L;
}
def int64_bl expSigmoidC(int64_bl index)
{
    return 0L;
}
def int64_bl expSigmoidD(int64_bl index)
{
    return 0L;
}
def int64_bl expSigmoid(int64_bl x, int64_pl scaleIn, int64_pl scaleOut)
{
    bool_bl cond = ((x < ( (-20L)*(33554432L) )) || (x > 0L) );
    
    x = (x == (-2147483648L))?(2147483647L):(0L - x);
    int64_bl val1 = (x & (127L));
    int64_bl expVal1 = expSigmoidA(val1);
    x = (x>>7L);
    
    int64_bl val2 = (x & (255L));
    int64_bl expVal2 = expSigmoidB(val2);
    x = (x>>8L);

    int64_bl val3 = (x & (255L));
    int64_bl expVal3 = expSigmoidC(val3);
    x = (x>>8L);

    int64_bl val4 = (x & (255L));
    int64_bl expVal4 = expSigmoidD(val4);

    int64_bl t1 = expVal1 * expVal2;
    t1 = t1 >> scaleOut;
    int64_bl t2 = expVal3 * expVal4;
    t2 = t2 >> scaleOut;
    int64_bl t3 = t1 * t2;
    t3 = t3 >> scaleOut;

    return (cond?(0L):t3);
}

def void main(){
    int64_bl var;
    int64_bl sigvar;
        
    sigvar = expSigmoid(var, 25L, 30L);
    output(ALL, sigvar);

}

, particularly in the part

    int64_bl expVal3 = expSigmoidC(val3);
    x = (x>>8L);

the ABY code generated should be

x = signedarshiftbl(x,  (int64_t)8);

However, the code generated is x = x;.

AttributeError: 'Int' object has no attribute 'idf' while executing CompileTF.sh

I have fetched the source and installed the docker as instruction. After ensuring that ABY and EzPC compiler have been built in the docker, I tried to follow README in https://github.com/mpc-msri/EzPC/tree/master/Athos to see how the program works. The first several steps are quite smooth, until I tried to compile the model into Porthos by executing the script ./CompileTF.sh -b 64 -s 12 -t PORTHOS -f ./Networks/ResNet/ResNet_main.py, I got following error log:

......[many lines of error trace back]......
File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
    return self.visitLet(node, args)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
    (prog_2, expr_2) = self.visit(node.expr)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
    return self.visitLet(node, args)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
    (prog_2, expr_2) = self.visit(node.expr)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
    return self.visitLet(node, args)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
    (prog_2, expr_2) = self.visit(node.expr)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
    return self.visitLet(node, args)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 863, in visitLet
    (prog_2, expr_2) = self.visit(node.expr)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/AST/ASTVisitor.py", line 121, in visit
    return self.visitLet(node, args)
  File "/ezpc-workdir/EzPC/Athos/SeeDot/IR/IRBuilderCSF.py", line 862, in visitLet
    self.name_mapping[idf] = expr_1.idf
AttributeError: 'Int' object has no attribute 'idf'
[WARNING] Running as root is not recommended
Traceback (most recent call last):
  File "./HelperScripts/AthosToPorthosTemp.py", line 31, in <module>
    with open(filename, 'r') as ff:
FileNotFoundError: [Errno 2] No such file or directory: '/ezpc-workdir/EzPC/Athos/Networks/ResNet/ResNet_main_64_porthos0.cpp'

I guess the error might raise due to an incorrect software version or incorrect input. Can anyone provide some suggestions on how can I proceed to next step? Thanks

[reduce_mean] [reduce_sum] Output mismatch

Reproduce error:
pytest -rs . -k "test_reduce[reduce_sum_v1-float32-a_shape2-0-False]" --backend="CPP"
pytest -rs . -k "test_reduce[reduce_mean_v1-float32-a_shape2-0-False]" --backend="CPP"

SCI requires AVX2 instructions, but not specifies it

Hi,

some of the intrinsics used are from the AVX2 instruction set., e.g., _mm256_extracti128_si256.

However, in the CMakeLists.txt, only the AESNI instructions are required with -maes is specified, but not AVX2 via -mavx2.

set(CMAKE_CXX_FLAGS "-pthread -Wall -march=native -maes -mrdseed -faligned-new -std=c++17 -w")

So that results in compilation errors if the current machine does not support AVX2:

/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/avx2intrin.h: In function ‘void sci::_mm256_storeu2_m128i(__m128i*, __m128i*, __m256i)’:
/usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/avx2intrin.h:1093:1: error: inlining failed in call to ‘always_inline’ ‘__m128i _mm256_extracti128_si256(__m256i, int)’: target specific option mismatch
 1093 | _mm256_extracti128_si256 (__m256i __X, const int __M)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /path/to/EzPC/SCI/src/utils/io_channel.h:30,
                 from /path/to/EzPC/SCI/src/utils/net_io_channel.h:33,
                 from /path/to/EzPC/SCI/src/globals.h:232,
                 from /path/to/EzPC/SCI/tests/test_field_maxpool.cpp:24:
/path/to/EzPC/SCI/src/utils/block.h:54:19: note: called from here
   54 |   _mm_storeu_si128(hiaddr, _mm256_extracti128_si256(a, 1));
      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

At other places in the code, functions are tagged with the attribute target("avx") while using AVX2 intrinsics.

EzPC/SCI/src/utils/block.h

Lines 118 to 122 in 7c325fc

__attribute__((target("avx")))
inline block256 makeBlock256(block128 x, block128 y) { // return x (MSB) || y (LSB)
return _mm256_inserti128_si256(_mm256_castsi128_si256(y), x, 1);
// return _mm256_loadu2_m128i(&x, &y);
}

It would be nice, if the required instruction sets were documented somewhere.

Synchronization issue?

The behavior of output changes according to whether I provide server inputs first or client inputs first. Sometimes the outputs are shown only to client with ALL if server inputs are provided first.

[SCI] Conv3D missing

Add support for conv3d in SCI.

Reproduce error: pytest -rs . -k "test_conv" --backend="2PC_HE"

Two questions regarding building and using SCI

Hi,

I have two questions.


First, in the README, you show how to run networks.

But in which format do the binaries expect their input? I.e., what is the expected file format of the <model_file> and <image_file> files mentioned in the code snippet?


Second, how can I build the SCI_OT implementation?

If I just add -DSCI_OT to the CMAKE_CXX_FLAGS, I get an undefined reference errors, e.g.:

/usr/bin/ld: CMakeFiles/minionn_field64.dir/main_minionn_field64.cpp.o: in function `Conv2DWrapper(long, long, long, long, long, long, long, long, long, long, long, long, long, unsigned long*, unsigned long*, unsigned long*)':
main_minionn_field64.cpp:(.text+0x21c37): undefined reference to `Conv2D(int, int, int, int, int, int, int, int, int, int, int, int, int, unsigned long*, unsigned long*, unsigned long*)'

Thanks!

Running Porthos (with resnet after tutorial) gives segfault

Hi, I am hoping to be able to run resnet but i get a segfault. I set up the make file to use -g as a flag and run the party0.sh with gdb. I get the following error.
image

I have made the resnet after the specification in Athos.

I would be very happy to get some help to resolve this :-)

[pad] Generic pad for ND not supported

Currently we only have support for padding of 4D and 5D tensors using Library functions.

Add support for ND tensors. We could simply add Pad1, Pad2, Pad3 functions but since we need to add support for reflect and symmetric padding too, it is better to just generate code instead of using library functions.

Test case: test_pad

[SCI][maxpool] Output mismatch

Reproduce error:
pytest -rs . -k "test_pool[max_pool-float32-a_shape0-ksize0-strides0-VALID-NHWC]" --backend="2PC_OT"

We expect
[0.74, 0.94, 1.24, 1.15]
We get
[0.74, 0. , 1.24, 1.15]

It's always the second element in the result that is zero.

Running Docker for EzPC ends at step 32/38

Hello,

I am trying to install and run EzPC with the docker method on Ubuntu. When I run sudo docker build -t ezpc_image . it works well but then ends at step 32/38.

in red it states

EzPC/EzPC/ABY_example/*': No such file or directory (second last line in image)

See the attached image. Thank you so much for any help you can provide!
Screen Shot 2020-02-20 at 9 04 00 AM

what(): std::bad_alloc when running EzPC docker

Hello!
After Installation of the docker, I followed issue#15 and issue#9, but it doesn't work for me.
I have modified the number to be smaller in
party = new ABYParty(role, address, port, seclvl, bitlen, nthreads, mt_alg, 520000000);

Here are the attached pics..
1
2
3

Thx!

[split] Add support to split into specific sizes (SplitV)

Currently splitting of tensor of size [2, 10] into 5 pieces along axis=1 results in 5 tensors of size [2,2]. This lowers to Split which we currently support.

However tf.split also has support for splitting into specific sizes.
tf.split(a, num_or_size_splits=[2,3,7], axis=1)
would result in 3 tensors of size [2,2], [2,3] and [2,7].

We need to add support for the above which lowers to SplitV

Unit test: test_split

Full pipeline tutorial

Thank you very much for this amazing work! I was wondering whether there is any tutorial on using the tools here in an end-to-end fashion. For example, if I have a pre-trained Tensorflow model, how should I create a secure 2-party system based on it using your toolset?

Thanks in advance for your time!

Input/output statements in functions other than main for ABY backend

Consider this code:

def uint32_al foo(){
  input(CLIENT, y, uint32_al);
  return y;
}

def void bar(uint32_al x){
  output(ALL, x);
}

def void main(){
  uint32_al x = foo();
  bar(x);
}

When compiled with ABY backend, ezpc compiles fine - but ABY itself doesn't compile.
This is because input/output statements use a variable called role, which is currently only being defined in main - if used in other functions, it results in error.
A solution can be to define role as a global variable and assign it in main.

Operator precedence issue between * and +

1 + 2*3 is currently parsed as (1+2)*3. This should instead be parsed as 1 + (2*3).
Fix needed in setting operator precedence in parser.mly. Need to discuss before implementing.

[SCI] Some questions about Multiplexer Algorithm in Cryptflow2

I am very interested in your work about your paper, CrypTFlow2: Practical 2-Party Secure Inference . This article is very valuable in both theory and practice. But I encountered some coding problems about it.
The First Question:
Whether the implementation of Algorithm 6, i.e., Multiplexer is void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp, or not.
The Second Question:
What is the meaning of row_batching = True/False in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
What is the meaning of accumulate = True/False in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
What is the maening of dim1, dim2 and dim3 in void LinearOT::matmul_multiplexer ( ) in linear-ot.cpp ?
The Third Question:
image
Here, bwA and bwB is the bitwidth of A and B. assert(bwA == 1 || bwB == 1) ensures that the bitwidth of either A or B is 1, otherwise, the program will abort.
Whether A or B with a bitwidth of 1 is the choice bit for OT in Multiplexer or not?

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.