snwagh / falcon-public

Implementation of protocols in Falcon
90 stars 46 forks source link

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

Open lcy5201314 opened 4 months ago

lcy5201314 commented 4 months ago

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

snwagh commented 4 months ago

@lcy5201314 There does seem to be some issue based on your output. Party B having all zeros is fine but the .first and .second of the first and third party respectively should agree. I won't have the bandwidth to probe into this but can you check the following:

There is a very real possibility of you hitting a bug, please send a patch if you manage to fix it.

lcy5201314 commented 3 months ago

Thank you for your reply. I will check the details of the error in detail later.