#include #include #include #include "testFloatOps.h" void floatOps(void* args) { protocolIO *io = (protocolIO*) args; float x = 0; float y = 0; float z = 0; load_data(io, &x, &y, ocCurrentParty()); obliv float obliv_x; obliv float obliv_y; obliv float obliv_z; printf("X: %f\n", x); printAsBinary(x); obliv_x = feedOblivFloat(x, 1); float x_r = 0; revealOblivFloat(&x_r, obliv_x, 1); printAsBinary(x_r); printf("X_r: %f\n", x_r); printf("Y: %f\n", y); printAsBinary(y); obliv_y = feedOblivFloat(y, 2); float y_r = 0; revealOblivFloat(&y_r, obliv_y, 2); printAsBinary(y_r); printf("Y_r: %f\n", y_r); printf("\n"); // Addition obliv_z = obliv_x + obliv_y; revealOblivFloat(&z, obliv_z, 0); printf("Addition: %f\n", z); printAsBinary(z); printf("\n"); // Addition obliv_z = obliv_x - obliv_y; revealOblivFloat(&z, obliv_z, 0); printf("Subtraction: %f\n", z); printAsBinary(z); printf("\n"); // Multiplication obliv_z = obliv_x * obliv_y; revealOblivFloat(&z, obliv_z, 0); printf("Multiplication: %f\n", z); printAsBinary(z); printf("\n"); // Division obliv_z = obliv_x / obliv_y; revealOblivFloat(&z, obliv_z, 0); printf("Division: %f\n", z); printAsBinary(z); printf("\n"); // Negation obliv_z = -obliv_x; revealOblivFloat(&z, obliv_z, 0); printf("Negation: %f\n", z); printAsBinary(z); printf("\n"); // Not Equal bool r; obliv bool o_r = obliv_x != obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Not Equal\n"); } else { printf("Equal\n"); } // Equal bool r; obliv bool o_r = obliv_x == obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Not Equal\n"); } else { printf("Equal\n"); } // Less Than bool r; obliv bool o_r = obliv_x < obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Less than\n"); } else { printf("Not less than\n"); } // Greater Than bool r; obliv bool o_r = obliv_x > obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Greater than\n"); } else { printf("Not greater than\n"); } // Less Than or Equal to bool r; obliv bool o_r = obliv_x <= obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Less than or equal to\n"); } else { printf("Not less than or equal to\n"); } // Greater Than or Equal to bool r; obliv bool o_r = obliv_x >= obliv_y; revealOblivBool(&r, o_r, 0); if (r) { printf("Greater than or equal to\n"); } else { printf("Not greater than or equal to\n"); } // Test setFloatKnown float x_test_r; obliv float x_test = 55; revealOblivFloat(&x_test_r, x_test, 0); printf("X_test_r: %f\n", x_test_r); printAsBinary(x_test_r); printf("\n"); io->ores = z; }