#include #include #include "protosplittest.h" void reducelist(obliv uint32_t * output, uint32_t * inputs, int len, ProtocolDesc * pd) { if (pd != NULL) ocSetCurrentProto(pd); for (size_t ii = 0; ii < len; ii ++) { *output += feedOblivInt(inputs[ii], ii%2 + 1); } // we want to flush if our protocol is done and other threads are waiting on us // in this case, it's not strictly necessary, but it's a good habit. if (pd != NULL) oflush(pd); } void goprotosplit(void* vargs) { obliv uint32_t output1, output2, output3; uint32_t * inputs = malloc(ELCT * 3 * sizeof(uint32_t)); for (size_t ii = 0; ii < ELCT*3; ii++) inputs[ii] = ii+1; ProtocolDesc pd1; ocSplitProto(&pd1, ocCurrentProto()); ProtocolDesc pd2; ocSplitProto(&pd2, &pd1); parallelize(reducelist, &output1, &output2, &output3, inputs, ELCT, &pd1, &pd2); ocCleanupProto(&pd2); ocCleanupProto(&pd1); output1 += output2 + output3; uint32_t result; revealOblivInt(&result, output1, 0); printf("Result: %u, Expected: %u\n", result, (ELCT*3+1)*(ELCT*3)/2); free(inputs); }