| 398 | } |
| 399 | |
| 400 | void open(int64_t &value, int64_t share_value) { |
| 401 | |
| 402 | int64_t* tmp = new int64_t[nP+1]; |
| 403 | int64_t sum = 0; |
| 404 | tmp[party] = share_value; |
| 405 | |
| 406 | vector<future<void>> res;//relic multi-thread problems... |
| 407 | for (int i = 1; i <= nP; i++) |
| 408 | { |
| 409 | int party2 = i; |
| 410 | if (i!=party) |
| 411 | { |
| 412 | res.push_back(pool->enqueue([this,share_value,party2]() { |
| 413 | io->send_data(party2,&share_value,sizeof(int64_t)); |
| 414 | io->flush(party2); |
| 415 | })); |
| 416 | res.push_back(pool->enqueue([this,tmp,party2]() { |
| 417 | io->recv_data(party2,tmp+party2,sizeof(int64_t)); |
| 418 | io->flush(party2); |
| 419 | })); |
| 420 | } |
| 421 | } |
| 422 | joinNclean(res); |
| 423 | |
| 424 | for (int i = 1; i <= nP; i++) |
| 425 | { |
| 426 | sum += tmp[i]; |
| 427 | // cout<<"delta_a:"<<delta_i[i]<<"\tdelta_b:"<<delta2_i[i]<<"\tdeltab:"<<deltab<<endl; |
| 428 | #ifdef _debug_ |
| 429 | cout<<"share_value:"<<tmp[i]<<endl; |
| 430 | #endif |
| 431 | } |
| 432 | #ifdef _debug_ |
| 433 | cout<<"sum:"<<sum<<endl; |
| 434 | #endif |
| 435 | value = sum; |
| 436 | |
| 437 | } |
| 438 | void open_vec_2PC(int64_t* value, int64_t* share_value, int length) { |
| 439 | |
| 440 | int64_t *tmp = new int64_t[length]; |