#ifndef __MPCOPS_HPP__ #define __MPCOPS_HPP__ #include "types.hpp" #include "mpcio.hpp" #include "coroutine.hpp" // P0 and P1 both hold additive shares of x (shares are x0 and x1) and y // (shares are y0 and y1); compute additive shares of z = x*y = // (x0+x1)*(y0+y1). x, y, and z are each at most nbits bits long. // // Cost: // 2 words sent in 1 message // consumes 1 MultTriple void mpc_mul(MPCTIO &tio, yield_t &yield, RegAS &z, RegAS x, RegAS y, nbits_t nbits = VALUE_BITS); // P0 and P1 both hold additive shares of x (shares are x0 and x1) and y // (shares are y0 and y1); compute additive shares of z = x0*y1 + y0*x1. // x, y, and z are each at most nbits bits long. // // Cost: // 2 words sent in 1 message // consumes 1 MultTriple void mpc_cross(MPCTIO &tio, yield_t &yield, RegAS &z, RegAS x, RegAS y, nbits_t nbits = VALUE_BITS); // P0 holds the (complete) value x, P1 holds the (complete) value y; // compute additive shares of z = x*y. x, y, and z are each at most // nbits bits long. The parameter is called x, but P1 will pass y // there. // // Cost: // 1 word sent in 1 message // consumes 1 HalfTriple void mpc_valuemul(MPCTIO &tio, yield_t &yield, RegAS &z, value_t x, nbits_t nbits = VALUE_BITS); // P0 and P1 hold bit shares f0 and f1 of the single bit f, and additive // shares y0 and y1 of the value y; compute additive shares of // z = f * y = (f0 XOR f1) * (y0 + y1). y and z are each at most nbits // bits long. // // Cost: // 2 words sent in 1 message // consumes 1 MultTriple void mpc_flagmult(MPCTIO &tio, yield_t &yield, RegAS &z, RegBS f, RegAS y, nbits_t nbits = VALUE_BITS); // P0 and P1 hold bit shares f0 and f1 of the single bit f, and additive // shares of the values x and y; compute additive shares of z, where // z = x if f=0 and z = y if f=1. x, y, and z are each at most nbits // bits long. // // Cost: // 2 words sent in 1 message // consumes 1 MultTriple void mpc_select(MPCTIO &tio, yield_t &yield, RegAS &z, RegBS f, RegAS x, RegAS y, nbits_t nbits = VALUE_BITS); // P0 and P1 hold bit shares f0 and f1 of the single bit f, and additive // shares of the values x and y. Obliviously swap x and y; that is, // replace x and y with new additive sharings of x and y respectively // (if f=0) or y and x respectively (if f=1). x and y are each at most // nbits bits long. // // Cost: // 2 words sent in 1 message // consumes 1 MultTriple void mpc_oswap(MPCTIO &tio, yield_t &yield, RegAS &x, RegAS &y, RegBS f, nbits_t nbits = VALUE_BITS); // P0 and P1 hold XOR shares of x. Compute additive shares of the same // x. x is at most nbits bits long. // // Cost: // nbits-1 words sent in 1 message // consumes nbits-1 HalfTriples void mpc_xs_to_as(MPCTIO &tio, yield_t &yield, RegAS &as_x, RegXS xs_x, nbits_t nbits = VALUE_BITS); #endif