ucbrise / piranha

Piranha: A GPU Platform for Secure Computation
MIT License
92 stars 26 forks source link

Share conversion in Piranha #5

Closed DylanWangWQF closed 2 years ago

DylanWangWQF commented 2 years ago

Hi, @jlwatson For share conversions in RSS, boolean to arithmetic is implemented in the function bitexpand(DeviceData<T, I> *a, DeviceData<U, I2> *b). Does piranha implement arithmetic to boolean (A2B, decomposition)?

BTW, does piranha implement the functionality of the equality test for two integers in 3PC (RSS)?

DylanWangWQF commented 2 years ago
  1. It seems that bitexpand() does not convert secret-shared boolean values to arithmetic values. It just expands a public value (e.g., 32-bit) into another value (e.g., 64-bit). So piranha does not implement A2B or B2A?

  2. For the input data, party_A and party_C store the original data, so we do it here for simplicity?

    
    input.zero();
    input.setPublic(data);

void RSSBase<T, I>::setPublic(std::vector &v) { std::vector shifted_vals; for (double f : v) { shifted_vals.push_back((T) (f * (1 << FLOAT_PRECISION))); }

switch (partyNum) {
    case PARTY_A:
        thrust::copy(shifted_vals.begin(), shifted_vals.end(), shareA->begin());
        shareB->zero();
        break;
    case PARTY_B:
        shareA->zero();
        shareB->zero();
    case PARTY_C:
        shareA->zero();
        thrust::copy(shifted_vals.begin(), shifted_vals.end(), shareB->begin());
        break;
}

};