Skip to main content

Secure Multiparty Computation (MPC)

Currently, proof generation is supported with two different MPC protocols:

  • 3-party replicated secret sharing (based on ABY31) with semi-honest security
  • N-party Shamir secret sharing2 (based on DN073) with semi-honest security

Notation

With [x][x] we denote that xFpx\in\mathbb F_p is additively secret shared amongst nn parties, such that [x]=(x1,x2,...,xn)[x] = (x_1, x_2, ..., x_n) and x=inxix = \sum_i^n x_i. With [x]B[x]^B we denote that xFpx\in\mathbb F_p is binary secret shared amongst nn parties, such that [x]B=(x1,x2,...,xn)[x]^B = (x_1, x_2, ..., x_n) and x=x1x2...xnx = x_1 \oplus x_2 \oplus ... \oplus x_n. With [x]t[x]_t we denote that xFpx\in\mathbb F_p is Shamir secret shared amongst nn parties, such that [x]=(x1,x2,...,xn)[x] = (x_1, x_2, ..., x_n) and xi=Q(i)x_i = Q(i) such that Q(X)Q(X) is a polynomial of degree tt with x=Q(0)x=Q(0). Similar, for a group element XGX\in\mathbb G in an additive Group G\mathbb G (e.g., elliptic curve groups) we denote by [X][X] its additive secret sharing amongst nn parties, and by [X]t[X]_t its Shamir sharing, such that [X]=(X1,X2,...,Xn)[X] = (X_1, X_2, ..., X_n). Furthermore, indices of shares are taken modulo the number of parties.

3-Party Replicated Sharing

Replicated secret sharing is based on additive secret sharing, with the twist that each party has multiple additive shares. Thus, in the 3-party case a secret xFpx\in\mathbb F_p is shared the following way. First, the xx is split into three random shares x1,x2,x3Fpx_1, x_2, x_3\in\mathbb F_p such that x=x1+x2+x3modpx=x_1+x_2+x_3 \mod p and each party gets two shares:

P1:(x1,x3)P2:(x2,x1)P3:(x3,x2)\begin{align*} P_1: (x_1, x_3)\\ P_2: (x_2, x_1)\\ P_3: (x_3, x_2) \end{align*}

Rng Setup

Random values are required during many parts of MPC executions. For cheaper randomness generation, correlated random number generators are set up before protocol execution.

Random Values

In order to create random shares (ri,ri1)(r_i, r_{i-1}), random additive shares of 00 (i.e., riri1r_i - r_{i-1}), or random binary shares of 00 (i.e., riri1r_i \oplus r_{i-1}) without interaction, Rep3 sets up a correlated random number generator during the setup phase. Each party PiP_i chooses a seed sis_i and sends it to the next party Pi+1P_{i+1}. Thus, each party has two seeds and can set up an RNG's, where two party are able to create the same random numbers:

P1:(RNG1,RNG3)P2:(RNG2,RNG1)P3:(RNG3,RNG2)\begin{align*} P_1: (\text{RNG}_1, \text{RNG}_3)\\ P_2: (\text{RNG}_2, \text{RNG}_1)\\ P_3: (\text{RNG}_3, \text{RNG}_2) \end{align*}

Binary To Arithmetic Conversion

For the binary to arithmetic conversion, we need correlated randomness as well. The goal is to setup RNG's, such that:

P1:(RNG11,RNG13),(RNG21,RNG22,RNG23)P2:(RNG11,RNG12,RNG13),(RNG22,RNG21)P3:(RNG11,RNG12,RNG13),(RNG21,RNG22,RNG23)\begin{align*} P_1: (&\text{RNG1}_1, \text{RNG1}_3), (\text{RNG2}_1, \text{RNG2}_2, \text{RNG2}_3)\\ P_2: (&\text{RNG1}_1, \text{RNG1}_2, \text{RNG1}_3), (\text{RNG2}_2, \text{RNG2}_1)\\ P_3: (&\text{RNG1}_1, \text{RNG1}_2, \text{RNG1}_3), (\text{RNG2}_1, \text{RNG2}_2, \text{RNG2}_3) \end{align*}

In other words, P2P_2 and P3P_3 can use RNG1 create the same field element, while all parties can sample valid shares for it. Similar, P1P_1 and P3P_3 can use RNG2 to create the same field element, while all parties can sample valid shares for it. This setup can be achieved by sampling seeds from the already set up RNG for shared random values and resharing the seeds correctly.

Supported operations

Linear Operations

Due to being based on additive secret sharing, linear operations can be performed on shares without party interaction.

  • Constant addition: [x]+y=(x1+y,x2,x3)[x] + y = (x_1 + y, x_2, x_3)
  • Share addition: [x]+[y]=(x1+y1,x2+y2,x3+y3)[x] + [y] = (x_1 + y_1, x_2 + y_2, x_3 + y_3)
  • Constant Multiplication: [x]y=(x1y,x2y,x3y)[x] \cdot y = (x_1\cdot y, x_2\cdot y, x_3\cdot y)

Similar, linear operations can be computed locally in the binary domain as well.

  • Constant addition: [x]By=(x1y,x2,x3)[x]^B \oplus y = (x_1 \oplus y, x_2, x_3)
  • Share addition: [x]B[y]B=(x1y1,x2y2,x3y3)[x]^B \oplus [y]^B = (x_1 \oplus y_1, x_2 \oplus y_2, x_3 \oplus y_3)
  • Constant Multiplication: [x]By=(x1y,x2y,x3y)[x]^B \wedge y = (x_1\wedge y, x_2\wedge y, x_3\wedge y)

Multiplications

One main advantage of replicated secret sharing is the presence of a simple multiplication protocol. First, due to having two additive shares, each party can calculate an additive share of the result without interaction. For [z]=[x][y][z] = [x] \cdot [y], zi=xiyi+xiyi1+xi1yiz_i = x_i \cdot y_i + x_i \cdot y_{i-1} + x_{i-1} \cdot y_i is a valid additive share of zz.

Thus, multiplications involve a local operation followed by a resharing of the result to translate the additive share to a replicated share. Resharing requires to randomize the share to not leak any information to the other party. For that reason, a fresh random share of zero is added, which can be sampled locally without party interaction (see RNG setup).

Thus, party PiP_i calculates:

ri=RNGiRNGi1zi=xiyi+xiyi1+xi1yi+rizi1=SendReceive(zi)\begin{align*} r_i &= \text{RNG}_i - \text{RNG}_{i-1}\\ z_i &= x_i \cdot y_i + x_i \cdot y_{i-1} + x_{i-1} \cdot y_i + r_i\\ z_{i-1} &= \text{SendReceive}(z_i) \end{align*}

The resharing, thereby, is simply implemented as PiP_i sending ziz_i to Pi+1P_{i+1}.

AND

AND gates follow directly from multiplications:

ri=RNGiRNGi1zi=(xiyi)(xiyi1)(xi1yi)rizi1=SendReceive(zi)\begin{align*} r_i &= \text{RNG}_i \oplus \text{RNG}_{i-1}\\ z_i &= (x_i \wedge y_i) \oplus (x_i \wedge y_{i-1}) \oplus (x_{i-1} \wedge y_i) \oplus r_i\\ z_{i-1} &= \text{SendReceive}(z_i) \end{align*}

Arithmetic to Binary Conversion

In replicated sharing over rings Z2k\mathbb Z_{2^k} (e.g., ABY3), arithmetic to binary conversion of a share [x][x] is implemented by first locally splitting the shares to valid binary sharings, i.e., [x1]B=(x1,0,0)[x_1]^B = (x_1, 0, 0), [x2]B=(0,x2,0)[x_2]^B = (0, x_2, 0), and [x3]B=(0,0,x3)[x_3]^B = (0, 0, x_3) and combining them in MPC using binary addition circuits. Then [x]B=BinAdd(BinAdd([x1]B,[x2]B),[x3]B)[x]^B = \text{BinAdd}(\text{BinAdd}([x_1]^B, [x_2]^B), [x_3]^B) is a valid binary sharing of xx. This approach works because binary addition circuits implicitly perform modular reductions mod 2k2^k.

Thus, in Fp\mathbb F_p we have to include the mod pp reductions manually in the circuit. For improved performance, we use the following protocol to translate [x][x]:

  • PiP_i samples rir_i to be a new random binary share of 00
  • Set [x3]B=(0,0,x3)[x_3]^B = (0, 0, x_3)
  • P2P_2 calculates t=(x1+x2modp)r2t = (x_1 + x_2 \mod p) \oplus r_2
    • It follows that (r1,t,r3)(r_1, t, r_3) is a valid binary sharing of (x1+x2modp)(x_1 + x_2 \mod p)
  • PiP_i sends its share of (r1,t,r3)(r_1, t, r_3) to Pi+1P_{i+1}
    • Each party now has a valid binary replicated sharing [x1,2]B[x_{1,2}]^B of (x1+x2modp)(x_1 + x_2 \mod p)
  • The parties compute a binary adder circuit of k=log2(p)k=\lceil \log_2(p)\rceil bits to sum up [x3]B[x_3]^B and [x1,2]B[x_{1,2}]^B to get [t1]B[t_1]^B with k+1k+1 bits (including overflow bit).
  • The parties compute the subtraction of [t1]Bp[t_1]^B - p inside a binary circuit to get [t2]B[t_2]^B.
  • The (k+1)(k+1)-th bit of [t2]B[t_2]^B indicates an overflow of the subtraction. If an overflow occurs, the result should be the first kk bits of [t1]B[t_1]^B, otherwise the first kk bits of [t2]B[t_2]^B. This if statement can be computed with a CMUX gate.

Binary to Arithmetic Conversion

For the binary to arithmetic conversion, the general strategy for replicated sharing is the following. We sample random binary shares [x2]B[x'_2]^B and [x3]B[x'_3]^B using the special correlated randomness, such that P3P_3 gets both values in addition to it's shares, while P1P_1 and P2P_2 get x3x'_3 and x2x'_2 in clear respectively. Then we compute a binary circuit to add [x1]B=BinAdd(BinAdd([x]B,[x2]B),[x3]B)[x_1]^B = \text{BinAdd}(\text{BinAdd}([x]^B, [x'_2]^B), [x'_3]^B). Finally, we open [x1]B[x_1]^B to P1P_1 and P2P_2. The arithmetic shares then are [x]=(x1,x2,x3)[x] = (x_1, -x'_2, -x'_3).

To account for modular reductions in finite fields, we follow a similar strategy as for the arithmetic to binary conversion to translate [x]B[x]^B:

  • PiP_i samples rir_i to be a new random binary share of 00
  • P1P_1 samples x3x'_3 using RNG2 and sets x3=x3x_3 = -x'_3;
  • P2P_2 samples x2x'_2 using RNG1 and sets x2=x2x_2 = -x'_2;
  • P3P_3 samples x2x'_2 using RNG1 and x3x'_3 using RNG2, sets x2=x2x_2 = -x'_2, x3=x3x_3 = -x'_3, and t=(x2+x3modp)r3t = (x'_2 + x'_3 \mod p) \oplus r_3;
    • It follows that (r1,t,r3)(r_1, t, r_3) is a valid binary sharing of (x2+x3modp)(x'_2 + x'_3 \mod p)
  • PiP_i sends its share of (r1,t,r3)(r_1, t, r_3) to Pi+1P_{i+1}
    • Each party now has a valid binary replicated sharing [x2,3]B[x'_{2,3}]^B of (x2+x3modp)(x'_2 + x'_3 \mod p)
  • The parties compute a binary adder circuit of k=log2(p)k=\lceil \log_2(p)\rceil bits to sum up [x]B[x]^B and [x2,3]B[x'_{2,3}]^B to get [t1]B[t_1]^B with k+1k+1 bits (including overflow bit).
  • The parties compute the subtraction of [t1]Bp[t_1]^B - p inside a binary circuit to get [t2]B[t_2]^B.
  • The (k+1)(k+1)-th bit of [t2]B[t_2]^B indicates an overflow of the subtraction. If an overflow occurs, [x1]B[x_1]^B should be the first kk bits of [t1]B[t_1]^B, otherwise the first kk bits of [t2]B[t_2]^B. This if statement can be computed with a CMUX gate.
  • We open [x1]B[x_1]^B to P1P_1 and P2P_2
  • The final sharing is [x]=(x1,x2,x3)[x] = (x_1, x_2, x_3) and each party has (only) access to the shares it requires for the replication.

Bit Injection

To translate a single shared bit [x]B[x]^B to a arithmetic sharing, we perform share splitting and create valid arithmetic shares of the shares: [x1]=(x1,0,0)[x_1] = (x_1, 0, 0), [x2]=(0,x2,0)[x_2] = (0, x_2, 0), and [x3]=(0,0,x3)[x_3] = (0, 0, x_3). Then, we combine the shares by calculating arithmetic XORs: [x]=AXor(AXor([x1],[x2]),[x3])[x] = \text{AXor}(\text{AXor}([x_1], [x_2]), [x_3]), where AXor(a,b)=a+b2ab\text{AXor}(a, b) = a + b - 2 \cdot a \cdot b.

Binary Addition Circuits

As mentioned in the arithmetic to binary conversions, we need binary addition circuits. Since the bitlength of the used prime fields is large, we use depth-optimized carry-lookahead adders for the conversions. Currently, we implement Kogge-Stone adders, since these can be computed efficiently using shifts and AND/XOR gates without extracting specific bits.

The general structure of a Kogge-Stone adder to add two binary values x,yx, y is to first compute p[i]=x[i]y[i]p[i] = x[i] \oplus y[i] and g[i]=x[i]y[i]g[i] = x[i] \wedge y[i], where x[i]x[i] is the ii-th bit of xx. Then, pp and gg are combined using a circuit with logarithmic depth (in the bitsize). This circuit is implemented in the kogge_stone_inner function.

For binary subtraction circuits, we basically compute an addition circuit with the two's complement of yy. Thus, we essentially compute 2k+xy2^k + x - y. If yy is public, the 2ky2^k - y can directly be computed and the result is just fed into the Kogge-Stone adder. If yy is shared, we invert all kk bits and set the carry-in flag for the Kogge-Stone adder. This simulates two's complement calculation. The set carry-in flag has the following effects: First, g[0]g[0] must additionally be XORed by p[0]p[0]. Finally, the LSB of the result of the Kogge-Stone circuit needs to be flipped.

Reconstruction

Reconstruction of a value is implemented as PiP_i sending zi1z_{i-1} to Pi+1P_{i+1}. Then each party has all shares.

Security

Our implementation provides semi-honest security with honest majority, i.e., the scheme is secure if all parties follow the protocol honestly and no servers collude.

Shamir Secret Sharing

Shamir secret sharing is a different way of instantiating a linear secret sharing scheme which is based on polynomials. To share a value xFpx\in\mathbb F_p, one first has to sample a random polynomial of degree tt, where xx is in the constant term. I.e., one samples a1,a2,...,ata_1, a_2, ..., a_t randomly from Fp\mathbb F_p and sets: Q(X)=x+a1X+a2X2+...+atXtQ(X) = x + a_1 \cdot X + a_2 \cdot X^2 + ... + a_t \cdot X^t. The share of party ii then is Q(i)Q(i). In other words, [x]t=(x1,x2,...,xn)[x]_t = (x_1, x_2, ..., x_n), where xi=Q(i)x_i=Q(i).

Reconstruction then works via lagrange interpolation of any t+1t+1 shares: x=it+1λixix = \sum_i^{t+1} \lambda_i x_i, where λi\lambda_i is the corresponding lagrange coefficient.

Supported operations

Linear Operations

Shamir's secret sharing allows, similar to additive sharing, to compute linear functions locally without party interaction:

  • Constant addition: [x]t+y=(x1+y,x2+y,x3+y)[x]_t + y = (x_1 + y, x_2 + y, x_3 + y)
  • Share addition: [x]t+[y]t=(x1+y1,x2+y2,x3+y3)[x]_t + [y]_t = (x_1 + y_1, x_2 + y_2, x_3 + y_3)
  • Constant Multiplication: [x]ty=(x1y,x2y,x3y)[x]_t \cdot y = (x_1\cdot y, x_2\cdot y, x_3\cdot y)

Multiplications

RNG Setup

For the degree reduction step after a multiplication we require degree-tt and degree-2t2t sharings of the same random value rr. We generate these values following the techniques proposed in DN07, to generate tt random pairs at once:

  • Each party PiP_i generates a random value sis_i and shares it as degree-tt share [si]t[s_i]_t and degree-2t2t share [si]2t[s_i]_{2t} to the other parties.
  • After receiving the all shares, one sets [s]t=([s1]t,[s2]t,...,[sn]t)T[\vec{s}]_t = ([s_1]_t, [s_2]_t, ..., [s_n]_t)^T and [s]2t=([s1]2t,[s2]2t,...,[sn]2t)T[\vec{s}]_{2t} = ([s_1]_{2t}, [s_2]_{2t}, ..., [s_n]_{2t})^T.
  • Calculate ([r1]t,[r2]t,...,[rt]t)T=M[s]t([r_1]_t, [r_2]_t, ..., [r_t]_t)^T = M \cdot [\vec{s}]_t and ([r1]2t,[r2]2t,...,[rt]2t)T=M[s]2t([r_1]_{2t}, [r_2]_{2t}, ..., [r_t]_{2t})^T = M \cdot [\vec{s}]_{2t}, where MFpt×nM\in\mathbb F_p^{t\times n} is a Vandermonde matrix.
  • The pairs ([ri]t,[ri]2t)([r_i]_t, [r_i]_{2t}) for 1it1\le i \le t are then valid random shares which can be used for resharing.

For simplicity we use the following Vandermonde matrix:

M=(111...1123...n12232...n212t3t...nt) M = \left(\begin{array}{ccccc} 1 & 1 & 1 & ... & 1 \\ 1 & 2 & 3 & ... & n \\ 1 & 2^2 & 3^2 & ... & n^2 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & 2^t & 3^t & ... & n^t \end{array}\right)

Reconstruction

Reconstruction is currently implemented as PiP_i sending its share xix_i to the next tt parties. Then, each party has t+1t+1 shares to reconstruct the secret.

Security

Our implementation provides semi-honest security with honest majority, i.e., the scheme is secure if all parties follow the protocol honestly and at most tt servers collude. tt can, thereby, be chosen to be tn12t\le \frac{n-1}{2}.

MPC for group operations

So far, we only discussed MPC for field elements Fp\mathbb F_p. However, one can easily extend it to MPC over Group elements G\mathbb G. W.l.o.g. we will use the notation for additive groups G\mathbb G (e.g., elliptic curve groups). A secret share [x]Fp[x]\in\mathbb F_p can be translated to a shared group element by [X]=[x]G[X] = [x] \cdot G, where GG is a generator of G\mathbb G. Then, [X]=(X1,X2,...,Xn)[X] = (X_1, X_2, ..., X_n) is a valid share of X=xGX=x\cdot G. Linear operations directly follow from the used linear secret sharing scheme: [Z]=a[X]+b[Y]+C=(a[x]+b[y]+c)G[Z] = a \cdot [X] + b\cdot [Y] + C = (a\cdot [x] + b\cdot [y] + c)\cdot G. Shared scalar multiplications also follow from the secret sharing scheme: [Z]=[x][Y]=[x][y]G[Z] = [x] \cdot [Y] = [x] \cdot [y] \cdot G.

Shamir vs Rep3

Shamir and Rep3 are both linear secret sharing schemes which provide semi-honest security with honest-majority. However, they have some important differences.

  • Shamir can be instantiated with n3n\ge 3 parties, while Rep3 is limited to n=3n=3 parties.
  • In Shamir, each share is just one field element Fp\in\mathbb F_p, while in Rep3 each share is composed of two field elements.
  • In Shamir, the overhead on the CPU is significantly smaller compared to Rep3, where each operation is applied to two shares.
  • Rep3 allows efficient arithmetic-to-binary conversions.

Witness Extension

Due to not having an efficient arithmetic to binary conversion, we do not have a witness extension implementation for Shamir sharing at the moment. However, we provide a bridge implementation, which can translate Rep3 shares to 3-party Shamir shares (with threshold/poly-degree t=1t=1).

This bridge works by first letting PiP_i translate its first additive share xix_i to a Shamir share by dividing by the corresponding lagrange coefficient. This, however, creates a 3-party Shamir sharing with threshold/poly-degree t=2t=2. Thus, we perform the same degree-reduction step, which is also required after a Shamir multiplication.

Footnotes

  1. ABY3: https://eprint.iacr.org/2018/403.pdf

  2. Shamir: https://web.mit.edu/6.857/OldStuff/Fall03/ref/Shamir-HowToShareASecret.pdf

  3. DN07: https://iacr.org/archive/crypto2007/46220565/46220565.pdf