Giter Club home page Giter Club logo

snwagh / falcon-public Goto Github PK

View Code? Open in Web Editor NEW
85.0 4.0 44.0 16.73 MB

Implementation of protocols in Falcon

CMake 2.17% C++ 73.48% C 13.42% Shell 0.13% Cuda 0.88% Fortran 8.89% Python 0.06% JavaScript 0.05% CSS 0.04% Makefile 0.08% Jupyter Notebook 0.21% Batchfile 0.21% AGS Script 0.01% Jolie 0.01% Roff 0.01% Smarty 0.34% Assembly 0.01% Dockerfile 0.01% Bikeshed 0.01%
multi-party-computation secure-computation privacy-enhancing-technologies privacy-preserving-machine-learning

falcon-public's Introduction

Falcon: Honest-Majority Maliciously Secure Framework for Private Deep Learning

A maliciously secure framework for efficient 3-party protocols tailored for neural networks. This work builds off SecureNN, ABY3 and other prior works. This work is published in Privacy Enhancing Technologies Symposium (PETS) 2021. Paper available here. If you're looking to run Neural Network training, strongly consider using this GPU-based codebase Piranha.

Table of Contents

Warning


This codebase is released solely as a reference for other developers, as a proof-of-concept, and for benchmarking purposes. In particular, it has not had any security review, has a number of implementational TODOs, has a number of known bugs (especially in the malicious implementation), and thus, should be used at your own risk. You can contribute to this project by creating pull requests and submitting fixes and implementations. The code has not run end-to-end training and we expect this to require some parameter tuning, hence training and inference won't work out of the box (however, inference from pre-trained networks can be repreduced easily).

Requirements


  • The code should work on most Linux distributions (It has been developed and tested with Ubuntu 16.04 and 18.04).

  • Required packages for Falcon:

    Install these packages with your favorite package manager, e.g, sudo apt-get install <package-name>.

Docker


To install and run Falcon using docker, first build the container: docker build -t falcon . then run docker run -it falcon '/bin/bash'.

From the prompt, you can execute any of the commands specified in Running the code.

Source Code


Repository Structure

  • files/ - Shared keys, IP addresses and data files.
  • files/preload - Contains data for pretrained network from SecureML. The other networks can be generated using scripts and functions in secondary.cpp
  • lib_eigen/ - Eigen library for faster matrix multiplication.
  • src/ - Source code.
  • util/ - Dependencies for AES randomness.
  • scripts/ - Contains python code to generate trained models for accuracy testing over a batch.
  • The god script makes remote runs simpler (as well as the makefile)

Building the code

To build Falcon, run the following commands:

git clone https://github.com/snwagh/falcon-public.git Falcon
cd Falcon
make all -j$(nproc)

Running the code

To run the code, simply choose one of the following options:

  • make: Prints all the possible makefile options.
  • make terminal: Runs the 3PC code on localhost with output from $P_0$ printed to standard output.
  • make file: : Runs the 3PC code on localhost with output from $P_0$ printed to a file (in output/3PC.txt)
  • make valg: Useful for debugging the code for set faults. Note that the -03 optimization flag needs to be suppressed (toggle lines 42, 43 in makefile)
  • make command: Enables running a specific network, dataset, adversarial model, and run type (localhost/LAN/WAN) specified through the makefile. This takes precedence over choices in the src/main.cpp file.
  • To run the code over tmux over multiple terminals, make zero, make one, and make two come in handy.
  • Finally, the makefile (line 4-15) contains the descriptions of the arguments accepted by the executable.

Additional Resources


Run combinations

Note that given the size of the larger networks (AlexNet, VGG16) and the need to explicitly define network parameters, these networks can only be run for the CIFAR10 and Tiny ImageNet dataset. On the contrary, the smaller datasets (SecureML, Sarda, MiniONN, and LeNet) can only be run for the MNIST dataset. Running them otherwise should result in assertion errors. The following configuration was sufficient to produce the results for the larger networks: 2.9 GHz Intel Xeon E5-2666 v3 Processor, 36 cores, 60 GB RAM (in particular, a similar processor with 16 GB RAM was insifficient).

Comparison with SecureNN

While a bulk of the Falcon code builds on SecureNN, it differs in two important characterastics (1) Building on replicated secret sharing (RSS) (2) Modularity of the design. The latter enables each layer to self contained in forward and backward pass (in contrast to SecureNN where layers are merged for the networks to be tested). The functions are reasonably tested (including ReLU) however they are more tested for 32-bit datatype so the 64-bit might have minor bugs.

Errors and Issues

If there are compile/installation/runtime errors, please create git issues. Some of the common errors and their resolutions are listed below:

  • cannot find something error: This would be a linker error, make sure your code has access to the right paths in the $PATH environment variable.
  • Binding error: There is probably an execution running in the background. Kill the process with pkill Falcon.out (this happens since the socket ports are hardcoded in the program and a number of the makefile commands run code in the background and Ctrl+c only kills the Party 0 code)
  • Bad alloc: This is probably a memory issue. If you're running one of the larger networks (AlexNet, VGG16) on a laptop, try running them on a server/cluster/machine with more memory.

Todos/Bug todos

  • Remove size argument from all functions (generate it inside functions)
  • Clean-up tools and functionalities file -- move reconstruction functions to tools
  • Pointers to layer configurations are never deleted --> needs to be fixed
  • Precompute implementation
  • Incorrect communication numbers for parallel implememntations
  • ...

Citation

You can cite the paper using the following bibtex entry (the paper links to this repo):

@inproceedings{wagh2021falcon,
  title={{FALCON: Honest-Majority Maliciously Secure Framework for Private Deep Learning}},
  author={Wagh, Sameer and Tople, Shruti and Benhamouda, Fabrice and Kushilevitz, Eyal and Mittal, Prateek and Rabin, Tal},
  journal={Proceedings on Privacy Enhancing Technologies},
  year={2021}
}

For questions, please create git issues; for eventual replies, you can also reach out to [email protected]

falcon-public's People

Contributors

andespooh258 avatar cohosh avatar gmuraru avatar snwagh avatar yl3469 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

Watchers

 avatar  avatar  avatar  avatar

falcon-public's Issues

How to generate the common randomness in functionality wrap3?

Hello! I read the paper Falcon: Honest-Majority Maliciously Secure Framework for Private Deep Learning. I wonder how to generate the common randomness in Algorithm wrap3, which I didn't find in code, i.e the shares of a random number x and the shares of the carry bit.

Reproducing the accuracy results

Hi,

So I saw the previous discussion on #9 and I made some edit to the functions that I could get reasonable results for SecureML and Sarda (~96% each). However I still could not get good results for LeNet and MiniONN. So just want to know how the accuracy results in the paper were created? Was there something like quantization scripts? Thanks!

error in Dubugdivision

Hi, i find the division test result is error, everybody meet such problem?
In the test, a = 3.2 b=9.7, the result should be a / b = 0.32, but the code result is 0.0198,
Is there some errors in my test?
image

Prepare dataset wrong

hello ,I have put the .csv file into the ~/Downloads/mnist_train/ and ~/Downloads/mnist_test/ . when I bash the run.sh, I cannot generate the right datase and the output file TRAINING_DATA_A is all 0. I don't know where is wrong?

New bug - Segmentation fault on layer push_back on VGG16

network = "VGG16";
dataset = "CIFAR10"; // or ImageNet

Segmentation fault is detected when pushing back the 31st layer (an FC layer) to layers. This occurred on my two machines so I think it's a machine issue. Tried to fix it myself but didn't quite get the reason for the issue. I see the repo is updated a lot since I first checked, please do investigate this issue to see if the bug can be reproduced.

funcMatMul () require number range?

If two floating point numbers float f = 7.7338 and float e = 6.7338,First, scale the two numbers, then call matrix multiplication funcMatMul (), and find that the product is wrong.

However, if float f = 2.7338 and float e = 3.7338, the result of the product is correct. Does funcmatmul() require the size range of numbers?

Communication round of Private Compare.

Hello,
I noticed l times u[i] needs to be computed in the loop, so it use l invocations of Mult. Why communication rounds of Private Compare are (logl +2) rather than (l+2)?

train data

I don't find the files/train_data_A etc.
why do every party get the same data?

How are shares actually getting created??

I see funcGetShares() in Functionalities.cpp, but from my understanding, for a given input a it is not randomizing the shares into 3 parts and distributing. Instead it only assigns the value a to party A (first) and party C(second) and party B is always initialized with 0. Shouldn't all shares be randomized and then sent to parties as 2-out-of-3 replicated sharing ?? Please correct me If I am wrong, I am unable to understand how shares are getting created

Are parties computing on same inputs?

From the look of the code (especially neural network part), I got an impression that parties are actually computing on the same inputs (rather than having their own secret inputs and sharing them in MPC fashion). Please correct me if I am wrong.

I also found the following lines in the neural network code (secondary.cpp)
//Some day check if this is right. It seems that all
//parties use the same data which is not right.

How do I make parties compute on shares created on their secret inputs? kindly refer to an example file I might have missed

Batch Normalization protocol does not match code implementation.

Hey, snwagh.
I have been reading your paper of Falcon and found this repo. And I am interested in how you perform the computation of Batch Normalization.

I have the following two questions:

  1. the implementation of BN seems to be just a single division
    image
    image

  2. the protocol of Pow seems to reveal the information of the exponent, i.e., \alpha

  3. the BIT_SIZE in your paper is 32, which seems to be too small. How you guarantee the accuracy or say precision? IS the BN actually essential to your ML training and inference?

The security of division protocol

In the paper, the division protocol a/b shown in Algorithm 6 leaks the range of the divisor b.
How to ensure the security of this protocol?

Problems of AlexNet on ImageNet.

I ran AlexNet on ImageNet in LAN. Here is what i got:

P0:

./Falcon.out 0 files/IP_LAN files/keyA files/keyAB files/keyAC AlexNet ImageNet Semi-honest
Loading data done.....
Forward 	0 completed...
...
Forward 	18 completed...
Delta last layer completed.
Delta 		18 completed...
...
Delta 		1 completed...
Update Eq. 	18 completed...
...
Update Eq. 	1 completed...
First layer update Eq. completed.
----------------------------------------------
Wall Clock time for AlexNet train: 7155.25 sec
CPU time for AlexNet train: 7042.8 sec
----------------------------------------------
----------------------------------------------
Total communication: 1777.36MB (sent) and 1777.36MB (recv)
Total calls: 2495 (sends) and 2495 (recvs)
----------------------------------------------
----------------------------------------------
Communication, AlexNet train, P0: 3171.3MB (sent) 3171.3MB (recv)
Rounds, AlexNet train, P0: 808(sends) 808(recvs)
----------------------------------------------
----------------------------------------------
Run details: 3PC (P0), 1 iterations, batch size 128
Running Semi-honest AlexNet train on ImageNet dataset
----------------------------------------------

----------------------------------------------
(1) CNN Layer		  56 x 56 x 3
			  7 x 7  	(Filter Size)
			  1 , 3 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(2) CNN Layer		  56 x 56 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(3) Maxpool Layer	  56 x 56 x 64
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(4) ReLU Layer		  50176 x 128
----------------------------------------------
(5) BN Layer		  50176 x 128
----------------------------------------------
(6) CNN Layer		  28 x 28 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  28 x 28 x 128 	(Output)
----------------------------------------------
(7) Maxpool Layer	  28 x 28 x 128
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(8) ReLU Layer		  25088 x 128
----------------------------------------------
(9) BN Layer		  25088 x 128
----------------------------------------------
(10) CNN Layer		  14 x 14 x 128
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(11) CNN Layer		  14 x 14 x 256
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(12) Maxpool Layer	  14 x 14 x 256
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(13) ReLU Layer		  12544 x 128
----------------------------------------------
(14) FC Layer		  12544 x 1024
			  128		 (Batch Size)
----------------------------------------------
(15) ReLU Layer		  1024 x 128
----------------------------------------------
(16) FC Layer		  1024 x 1024
			  128		 (Batch Size)
----------------------------------------------
(17) ReLU Layer		  1024 x 128
----------------------------------------------
(18) FC Layer		  1024 x 200
			  128		 (Batch Size)
----------------------------------------------
(19) ReLU Layer		  200 x 128
----------------------------------------------

P1:

./Falcon.out 1 files/IP_LAN files/keyB files/keyBC files/keyAB AlexNet ImageNet Semi-honest
Loading data done.....
Forward 	0 completed...
...
Forward 	18 completed...
Delta last layer completed.
Delta 		18 completed...
...
Delta 		1 completed...
Update Eq. 	18 completed...
...
Update Eq. 	1 completed...
First layer update Eq. completed.
----------------------------------------------
Wall Clock time for AlexNet train: 7155.26 sec
CPU time for AlexNet train: 6951.5 sec
----------------------------------------------
----------------------------------------------
Communication, AlexNet train, P1: 3171.3MB (sent) 3171.3MB (recv)
Rounds, AlexNet train, P1: 808(sends) 808(recvs)
----------------------------------------------
----------------------------------------------
Run details: 3PC (P1), 1 iterations, batch size 128
Running Semi-honest AlexNet train on ImageNet dataset
----------------------------------------------

----------------------------------------------
(1) CNN Layer		  56 x 56 x 3
			  7 x 7  	(Filter Size)
			  1 , 3 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(2) CNN Layer		  56 x 56 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(3) Maxpool Layer	  56 x 56 x 64
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(4) ReLU Layer		  50176 x 128
----------------------------------------------
(5) BN Layer		  50176 x 128
----------------------------------------------
(6) CNN Layer		  28 x 28 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  28 x 28 x 128 	(Output)
----------------------------------------------
(7) Maxpool Layer	  28 x 28 x 128
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(8) ReLU Layer		  25088 x 128
----------------------------------------------
(9) BN Layer		  25088 x 128
----------------------------------------------
(10) CNN Layer		  14 x 14 x 128
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(11) CNN Layer		  14 x 14 x 256
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(12) Maxpool Layer	  14 x 14 x 256
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(13) ReLU Layer		  12544 x 128
----------------------------------------------
(14) FC Layer		  12544 x 1024
			  128		 (Batch Size)
----------------------------------------------
(15) ReLU Layer		  1024 x 128
----------------------------------------------
(16) FC Layer		  1024 x 1024
			  128		 (Batch Size)
----------------------------------------------
(17) ReLU Layer		  1024 x 128
----------------------------------------------
(18) FC Layer		  1024 x 200
			  128		 (Batch Size)
----------------------------------------------
(19) ReLU Layer		  200 x 128
----------------------------------------------

P2:

./Falcon.out 2 files/IP_LAN files/keyC files/keyAC files/keyBC AlexNet ImageNet Semi-honest
Loading data done.....
Forward 	0 completed...
...
Forward 	18 completed...
Delta last layer completed.
Delta 		18 completed...
...
Delta 		1 completed...
Update Eq. 	18 completed...
...
Update Eq. 	1 completed...
First layer update Eq. completed.
----------------------------------------------
Wall Clock time for AlexNet train: 7155.25 sec
CPU time for AlexNet train: 6733.12 sec
----------------------------------------------
----------------------------------------------
Communication, AlexNet train, P2: 4024.69MB (sent) 4024.69MB (recv)
Rounds, AlexNet train, P2: 879(sends) 879(recvs)
----------------------------------------------
----------------------------------------------
Run details: 3PC (P2), 1 iterations, batch size 128
Running Semi-honest AlexNet train on ImageNet dataset
----------------------------------------------

----------------------------------------------
(1) CNN Layer		  56 x 56 x 3
			  7 x 7  	(Filter Size)
			  1 , 3 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(2) CNN Layer		  56 x 56 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  56 x 56 x 64 	(Output)
----------------------------------------------
(3) Maxpool Layer	  56 x 56 x 64
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(4) ReLU Layer		  50176 x 128
----------------------------------------------
(5) BN Layer		  50176 x 128
----------------------------------------------
(6) CNN Layer		  28 x 28 x 64
			  5 x 5  	(Filter Size)
			  1 , 2 	(Stride, padding)
			  128		(Batch Size)
			  28 x 28 x 128 	(Output)
----------------------------------------------
(7) Maxpool Layer	  28 x 28 x 128
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(8) ReLU Layer		  25088 x 128
----------------------------------------------
(9) BN Layer		  25088 x 128
----------------------------------------------
(10) CNN Layer		  14 x 14 x 128
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(11) CNN Layer		  14 x 14 x 256
			  3 x 3  	(Filter Size)
			  1 , 1 	(Stride, padding)
			  128		(Batch Size)
			  14 x 14 x 256 	(Output)
----------------------------------------------
(12) Maxpool Layer	  14 x 14 x 256
			  2  		(Pooling Size)
			  2 		(Stride)
			  128		(Batch Size)
----------------------------------------------
(13) ReLU Layer		  12544 x 128
----------------------------------------------
(14) FC Layer		  12544 x 1024
			  128		 (Batch Size)
----------------------------------------------
(15) ReLU Layer		  1024 x 128
----------------------------------------------
(16) FC Layer		  1024 x 1024
			  128		 (Batch Size)
----------------------------------------------
(17) ReLU Layer		  1024 x 128
----------------------------------------------
(18) FC Layer		  1024 x 200
			  128		 (Batch Size)
----------------------------------------------
(19) ReLU Layer		  200 x 128
----------------------------------------------

Firstly, the "Total communication" seems not equal to the sum of all parties communication.

Secondly, it was much more time consuming than I expected.

Btw, I also ran AlexNet on CIFAR10, it cost 77.6502 sec and total communication was 665.514MB (sent).

Any clue?

Large error

An array of 500 decimals of type flaot,

  1. First, scale it to mytype type,

  2. Call Falcon's multiplication operation for each number in the array to calculate the square of each number

  3. Then add up the decimals represented by mytype, and are also represented by mytype,

  4. It is found that the and corresponding plaintext of mytype are about 200 smaller than the plaintext calculated directly by flaot

  5. Is the error caused by the continuous accumulation of the data in the multiplication step and the real product?

However, if you scale the 500 float data into mytype, and then add it up, you will find no error, so I'd like to ask you

A question about calculating Pow in the paper and code

hellow snwagh.
I read the algorithm 5 for computing pow in your paper, but when I read the implementation of the code, I found that the fourth step of algorithm 5 in paper is c=1, and the code shows c=0 here I am puzzled about this. Can you help me? Thank you very much

Testing on distributed server

Hello!

I was trying to test the code on three machines under LAN. Is changing the IP_LAN and the makefile of choosing LAN setting all I need to do? After doing so, I tried to run make zero/one/two on the three machines but after data loading, no further responses are given and it seems no data are transferred.

If I'm doing wrong would you mind telling me the right way to do so? Thanks a lot!

Error in `funcDivsion`

Hi, @snwagh . The funcDivsion functionality computes c=a/b. After increasing the bit-width by changing to uint64_t, I try to run some tests in Debugdivision code as follows

void debugDivision() {
  vector<myType> data_a = {floatToMyType(255), floatToMyType(256),
                           floatToMyType(255)},
                 data_b = {floatToMyType(255), floatToMyType(256),
                           floatToMyType(255)};
  size_t size = data_a.size();
  RSSVectorMyType a(size), b(size), quotient(size);
  vector<myType> reconst(size);

  funcGetShares(a, data_a);
  funcGetShares(b, data_b);
  funcDivision(a, b, quotient, size);

#if (!LOG_DEBUG)
  funcReconstruct(a, reconst, size, "a", true);
  funcReconstruct(b, reconst, size, "b", true);
  funcReconstruct(quotient, reconst, size, "Quot", true);
  print_myType(reconst[0], "Quotient[0]", "FLOAT");
  print_myType(reconst[1], "Quotient[1]", "FLOAT");
  print_myType(reconst[2], "Quotient[2]", "FLOAT");
#endif
}

It returns as follows:

a:              2088960 2097152 2088960 
b:              2088960 2097152 2088960 
Quot:           8137 8131 8137 
Quotient[0]:            0.993286
Quotient[1]:            0.992554
Quotient[2]:            0.993286

It seems good.

But if I change the first element of data_a and data_b as follows:

  vector<myType> data_a = {floatToMyType(300), floatToMyType(256),
                           floatToMyType(255)},
                 data_b = {floatToMyType(300), floatToMyType(256),
                           floatToMyType(255)};

I got this error result:

a:              2457600 2097152 2088960 
b:              2457600 2097152 2088960 
Quot:           -8188 -8176 -8175 
Quotient[0]:            -0.999512
Quotient[1]:            -0.998047
Quotient[2]:            -0.997925

I am so confused about the result. Is anything wrong with my understanding?

How to load CIFAR-10 and ImageNet dataset?

Hey @snwagh .

I try to test the AlexNet and VGG16 which takes CIFAR-10 and ImageNet datasets as training data. Is there data loader for these two datasets?

And i notice that the input size of CIFAR-10 for AlexNet is modified to 33x33, which is here. I wonder why this modification is made and how does this affect the dataloader, zero padding the raw input from 32x32 to 33x33?

relu function in falcon is much bigger than in securenn

  • the cpu time and wall clock time of running the relu function in securenn 100 times is 0.007129 sec and 0.0573575 sec respectively.
  • the cpu time and wall clock time of running the relu function in falcon100 times is 0.120657 sec and 0.0899462 sec respectively.

And it doesn't match the paper(falcon), which you mentioned that falcon improve the efficiency by abount 2X.
Do you have any advice? Thanks every much

How to calculate the communication?

Hi Wagh
I use preloading data to execute the Falcon inference phase in the LAN environment. But the communication obtained through the source code is very large (the specific output is shown in the figure below). This one is too far from the results in Table 2 in your paper. Did I miss something in the calculation process? Could you guide me on how to calculate the communication?

キャプチャ

Very grateful for your help!

Functions in Precompute.cpp

As I understand, all the functions in Precompute.cpp (currently) are just initializing values to 0, can you give a one liner for these functions and how to re-write them ??

The security of division protocol

In the paper, the division protocol a/b shown in Algorithm 6 leaks the range of the divisor b.
How to ensure the security of this protocol?

The test accuracy is not changed

Hi Snwagh
When I use different commands and arguments, there is no change in the Rolling accuracy (100%). Could you give some tips for it or did I run it in wrong way?

./Falcon.out 2 files/IP_localhost files/keyC files/keyAC files/keyBC AlexNet CIFAR10 Semi-honest >/dev/null &
./Falcon.out 1 files/IP_localhost files/keyB files/keyBC files/keyAB AlexNet CIFAR10 Semi-honest >/dev/null &
./Falcon.out 0 files/IP_localhost files/keyA files/keyAB files/keyAC AlexNet CIFAR10 Semi-honest
argc == 9
Loading data done.....
Rolling accuracy: 128 out of 128 (100 %)
MPC Output over uint32_t:

Thank you very much!

Using Randomness function of AESObject

Hey, snwagh.
I have been reading your paper Falcon. I am interested in how to use randomness functions of AESObject in Falcon.

e.g.
let partyA and partyB have r1, partyB and partyC have r2, and partyC and partyA have r3.

  1. Maybe, randomness can get from api PrecomputeObject.getTriplets, but all randomness in Precompute is 0, since the following code:
std::make_pair(0,0);
  1. So can using std::make_pair(getxxBits(), getxxBits()) to replace std::make_pair(0,0) achieve RSS of randomness?
# AESObject 
myType get64Bits();
smallType get8Bits();

Save the model after training and make prediction

Hello, I would like to train a neural network using a falcon and then make a prediction. Is this possible with the current functionality?
Function "test" loads a pre-trained model, can I save the model after training with falcon?

Configuring the network of linux server

Hi, I was trying to conduct the experiment on Linux servers, but I could not get the results from the paper. For the smaller networks, the computation time is almost ignorable, and the main overhead comes from the transmission. For example, for a network like Sarda, in the WAN setting of 70ms ping time between servers and 40MB/s speed, I spent 2.16s purely in data transmission during inference (counted through adding timers in sendVector and receiveVector, computation cost < 0.05s), while the paper reports only 0.76s in total. One thing I notice is that in my case the time cannot simply match adding the round delay + transmission time, and this is very likely to be caused by the vector being split into several packages and costed several rounds during transmission due to the transmission protocol settings.

Did your experiment specifically set some parameters or rules for the Linux data transmission to perform better in large packages? Would you mind sharing those settings so I can better reproduce the results you have? Of course, if you have some other theory for the difference, please let me know! I'm not using an Amazon server as in the paper, would that potentially caused this kind of huge difference?

Thanks!

Question about falcon-public/tree/master/MNIST

hi. I tried to download and parse the MNIST dataset on falcon-public/MNIST/ , and I got the results like it. I have searched the Internet for this error. Some people say that it is because the parameter in the stoi function is not a string that can be converted into an integer.
Screenshot

Can someone help me solve this problem?

'funcRELUPrime' function produces inconsistent 'b' sharing when printed by different parties

Description

Hi, I discovered while running inference that the funcRELUPrime function produces inconsistent sharing of b when printed by different parties. Since the random number is 0, the final calculation result is correct.

I added the following code in funcRELUPrime to get the result

void funcRELUPrime(const RSSVectorMyType &a, RSSVectorSmallType &b, size_t size)
{
	log_print("funcRELUPrime");

	RSSVectorMyType twoA(size);
	RSSVectorSmallType theta(size);
	for (int i = 0; i < size; ++i)
		twoA[i] = a[i] << 1;

	// cout << "Wrap: \t\t" << funcTime(funcWrap, twoA, theta, size) << endl;
	funcWrap(twoA, theta, size);


	for (int i = 0; i < size; ++i)
	{
		b[i].first = theta[i].first ^ (getMSB(a[i].first));
		b[i].second = theta[i].second ^ (getMSB(a[i].second));
	}
        // cout << "---------------------------------------------------------"<<endl;
	// for (size_t i = 0; i < 50; ++i){
	// 	cout << (int)b[i].first << "  ";
	// }
	// cout << endl;
	// for (size_t i = 0; i < 50; ++i){
	// 	cout << (int)b[i].second << "  ";
	// }
	// cout << endl;
	// print_vector(b, "FLOAT", "b - v", 50);
	// cout << "---------------------------------------------------------"<<endl;
}	

Expected Behavior

The b shares should be consistent across all parties after the funcRELUPrime function is executed.

Actual Behavior

The b shares are inconsistent, as demonstrated by the following outputs from different parties:

Party A:

0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b - v
0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0

Party B:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
b - v
0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0

Party C:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 1
b - v
1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 1

How to improve training accuracy?

Now I am trying to use this codebase to realize the training of the "SecureML" neural network over the MNIST dataset, but I have encountered some problems. Please could you advise me what I should do?

  1. I fixed the data importing of the codebase, and the training label and testing label used the one-hot representation. could you help me confirm that this input format is correct? In addition, do I need to perform other preprocessing on the training data before importing the data?

  2. I used the He-Initialization method to initialize the parameters(weights).

  3. The following figure shows the training accuracy of 10 epochs, and the result is very unsatisfactory. Could you give me some valuable suggestions?
    Screenshot from 2021-03-02 17-17-30

  4. In addition, Can functions "backward","computeDelta" and "updateEquations" in the codebase be used directly?

Weird communication results

Hi, I am training LeNet on localhost for 15 iterations. I got the results like in the picture, where it shows the total communication is 900 Mb, but the communication for P0 is already 1673.28 MB. Is there anything wrong with this?

image

How to change the number of epochs when training networks

Hi,

How can I define the number of training epochs for different networks? I have found that there is a variable named NUM_ITERATIONS in main.cpp, but not sure what it is, and also we cannot change it in makefile either.

Thank you.

Incomplete Implementation of getAccuracy() in NeuralNetwork.cpp

Hello,
I am an undergraduate student who are working on privacy-preserving machine learning for my graduation thesis. By testing the code downloaded from the repo, I found that the getAccuracy() in NeuralNetwork.cpp is not implemented, and it always showed an accuracy of 100%, which is quite weird. Can anyone kindly provide some solution on how I can fix it?
Thank you very much!

An Error in the Calculation of Communication Amount

Hello @snwagh, I have found an error in your code.
In line 1150 and 1151 of Functionalities.cpp, the last parameter of sendVector and receiveVector should be sizeLong instead of size.

This mistake makes the communication amount per ReLU 31 bytes less than the correct value and also influences the wall clock time in the stats. Because all shares of the common randomnesses are set to 0 in Precompute.cpp(which is also inappropriate), the mistake above does not have an impact on the prediction result. But the experiment results in Table 2,3,4,5,7 are all incorrect, let alone the follow-up works that make comparison with Falcon.

The correct communication amount per ReLU in semi-honest setting should be 73 bytes, but the theoretical results in the Appendix neither in Table 8(which is 32l) nor in Table 9(which is 4kn) agree with this value.

How to reconduct the experiment

Hello. I am a student interested in MPC and I've executed the tutorial.
Now I plan to reconduct the experiments in your paper, but I don't know how to do it.
Maybe you can give me some help? Thank you!

CPU time and Wall clock time

Hi, when conducting the experiment I see these two values are very different (CPU time seems to be smaller). Which one is reported in the paper? And why are they so different (especially in small networks)?

Getting model parameters after training

Is there an in-built method which can help me save the model parameters after training is completed?
If not, can you suggest some pointers. I have tried using the test() method in Secondary.cpp but I wasn't able to see any output written to any file (it should've written to file in "/files/preload/...").

How to run falcon in the network environment

I want to test the falcon and found 4 four IP addresses in files/IP_localhost, and I want to know the corresponding relationship between these IP addresses and PC0, PC1, and PC2, and how to change the communication port. Can the Falcon run in the network environment just by changing the IP address in files/IP_localhost?
Thanks a lot.

How to get training accuracy?

Hi all,
I was trying to get the accuracy as done in one of the previous issues #8 but I realized the NeuralNetwork::getAccuracy() function has been commented out and as a result temp_groundTruth is not updated. I am always getting 100% accuracy since both counter[0] and counter[1] have same values. Can anyone please help to fix this issue?
Thanks

Segfault when running default SecureML example

ENV: Ubuntu 18.04 with all requirements installed (g++ make libssl-dev).

Description

After setting up the environment (make -j), I tried running the default example (running make example with SecureML with MNIST and Semi-honest in the main.cpp), getting a segmentation fault error. I also tried make command with the proper config variables in the makefile, with the same result.

Code to reproduce

make terminal
#./BMRPassive.out 2 files/IP_localhost  files/keyC files/keyAC files/keyBC >/dev/null &
#./BMRPassive.out 1 files/IP_localhost  files/keyB files/keyBC files/keyAB >/dev/null &
#./BMRPassive.out 0 files/IP_localhost  files/keyA files/keyAB files/keyAC 
#Loading data done.....
#Binding: Address already in use
#makefile:36: recipe for target 'terminal' failed
#make: *** [terminal] Segmentation fault (core dumped)

Additional info

To obtain more info, I ran make valg, and I saved the resulting log hoping it will be of help.
output.log

"Not managing to connect" problem when running using LAN

Hi,
I am trying to run the experiments on the LAN setting to reproduce the results in the Table 4 of the paper. I have changed the appropriate settings in makefile. I have also changed the IP addresses in files/IP_LAN and god. However, I always got the error "Not managing to connect" after running make command, like in the picture attached.
Thank you very much.
Screenshot from 2022-05-24 11-03-48

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.