snwagh / falcon-public

Implementation of protocols in Falcon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How are shares actually getting created??

imtiyazuddin opened this issue · comments

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

If my understanding is correct, share generation has to be implemented as a preprocessing step in the PreComompute.cpp (also handling the floating point arithmetic). Am I correct?

Yes, currently the code does not implement any share randomization. Share generation for pre-preocessing material will be implemented in Precompute.cpp but you will also need share generation for the inputs which will be implemented elsewhere.

Just small clarification that, all four inputs: train_data, test_data, train_labels, test_labels need to be created in shares and stored in files and then read for each party as 2-out-of-3 (2 files for each input) right?

Also the random number generator will be generating a random value in Z_{2^32} i.e. 32 bit integers right? so it can be any random number generator for 32 bit ints ?? Please correct me if I am wrong

Right, so to emulate a real computation, each of the 3 parties should receive 8 "files" as input (train_data, test_data, train_labels, test_labels and 2 files per data type as you mentioned because of the replicated secret sharing).

To generate these files, yes, you can use any random number generator. The default provided in the codebase will provide random 32 bit integers (the function is poorly named and implemented but it should give you a random 32 bit value if myType is set to uint32_t).

Thanks a lot !!!

Floating point also needs to be handled before share creation?? How are floats to be converted into MyType datatype ??

Yes, shares would imply the values are in fixed-point already. There's a small macro (probably in globals.h) called FloatToMyType(x) where x is a floating point value.

So basically I first read my inputs and convert to mytype and then create shares for them and store , got it. Will try it out, thanks !!

Just a small query, how do I create float back from mytype?? just simply divide by 1<< FLOAT_PRECISION ?

Converting back to float is a bit more involved (given the sign). Here's a line that will do it.

There's a method in Functionalities.cpp by the name funcGetShares(), how exactly is it supposed to work? like creating two random numbers r1,r2 and r3 = x-r1-r2 or any other method? How do I control which party generates the random numbers because otherwise everyone will be creating r1,r2,r3 in their own threads right ? Correct me If I am wrong

The funcGetShares() function is written as a quick helper to get plaintext data into secret shared form.

If you would like to generate an input (as secret shares r1, r2, r3) to the entire computation, then that logic will be outside Functionalities.cpp. It will also be an independent piece of code as this data/input is an input to the MPC computation (and thus external to it). You can use the AESObject to generate randomness, i.e., you create a new file which will take raw data r and output r1, r2, r3 and you can create a new instance of the AESObject to generate randomness needed here. This entire script is not related to the 3 parties that you will be running, the only interface would be sending the appropriate data shares to the appropriate party.

okk, thanks for the quick reply !!