3
Unconditional Cryptography

☆ Secret Sharing

DNS (for Domain Name System) maps human-memorable Internet domains like joyofcryptography.com to machine-readable IP addresses like 104.21.52.139. The traditional DNS protocol is not authenticated, meaning that a malicious DNS server could answer client queries with incorrect IP addresses. An extension to DNS, called DNSSEC, adds some cryptographic authentication to the protocol, to prevent this problematic behavior.

DNSSEC requires one “master key,” which holds authority over the entire Internet's DNS information. The organization that maintains the DNSSEC master key has chosen the following interesting backup strategy: The master key is split into seven pieces, with each piece given to a trusted human. In order to recover the key, one must combine any five of these seven pieces. On the other hand, combining any four of the seven pieces reveals no information about the key!

How is this possible? The answer is a primitive called a secret-sharing scheme, the topic of this chapter.

3.1. Defining secret sharing

Secret sharing is a way to encode a value M\ptxt into several pieces, called shares. The encoding is associated with a threshold value tt such that:

  • It is possible to recover M\ptxt from any tt of the shares.

  • Any collection of fewer than tt shares reveals nothing about M\ptxt.

It's often useful to think of one person, called the dealer, having the secret M\ptxt, generating the shares, and then distributing each share to a separate user. (This is not the only way to use secret sharing, but it is the easiest to talk about.)

We will number the users 1 through nn, and name the shares S1,,SnS_1, \ldots, S_n, with user ii receiving share SiS_i. Any subset U{1,,n}\mathcal{U} \subseteq \{1, \ldots, n\} can refer to a set of users, and we use the following notation to refer to their corresponding set of shares:

// shares belonging to users in U\U:
Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n):
for i=1i=1 to nn:
if i∉Ui \not\in \U: Si:=nullS_i := \mynull
return (S1,,Sn)(S_1, \ldots, S_n)

For example:

Filter({1,3,5},A,B,C,D,E)=(A,null,C,null,E);Filter({2,3,4},A,B,C,D,E)=(null,B,C,D,null).\begin{aligned} \Filter(\{1,3,5\}, \bit{A}, \bit{B}, \bit{C}, \bit{D}, \bit{E}) &= (\bit{A}, \mynull, \bit{C}, \mynull, \bit{E}); \\ \Filter(\{2,3,4\}, \bit{A}, \bit{B}, \bit{C}, \bit{D}, \bit{E}) &= (\mynull, \bit{B}, \bit{C}, \bit{D},\mynull).\end{aligned}

The reason we replace shares with null\mynull, rather than removing them altogether to make a shorter list, is that it preserves information about which share belongs to which user—information that can be used by the algorithm that recovers the secret from the shares.

Definition 3.1.1 (Secret sharing scheme: syntax & correctness)

A tt-out-of-nn secret sharing scheme consists of the following algorithms:

  • Share\Share: a randomized algorithm that takes a value MM\ptxt \in \M as input, and outputs a list of nn shares SSnS \in \mathcal{S}^n.

  • Reconstruct\Reconstruct: a deterministic algorithm that takes a partial list of shares S(S{null})nS \in (\mathcal{S} \cup \{\mynull\})^n as input, and outputs a value MM\ptxt \in \M.

The value tt is called the threshold of the scheme.

The scheme is correct if, for all MM\ptxt \in \M and all U{1,,n}\U \subseteq \{1, \ldots, n\} with U=t|\U| = t, we have:

Pr[Reconstruct(Filter(U,Share(M)))=M]=1. \PR{ \Reconstruct\Bigl( \Filter\bigl( \U, \Share(\ptxt)\bigr)\Bigr) = \ptxt } = 1.

In other words, the secret M\ptxt can be recovered just from the shares belonging to users U\U.

The goal of secret sharing is that any collection of fewer than tt shares should reveal nothing about the secret. We formalize this security requirement in an attack scenario in which a victim runs the Share\Share algorithm. Since the only input to the Share\Share algorithm is not a key, we can let the adversary have control over it. Next, the output of Share\Share is passed through the Filter\Filter function before being given to the adversary, to ensure that the adversary sees fewer than tt shares. Finally, we can rephrase the informal security goal in the real-or-random paradigm: Any collection of fewer than tt shares appears uniformly distributed (i.e., looks like random junk).

Thus, we define two libraries that give output Filter(U,S1,,Sn)\Filter( \U, S_1, \ldots, S_n) to the adversary. In one library, S1,,SnS_1, \ldots, S_n are valid shares, and in the other they are chosen uniformly. The question remains: Where does U\U come from? We want our security guarantee to apply no matter what U\U is used, as long as U<t|\U| < t. Thus, we simply let the adversary choose U\U. The library enforces the constraint U<t|\U| < t by simply returning an error if the adversary chooses U\U too large.

Definition 3.1.2 (Security for secret sharing schemes)

A tt-out-of-nn secret sharing scheme Σ\Sigma is secure if the following two libraries are interchangeable:

Lss-realΣ\lib{ss-real}^\Sigma
ss.share(M,U)\ssshare(\ptxt, \U):
if UΣ.t|\U| \ge \Sigma.t: return err\myerr
(S1,,Sn):=Σ.Share(M)(S_1, \ldots, S_n) := \Sigma.\Share(\ptxt)
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
\equiv
Lss-randΣ\lib{ss-rand}^\Sigma
ss.share(M,U)\ssshare(\ptxt, \U):
if UΣ.t|\U| \ge \Sigma.t: return err\myerr
for i=1i=1 to Σ.n\Sigma.n:
SiΣ.SS_i \gets \Sigma.\mathcal{S}
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)

A Bad Secret Sharing Scheme: The “obvious” way to split a secret is to simply chop it into pieces. The secret can then be reconstructed by concatenating these pieces. This obvious approach is not a secure secret sharing scheme!

Example 3.1.3 (Naïve secret sharing scheme)

The following is not a secure nn-out-of-nn secret sharing scheme:

M:={0,1}nk\M := \bits^{nk}
Share(M)\Share(\ptxt):
write S1S2Sn:=MS_1 \| S_2 \| \cdots \| S_n := \ptxt
// this means: chop M\ptxt into nn
// pieces, each kk bits long; SiS_i
// is the iith piece
return (S1,S2,,Sn)(S_1, S_2, \ldots, S_n)
\quad
// nn-out-of-nn scheme, so
// each SiS_i is non-null\mynull
Reconstruct(S1,,Sn)\Reconstruct(S_1, \ldots, S_n):
return S1SnS_1 \| \cdots \| S_n

In other words, the following two libraries are not interchangeable:

Lss-real\lib{ss-real}
ss.share(M,U)\ssshare(\ptxt, \U):
if Un|\U| \ge n: return err\myerr
// Share(M)\Share(\ptxt):
S1S2Sn:=MS_1 \| S_2 \| \cdots \| S_n := \ptxt
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
≢\not\equiv
Lss-rand\lib{ss-rand}
ss.share(M,U)\ssshare(\ptxt, \U):
if Un|\U| \ge n: return err\myerr
for i=1i=1 to nn:
Si{0,1}kS_i \gets \bits^k
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)

The reason is simple: Each share reveals some information about the secret! The first share reveals the first kk bits of M\ptxt, and so on. The attack is therefore quite simple:

A\A
M:=0nk\ptxt := \bit0^{nk}
U:={1,,n1}\U := \{1, \ldots, n-1\}
(S1,,Sn):=ss.share(M,U)(S_1, \ldots, S_n) := \ssshare(\ptxt,\U)
return S1==0kS_1 == \bit0^k

When A\A is linked to Lss-real\lib{ss-real}, S1S_1 contains the first kk bits of M=0nk\ptxt = \bit0^{nk}, which are all zeros. So A\A returns true\mytrue with probability 1 in this case. However, when A\A is linked to Lss-rand \lib{ss-rand}, S1S_1 is sampled uniformly from {0,1}k\bits^k, so A\A outputs true\mytrue only with probability 1/2k1/2^k.

3.2. 2-out-of-2 secret sharing

The simplest possible flavor of a secret sharing scheme is 2-out-of-2: The secret is split into two shares, both of which are needed to reconstruct the secret. Believe it or not, you've already seen a 2-out-of-2 secret sharing scheme: one-time pad! One share is the key, and the other is the ciphertext. The key alone reveals nothing about the plaintext; the ciphertext alone also reveals nothing about the plaintext. But by combining the two together in the right way, you can learn the plaintext.

Construction 3.2.1 (2-out-of-2 secret sharing based on OTP)

OTP secret sharing is defined by the following:

M={0,1}S={0,1}\begin{aligned} \M &= \bits^\ell \\ \mathcal{S} &= \bits^\ell \end{aligned}
\quad
Share(M)\Share(\ptxt):
S1{0,1}S_1 \gets \bits^\ell
S2:=S1MS_2 := S_1 \oplus \ptxt
return (S1,S2)(S_1, S_2)
\quad
// 2-out-of-2 scheme, so both
// shares must be present
Reconstruct(S1,S2)\Reconstruct(S_1,S_2):
return S1S2S_1 \oplus S_2

To see why construction 3.2.1 is correct, we can use the usual rules of xor:

Reconstruct(S1,S2)=S1S2=S1(S1M)=M. \Reconstruct(S_1, S_2) = S_1 \oplus S_2 = S_1 \oplus (S_1 \oplus \ptxt) = \ptxt.
Claim 3.2.2 (Security of OTP secret sharing)

Construction 3.2.1 is a secure 2-out-of-2 secret sharing scheme. In other words,

Lss-real\lib{ss-real}
ss.share(M,U)\ssshare(\ptxt, \U):
if U2|\U| \ge 2: return err\myerr
// (S1,S2):=Share(M)(S_1, S_2) := \Share(\ptxt)
S1{0,1}S_1 \gets \bits^\ell
S2:=S1MS_2 := S_1 \oplus \ptxt
return Filter(U,S1,S2)\Filter(\U, S_1, S_2)
\equiv
Lss-rand\lib{ss-rand}
ss.share(M,U)\ssshare(\ptxt, \U):
if U2|\U| \ge 2: return err\myerr
S1{0,1}S_1 \gets \bits^\ell
S2{0,1}S_2 \gets \bits^\ell
return Filter(U,S1,S2)\Filter(\U, S_1, S_2)
Proof:

The only legal choices for U\U are:

  • U=\U = \emptyset, causing ss.share\ssshare to output (null,null)(\mynull,\mynull),

  • U={1}\U = \{1\}, causing ss.share\ssshare to output (S1,null)(S_1,\mynull), and

  • U={2}\U=\{2\}, causing ss.share\ssshare to output (null,S2)(\mynull,S_2).

There is not much to say about the first case, but we need to show that in the other cases, the output share is distributed uniformly. The case of S1S_1 is simple, because Share\Share literally samples S1S_1 uniformly. The case of S2S_2 is exactly the one-time secrecy of OTP.

The Lss-*\lib{ss-*} libraries treat all choices of U\U in the same manner (this was the purpose of introducing the Filter\Filter function). But, as we just saw, different choices of U\U demand different justifications for their security. So the first step of our security proof introduces a hybrid library that handles the different cases of U\U in different branches of an if-statement. That way, we can apply different reasoning steps to these different parts of the library's code.

Hybrid Sequence:
The starting point is Lss-real\lib{ss-real}.
First, separate the cases for U\U into different branches of an if-statement. Within each branch, we can inline the behavior of Filter(U,)\Filter(\U,\cdot). These changes have no effect on the library's behavior.
S2S_2 is not used at all in the if-branch, so it can be removed without affecting the library's behavior.
The “else if" branch generates and returns a OTP encryption of M\ptxt, using S1S_1 as the key. We can use the security of OTP to show that the resulting output is uniform. In this three-hop maneuver, S1S_1 becomes K\key from the Lotp-real\lib{otp-real} library and S2S_2 becomes C\ctxt.
The branches of the if-statement can now be unified by writing them in terms of Filter\Filter. The result is Lss-rand\lib{ss-rand}, which completes the proof.
Lss-real\lib{ss-real}
ss.share\ssshare(M,U\ptxt, \U):
if U2|\U| \ge 2: return err\myerr
//
Share(M)\Share(\ptxt)
Filter({1},(S1,S2))\Filter\bigl(\{1\}, (S_1,S_2)\bigr):
S1{0,1}S_1 \gets \bits^\ell
S2S_2
:={}:= {}
S1MS_1 \oplus \ptxt
otp.enc(M)\otpenc(\ptxt)
{0,1}{}\gets \bits^\ell
return
Filter(U,S1,S2)\Filter(\U, S_1, S_2)
(null,S2)(\mynull, S_2)
Filter(U,S1,S2)\Filter(\U, S_1, S_2)
\link
Lotp-real\lib{otp-real}
otp.enc\otpenc(M\ptxt):
K{0,1}\key \gets \bits^\ell
C:=KM\ctxt := \key \oplus \ptxt
return C\ctxt
Lotp-rand\lib{otp-rand}
otp.enc\otpenc(M\ptxt):
C{0,1}\ctxt \gets \bits^\ell
return C\ctxt

3.3. Polynomial interpolation

You are probably familiar with the fact that two points determine a line. It is also true that three points determine a parabola, and so on. The final secret-sharing scheme in this chapter is based on the following principle:

d+1d+1 points determine a unique degree-dd polynomial.

Notation & Terminology

In this section, if FF is a polynomial that can be written as:

F(X)=cdXd+cd1Xd1++c0, F(X) = c_d X^d + c_{d-1} X^{d-1} + \cdots + c_0,

then we will describe FF as degree-dd. It would be more accurate to describe FF as a polynomial of degree at most dd, since the leading coefficient could be zero.

Throughout this section, we will use capital XX to denote the formal variable of a polynomial, and lowercase xix_i's to denote specific values/scalars.

The process of finding the polynomial that passes through a given set of points is called interpolation.

Theorem 3.3.1 (Polynomial interpolation)

Let {(x1,y1),,(xd+1,yd+1)}R2\{ (x_1, y_1), \ldots, (x_{d+1}, y_{d+1})\} \subseteq \mathbb{R}^2 be a set of points whose xix_i values are all distinct. Then there is a unique degree-dd polynomial F(X)F(X) with real coefficients that satisfies yi=F(xi)y_i = F(x_i) for all ii.

Proof:

As a warm-up, consider the following polynomial:

A(X)=(Xx2)(Xx3)(Xxd+1). A(X) = (X-x_2)( X - x_3) \cdots (X - x_{d+1}).

This is the product of dd terms, so it has degree dd. Additionally:

  • On input x1x_1, we get A(x1)=(x1x2)(x1x3)(x1xd+1)A(x_1) = (x_1 - x_2)(x_1 - x_3) \cdots (x_1 - x_{d+1}), which is nonzero because all of the xix_i values are distinct.

  • On input xix_i for i1i\ne 1, A(xi)A(x_i) includes a term (xixi)=0(x_i - x_i) = 0, so the output is zero.

Of course A(X)A(X) can be evaluated at any point, but we care only about its behavior on these special points.

Suppose we divide A(X)A(X) by the fixed, nonzero value A(x1)A(x_1):

L1(X)=(Xx2)(Xx3)(Xxd+1)(x1x2)(x1x3)(x1xd+1). \displaystyle L_1(X) = \frac{ (X-x_2)( X - x_3) \cdots (X - x_{d+1}) } { (x_1 - x_2)( x_1 - x_3) \cdots (x_1 - x_{d+1}) } .

The result is another degree-dd polynomial that satisfies:

L1(xi)={1 if i=10 if i1. L_1(x_i) = \begin{cases} 1 & \text{ if } i=1 \\ 0 & \text{ if } i\ne1 . \end{cases}

In the same way, we can define other polynomials LjL_j:

Lj(X)=(Xx1)(Xxj1)(Xxj+1)(Xxd+1)(xjx1)(xjxj1)(xjxj+1)(xjxd+1). \displaystyle L_j(X) = \frac{ (X-x_1) \cdots (X - x_{j-1}) (X - x_{j+1}) \cdots (X - x_{d+1}) } { (x_j-x_1) \cdots (x_j - x_{j-1}) (x_j - x_{j+1}) \cdots (x_j - x_{d+1}) } .

The pattern is that the numerator is “missing” the term (Xxj)(X - x_j) and the denominator is missing the term (xjxj)(x_j - x_j), to avoid dividing by zero. Polynomials of this kind are called Lagrange polynomials. They are all degree-dd, and they satisfy the property:

Lj(xi)={1 if i=j0 if ij. L_j(x_i) = \begin{cases} 1 & \text{ if } i=j \\ 0 & \text{ if } i\ne j. \end{cases}

Now consider the following polynomial:

F(X)=y1L1(X)+y2L2(X)++yd+1Ld+1(X). F(X) = y_1 L_1(X) + y_2 L_2(X) + \cdots + y_{d+1} L_{d+1}(X).

This F(X)F(X) is degree-dd since it is the sum of degree-dd polynomials (the yiy_i values are just scalars). Evaluating F(X)F(X) on one of the special xix_i values results in:

F(xi)=y1L1(xi)++yiLi(xi)++yd+1Ld+1(xi)=y10++yi1++yd+10=yi.\begin{aligned} F(x_i) &= y_1 L_1(x_i) + \cdots + y_i L_i(x_i) + \cdots + y_{d+1} L_{d+1}(x_i) \\ &= y_1 \cdot 0 + \cdots + y_i \cdot 1 + \cdots + y_{d+1} \cdot 0 \\ &= y_i.\end{aligned}

So F(xi)=yiF(x_i) = y_i for every xix_i; in other words, F(X)F(X) interpolates the given points.

Next, we show that FF is unique. Suppose some other polynomial FF' also interpolates the given points: F(xi)=F(xi)=yiF(x_i) = F'(x_i) = y_i for all i{1,,d+1}i \in \{1,\ldots, d+1\}. Then the polynomial G(X)=F(X)F(X)G(X) = F(X)-F'(X) also is degree-dd, and it satisfies G(xi)=0G(x_i) = 0 for all ii. In other words, G(X)G(X) has (at least) d+1d+1 roots. But the only degree-dd polynomial with d+1d+1 roots is the identically-zero polynomial G(X)=0G(X) = 0. If G(X)=0G(X)=0 then F=FF = F'; thus, FF is unique.

Example 3.3.2 (Polynomial interpolation)

What is the degree-3 polynomial that passes through the points (3,1)(3,1), (4,1)(4,1), (5,9)(5,9), and (2,6)(2,6)?

ii 1 2 3 4
xix_i 3 4 5 2
yiy_i 1 1 9 6

First, let's construct the appropriate Lagrange polynomials:

L1(X)=(X4)(X5)(X2)(34)(35)(32)=X311X2+38X402L2(X)=(X3)(X5)(X2)(43)(45)(42)=X310X2+31X302L3(X)=(X3)(X4)(X2)(53)(54)(52)=X39X2+26X246L4(X)=(X3)(X4)(X5)(23)(24)(25)=X312X2+47X606\begin{aligned} L_1(X) & = \frac{(X - 4)(X - 5)(X - 2)} {(3 - 4)(3 - 5)(3 - 2)} = \frac{X^3 - 11 X^2 + 38 X - 40} {2} \\[4pt] L_2(X) & = \frac{(X - 3)(X - 5)(X - 2)} {(4 - 3)(4 - 5)(4 - 2)} = \frac{X^3 - 10 X^2 + 31 X - 30} {-2} \\[4pt] L_3(X) & = \frac{(X - 3)(X - 4)(X - 2)} {(5 - 3)(5 - 4)(5 - 2)} = \frac{X^3 - 9 X^2 + 26 X - 24} {6} \\[4pt] L_4(X) & = \frac{(X - 3)(X - 4)(X - 5)} {(2 - 3)(2 - 4)(2 - 5)} = \frac{X^3 - 12 X^2 + 47 X - 60} {-6}\end{aligned}

Check for yourself that Lj(xi)=1L_j(x_i) = 1 if and only if i=ji=j. The next step is easier if we rewrite all Lagrange polynomials to have the same denominator 6:

L1(X)=3X333X2+114X1206;L3(X)=X39X2+26X246;L2(X)=3X3+30X293X+906;L4(X)=X3+12X247X+606.\begin{aligned} L_1(X) &= \frac{3 X^3 - 33 X^2 + 114 X - 120} {6} ; & L_3(X) &= \frac{X^3 - 9 X^2 + 26 X - 24} {6}; \\ L_2(X) &= \frac{-3X^3 + 30 X^2 - 93 X + 90} {6}; & L_4(X) &= \frac{-X^3 + 12 X^2 - 47 X + 60} {6}.\end{aligned}

Our desired polynomial is

F(X)=y1L1(X)+y2L2(X)+y3L3(X)+y4L4(X)=1L1(X)+1L2(X)+9L3(X)+6L4(X)=16(1(3X333X2+114X120)+1(3X3+30X293X+90)+9(3X39X2+26X24)+6(3X3+12X247X+60))=16(3X312X227X+114)=12(X34X29X+38).\begin{aligned} F(X) &= y_1 \cdot L_1(X) + y_2 \cdot L_2(X) + y_3 \cdot L_3(X) + y_4 \cdot L_4(X) \\ &= 1\cdot L_1(X) + 1\cdot L_2(X) + 9 \cdot L_3(X) + 6 \cdot L_4(X)\\ &= \frac 16 \left( \begin{array}{rrrr} 1\cdot\big( \phantom{{}-{}} 3 X^3 & {} - 33 X^2 & {} + 114X & {} -120 \big) \\ {}+ 1 \cdot\big( -3 X^3 & {} + 30 X^2 & {} - 93X & {} +90 \big) \\ {}+ 9 \cdot\big( \phantom{{}-3} X^3 &{} -9X^2 & {} + 26X & {} -24 \big) \\ {}+6 \cdot\big( \phantom{3} -X^3 & {} + 12X^2 & {} -47X & {} + 60 \big) \end{array} \right) \\ &= \frac16 \Bigl( 3 X^3 - 12 X^2 - 27 X + 114 \Bigr)\\[4pt] &= \frac12 \Bigl( X^3 - 4X^2 - 9X + 38 \Bigr).\end{aligned}

We can double-check that FF gives the correct values:

F(x1)=F(3)=12(3343293+38)=1=y1,F(x2)=F(4)=12(4344294+38)=1=y2,F(x3)=F(5)=12(5345295+38)=9=y3,F(x4)=F(2)=12(2342292+38)=6=y4.\begin{aligned} F(x_1) & = F(\hl{3}) = \frac12 ( \hl{3}^3 - 4 \cdot \hl{3}^2 - 9 \cdot \hl{3} + 38 ) = 1 = y_1, \\ F(x_2) & = F(\hl{4}) = \frac12 ( \hl{4}^3 - 4 \cdot \hl{4}^2 - 9 \cdot \hl{4} + 38 ) = 1 = y_2, \\ F(x_3) & = F(\hl{5}) = \frac12 ( \hl{5}^3 - 4 \cdot \hl{5}^2 - 9 \cdot \hl{5} + 38 ) = 9 = y_3, \\ F(x_4) & = F(\hl{2}) = \frac12 ( \hl{2}^3 - 4 \cdot \hl{2}^2 - 9 \cdot \hl{2} + 38 ) = 6 = y_4.\end{aligned}

3.4. Multiplicative inverses modulo a prime

Addition, subtraction, and multiplication are simple operations mod n\nmod. Just perform the operation over the integers and reduce the result mod n\nmod. In this way, we can define operations on Zn\Z_\nmod whose results are always in Zn\Z_\nmod. This section is about how to make sense of division mod n\nmod. How can we divide two numbers in Zn\Z_\nmod to obtain a result also in Zn\Z_\nmod?

It is helpful to rethink what an expression like “1/2” means in the first place. The best way to define “1/2” is the solution to the equation 2x=12x=1. Try to convince yourself that any time you divide by two, what you are really doing is multiplying by the value xx that satisfies 2x=12x=1.

Even though there is no solution to 2x=12x=1 in the integers, there could be a solution mod n\nmod. If xZnx \in \Z_\nmod satisfies 2xn12x \equiv_\nmod 1, then it is reasonable for us call xx “1/2.”

Example 3.4.1 (“1/2” under different moduli)
  • 6 is a solution to 2x1112 x \equiv_{11} 1. Thus, “1/2” in Z11\Z_{11} is 6.

  • 8 is a solution to 2x1512 x \equiv_{15} 1. Thus, “1/2” in Z15\Z_{15} is 8.

  • There is no solution to 2x1012 x \equiv_{10} 1. If xx is an integer, then 2x2x is even, and its remainder mod 10 is also even, and thus cannot equal 1. So “1/2” does not exist in Z10\Z_{10}.

More generally, dividing by bb is just multiplying by the xx that satisfies xb=1xb = 1. This special value xx is called the multiplicative inverse of bb.

Definition 3.4.2 (Multiplicative inverse)

xx is a multiplicative inverse of bb mod n\nmod if xbn1xb \equiv_\nmod 1. When this is the case, we often write xnb1x \equiv_\nmod \hl{b^{-1}}.

Example 3.4.3 (Multiplicative inverses)
  • 6 is an inverse of 2 mod 11, since 621116 \cdot 2 \equiv_{11} 1.

  • 3 is an inverse of 7 mod 10, since 371013 \cdot 7 \equiv_{10} 1.

  • 4 is its own inverse mod 15, since 441514 \cdot 4 \equiv_{15} 1.

3.4.1. Computing inverses

You might be disappointed if you write (1/2) % 11 (sometimes the operator is named mod) in your favorite programming language—the result might be 0.5. Your program divided 1/2 to get a real number (floating point) 0.5, then divided 0.5 by 11 and computed the remainder, which of course was 0.5.

We can always add, subtract, or multiply mod n\nmod by first performing the operation over the integers and then reducing the result mod n\nmod. This works because adding, subtracting, or multiplying integers always gives an integer result, But division of integers doesn't always result in an integer, so division mod n\nmod is not equivalent in general to dividing over the integers and reducing the result mod n\nmod.

So how can you actually compute inverses mod n\nmod? We discuss the algorithms behind modular inverses in more detail in chapter 15, but for now you can simply use a good numerical library. Numerical examples in this book will use SageMath (sagemath.org), an open-source system that uses Python syntax. Sage's built-in % operator is smart enough to do what we want:

sage: (1/2) % 11 6

Beware that Sage treats expressions like 1/2 and 0.5 differently:

sage: 0.5 % 11 0.500000000000000

Sage stores 1/2 as a rational number with exact precision (it stores the numerator and denominator separately as integers), instead of converting it to a floating point number. It can therefore interpret (a/b)%n(a/b) \pct \nmod as ab1%na b^{-1} \pct \nmod.

If you want to be even more explicit, you can define a Mod object, which “knows” that it lives in Zn\Z_\nmod and overloads its arithmetic operations to be the mod-n\nmod operations:

sage: x = Mod(2,11) sage: 1/x 6 sage: x + 100 3

A Mod object can be converted back into an integer with the lift method:

sage: x.lift() + 100 102

3.4.2. Prime moduli

We have seen examples where multiplicative inverses exist and other examples where they don't. If you want to know the rule that characterizes exactly when bb has a multiplicative inverse mod n\nmod, take a look at chapter 15. For this chapter, we only need to understand the case where the modulus is prime.

Claim 3.4.4 (Multiplicative inverses modulo a prime)

When n\nmod is a prime, every b{1,,n1}b \in \{1, \ldots, \nmod-1\} has a multiplicative inverse mod n\nmod.

This algebraic property is one reason prime numbers are useful in cryptography.

Proof:

For the sake of contradiction, suppose that none of the integers b,2b,3b,b, 2b, 3b, \ldots are congruent to 1 mod n\nmod. Reduce that sequence mod n\nmod to obtain:

b%p,(2a)%p,(3a)%n, b \pct p, \quad (2a) \pct p,\quad (3a) \pct \nmod,\quad \ldots

Each item in the sequence is an integer in the range {0,,n1}\{0, \ldots, \nmod-1\}, and we have assumed that no term is equal to 1. With only n1\nmod-1 values possible in this sequence, there must be a repeat within the first n\nmod terms:

(ib)%n=(jb)%n, for some distinct i,j{1,,n}. (i \cdot b) \pct \nmod = (j \cdot b) \pct \nmod, \text{ for some distinct $i,j \in \{1, \ldots, \nmod\}$.}

Equivalently,

ibnjb    ijbn0    n divides ijb. i \cdot b \equiv_\nmod j\cdot b \implies |i-j|\cdot b \equiv_\nmod 0 \implies\nmod \text{ divides } |i-j| \cdot b.

An important fact about primes is the following:

Fact 3.4.5 (Prime divisors)

If n\nmod is a prime, and uu and vv are integers such that nuv\nmod \mid uv, then nu\nmod \mid u or nv\nmod \mid v (or both).

From this fact, we can conclude that n\nmod divides either ij|i-j| or bb. But both ij|i-j| and bb are positive, and strictly less than n\nmod. (ij|i-j| is the difference of distinct elements of {1,,n}\{1, \ldots, \nmod\}.) This gives us the desired contradiction: n\nmod cannot divide a positive number smaller than itself.

Interpolation: In the previous section we proved that d+1d+1 points determine a unique degree-dd polynomial. More precisely, we proved the statement with respect to the real numbers. It is also true working modulo a prime:

Theorem 3.4.6 (Polynomial interpolation modulo a prime)

Let n\nmod be a prime, and let {(x1,y1),,(xd+1,yd+1)}(Zn)2\{ (x_1, y_1), \ldots, (x_{d+1}, y_{d+1})\} \subseteq {} \hl{(\Z_\nmod)}^2 be a set of points whose xix_i values are all distinct. Then there is a unique degree-dd polynomial F(X)F(X) with coefficients in Zn\Z_\nmod that satisfies yinF(xi)y_i \hl{\equiv_\nmod} F(x_i) for all ii.

Proof:

The proof is essentially the same as that of theorem 3.3.1. In that proof we defined the Lagrange polynomials as:

Lj(X)=(Xx1)(Xxj1)(Xxj+1)(Xxd+1)(xjx1)(xjxj1)(xjxj+1)(xjxd+1). \displaystyle L_j(X) = \frac{ (X-x_1) \cdots (X - x_{j-1}) (X - x_{j+1}) \cdots (X - x_{d+1}) } { (x_j-x_1) \cdots (x_j - x_{j-1}) (x_j - x_{j+1}) \cdots (x_j - x_{d+1}) } .

These expressions are valid modulo a prime; to be completely precise, you can imagine multiplying the numerator by the inverse of the denominator.

To prove that a unique polynomial interpolates the given points, we used the fact that the only degree-dd polynomial with more than dd roots is the identically zero polynomial. This fact is also true in Zn\Z_\nmod when n\nmod is prime, but we do not prove it here.

Example 3.4.7 (Polynomial interpolation modulo a prime)

Suppose we are interested in the polynomial that interpolates the points from the previous section's example, but this time in Z11\Z_{11}:

ii 1 2 3 4
xix_i 3 4 5 2
yiy_i 1 1 9 6

We previously computed the example over the real numbers as:

F(X)=12(X34X29X+38). \displaystyle F(X) = \frac12 ( X^3 - 4X^2 - 9 X + 38 ).

To get the answer in Z11\Z_{11} (i.e., a polynomial with coefficients in Z11\Z_{11}), just replace “division by 2” with “multiplication by 2's inverse mod 11,” which in this case is 6.

F(X)=12(X34X29X+38)116(X34X29X+38)116X32X210X+8.\begin{aligned} \displaystyle F(X) &= \frac12 ( X^3 - 4X^2 - 9 X + 38 ) \\ &\equiv_{11} 6 ( X^3 - 4X^2 - 9 X + 38 ) \\ &\equiv_{11} 6 X^3 - 2 X^2 - 10 X + 8.\end{aligned}

(If you like, you could also replace negative coefficients with positive ones by reducing mod 11, obtaining F(X)=6X3+9X2+X+8F(X) = 6X^3 + 9X^2 + X + 8.) We can double-check that FF gives the correct values:

F(x1)=F(3)=633232103+8=122111=y1,F(x2)=F(4)=643242104+8=320111=y2,F(x3)=F(5)=653252105+8=658119=y3,F(x4)=F(2)=623222102+8=280116=y4.\begin{aligned} F(x_1) & = F(\hl{3}) = 6 \cdot \hl{3}^3 - 2 \cdot \hl{3}^2 - 10 \cdot \hl{3} + 8 = 122 \equiv_{11} 1 = y_1, \\ F(x_2) & = F(\hl{4}) = 6 \cdot \hl{4}^3 - 2 \cdot \hl{4}^2 - 10 \cdot \hl{4} + 8 = 320 \equiv_{11} 1 = y_2, \\ F(x_3) & = F(\hl{5}) = 6 \cdot \hl{5}^3 - 2 \cdot \hl{5}^2 - 10 \cdot \hl{5} + 8 = 658 \equiv_{11} 9 = y_3, \\ F(x_4) & = F(\hl{2}) = 6 \cdot \hl{2}^3 - 2 \cdot \hl{2}^2 - 10 \cdot \hl{2} + 8 = 28\phantom{0} \equiv_{11} 6 = y_4.\end{aligned}
Example 3.4.8 (Polynomial interpolation in Sage)

To solve this example in Sage, you can do the following:

sage: R = PolynomialRing(Zmod(11), 'X') sage: R.lagrange_polynomial([ (3,1), (4,1), (5,9), (2,6) ]) 6*X^3 + 9*X^2 + X + 8

The first line establishes R as the set of polynomials with coefficients in Z11\Z_{11}, with formal variable X.

If you want to interpolate over the real numbers or rationals—and remember, it makes a difference in Sage—you can use RR or QQ in place of Zmod(11):

sage: R = PolynomialRing(RR, 'X') sage: R.lagrange_polynomial([ (3,1), (4,1), (5,9), (2,6) ]) 0.500000000000000*X^3 - 2.00000000000000*X^2 - 4.50000000000000*X + 19.0000000000000 sage: R = PolynomialRing(QQ, 'X') sage: R.lagrange_polynomial([ (3,1), (4,1), (5,9), (2,6) ]) 1/2*X^3 - 2*X^2 - 9/2*X + 19

3.5. Shamir secret sharing

This section introduces Shamir's secret sharing scheme, a tt-out-of-nn secret sharing scheme that cleverly uses polynomial interpolation. The idea is that the shares are points that all lie on the same degree-(t1)(t-1) polynomial Q(X)Q(X). We have seen that any tt such points uniquely determine Q(X)Q(X). The secret is just another special point on the polynomial, usually Q(0)Q(0).

To share a secret M\ptxt, the dealer must choose a polynomial Q(X)Q(X) of degree t1t-1 satisfying Q(0)=MQ(0)=\ptxt. It does this by fixing QQ's constant coefficient to be M\ptxt and choosing the t1t-1 other coefficients uniformly at random from Zp\Z_\pmod, where p\pmod is a prime. Then the nn shares are Q(1),,Q(n)Q(1), \ldots, Q(n), with all operations taken mod p\pmod.

Construction 3.5.1 (Shamir secret sharing)

Let p\pmod be a prime and let tt and nn be integers with tn<pt \le n < \pmod. Then Shamir secret sharing consists of the following algorithms and parameters M=S=Zp\M = \mathcal{S} = \Z_\pmod:

Share(M)\Share(\ptxt):
// uniformly chosen degree-(t1)(t-1)
// polynomial with Q(0)=MQ(0) = \ptxt
q0:=Mq_0 := \ptxt
for i=1i = 1 to t1t-1:
qiZpq_i \gets \Z_\pmod
Q(X):=qt1Xt1++q0Q(X) := q_{t-1} X^{t-1} + \cdots + q_0
for i=1i = 1 to nn:
Si:=Q(i)%pS_i := Q(i) \pct \pmod
return (S1,,Sn)(S_1, \ldots, S_n)
// expect tt of the SiS_i's to be non-null\mynull
Reconstruct(S1,,Sn)\Reconstruct(S_1, \ldots, S_n):
for i=1i=1 to nn:
if SinullS_i \ne \mynull:
I:=I{(i,Si)}\mathcal{I} := \mathcal{I} \cup \{ (i, S_i) \}
// I\mathcal{I} = points on which to interpolate
Q(X):=unique degree-(t1)polynomial interpolatingpoints in I\begin{aligned}Q(X) := {} & \text{unique degree-}(t-1) \\[-3pt] & \text{polynomial interpolating} \\[-3pt] & \text{points in } \mathcal{I}\end{aligned}
return Q(0)%pQ(0) \pct \pmod

The restriction n<pn < \pmod comes from the fact that the shares are Q(1),,Q(n)Q(1), \ldots, Q(n) and the secret is Q(0)Q(0), so the numbers {0,,n}\{0, \ldots, n\} must be distinct mod p\pmod.

Example 3.5.2 (Shamir secret sharing)

Here is an example of 4-out-of-7 Shamir sharing over Z11\Z_{11}. Suppose the secret is M=8\ptxt = 8, then the Share\Share algorithm will define a polynomial Q(X)Q(X) by sampling t1=3t-1 = 3 coefficients q1,q2,q3q_1, q_2, q_3 and fixing coefficient q0=M=8q_0 = \ptxt = 8. Suppose the results are

q1=1,q2=9,q3=6, q_1 = 1, \qquad q_2 = 9, \qquad q_3 = 6,

and so the secret polynomial is Q(X)=6X3+9X2+X+8Q(X) = 6 X^3 + 9 X^2 + X + 8. The 7 shares are:

Q(1)=613+912+1+8113,Q(5)=653+952+5+8119,Q(2)=623+922+2+8116,Q(6)=663+962+6+8116,Q(3)=633+932+3+8111,Q(7)=673+972+7+8116,Q(4)=643+942+4+8111.\begin{aligned} Q(1) &= 6 \cdot \hl{1}^3 + 9 \cdot \hl{1}^2 + \hl{1} + 8 \equiv_{11} 3, & Q(5) &= 6 \cdot \hl{5}^3 + 9 \cdot \hl{5}^2 + \hl{5} + 8 \equiv_{11} 9, \\ Q(2) &= 6 \cdot \hl{2}^3 + 9 \cdot \hl{2}^2 + \hl{2} + 8 \equiv_{11} 6, & Q(6) &= 6 \cdot \hl{6}^3 + 9 \cdot \hl{6}^2 + \hl{6} + 8 \equiv_{11} 6, \\ Q(3) &= 6 \cdot \hl{3}^3 + 9 \cdot \hl{3}^2 + \hl{3} + 8 \equiv_{11} 1, & Q(7) &= 6 \cdot \hl{7}^3 + 9 \cdot \hl{7}^2 + \hl{7} + 8 \equiv_{11} 6, \\ Q(4) &= 6 \cdot \hl{4}^3 + 9 \cdot \hl{4}^2 + \hl{4} + 8 \equiv_{11} 1.\end{aligned}

Any four of these shares can be combined to reconstruct the secret. Suppose users 2, 3, 4, and 5 combine their shares Q(2),Q(3),Q(4),Q(5)Q(2), Q(3), Q(4), Q(5). They use polynomial interpolation to recover Q(X)Q(X) — in this case, their computation is precisely what is described in example 3.4.7. Upon recovering Q(X)Q(X), they evaluate it at zero to obtain the secret q0=8q_0 = 8.

Next, we turn our attention to the security of Shamir secret sharing. We must show that if you see less than tt shares, then those shares look like random junk.

Claim 3.5.3 (Security of Shamir secret sharing)

Shamir secret sharing (construction 3.5.1) is a secure secret sharing scheme. That is, the following libraries are interchangeable:

Lss-real\lib{ss-real}
ss.share(M,U)\ssshare(\ptxt, \U):
if Ut|\U| \ge t: return err\myerr
// (S1,,Sn):=Share(M)(S_1, \ldots, S_n) := \Share(\ptxt):
q0:=Mq_0 := \ptxt
for i=1i = 1 to t1t-1:
qiZpq_i \gets \Z_\pmod
Q(X):=qt1Xt1++q0Q(X) := q_{t-1} X^{t-1} + \cdots + q_0
for i=1i = 1 to nn:
Si:=Q(i)%pS_i := Q(i) \pct \pmod
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
\equiv
Lss-rand\lib{ss-rand}
ss.share(M,U)\ssshare(\ptxt, \U):
if Ut|\U| \ge t: return err\myerr
for i=1i=1 to nn:
SiZpS_i \gets \Z_\pmod
return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
Proof:

Rather than showing a sequence of hybrids, for this proof we will reason directly about output probabilities, similar to our security proof for OTP in chapter 1. The output of ss.share(M,U)\ssshare(\ptxt,\U) is a list containing Zp\Z_\pmod-elements in the positions given by U\U and null\mynull everywhere else (assuming U<t|\U| < t). Thus, there are pU\pmod^{|\U|} outputs possible for a specific choice of U\U, and our goal is to show that the output of ss.share\ssshare is uniformly distributed among these possibilities.

We will consider only the case where U=t1|\U| = t-1; exercise 3.1 asks you to show that this special case implies security in general. We will show that for any MZp\ptxt \in \Z_\pmod and any U=t1|\U| = t-1, the output of ss.share(M,U)\ssshare(\ptxt,\U) is uniformly distributed, among the pt1\pmod^{t-1} possibilities that are consistent with this choice of U\U.

Fix a particular MZp\ptxt \in \Z_\pmod and U{1,,n}\U \subseteq \{1,\ldots, n\} with U=t1|\U| = t-1, and a particular list (S1,,Sn)(S_1, \ldots, S_n) that consists of Zp\Z_\pmod-elements in the positions given in U\U and contains null\mynull everywhere else. It suffices to prove that:

Pr[ss.share(M,U)=(S1,,Sn)]=1/pt1. \PR{ \ssshare(\ptxt,\U) = (S_1, \ldots, S_n) } = 1/\pmod^{t-1}.

This event happens only when Share\Share chooses a polynomial Q(X)Q(X) such that Q(i)pSiQ(i) \equiv_\pmod S_i for all iUi \in \U. Additionally, Share\Share always chooses a polynomial satisfying Q(0)pMQ(0) \equiv_\pmod \ptxt. But there is only one Q(X)Q(X) of degree t1t-1 that interpolates these tt specific values. So the probability that ss.share(M,U)=(S1,,Sn)\ssshare(\ptxt,\U) = (S_1, \ldots, S_n) is exactly the probability that Share\Share chooses this one particular polynomial Q(X)Q(X). But Share\Share chooses each coefficient q1,,qt1q_1, \ldots, q_{t-1} uniformly from Zp\Z_\pmod, and they will match the coefficients of this particular Q(X)Q(X) with probability 1/pt11/\pmod^{t-1}. Thus, the output of ss.share\ssshare is uniformly distributed.

Exercises

  1. The libraries in definition 3.1.2 require the adversary to choose U\U with U<t|\U| < t. When this is not the case, they return an error.

    Prove that it suffices to restrict the adversary to U\U with U=t1|\U| = t-1. In other words, if Σ\Sigma is a secret sharing scheme for which the following libraries are interchangeable, then Σ\Sigma is also secure according to definition 3.1.2.

    ss.share(M,U)\ssshare(\ptxt, \U):
    if Ut1|\U| \ne t-1: return err\myerr
    (S1,,Sn):=Σ.Share(M)(S_1, \ldots, S_n) := \Sigma.\Share(\ptxt)
    return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
    \equiv
    ss.share(M,U)\ssshare(\ptxt, \U):
    if Ut1|\U| \ne t-1: return err\myerr
    for i=1i=1 to nn:
    SiΣ.SS_i \gets \Sigma.\mathcal{S}
    return Filter(U,S1,,Sn)\Filter(\U, S_1, \ldots, S_n)
    ,,
  2. There are three major divisions at PizzaCorp: the crust division, the sauce division, and the cheese division. Each division has an executive board consisting of five people. The CEO of PizzaCorp would like to divide the secret family recipe among the executives so that they can recover it only if a majority of executives from each division cooperate. If any division does not have a majority of executives present, then nobody should learn anything about the secret recipe.

    Assuming that the CEO is aware of tt-out-of-nn secret sharing schemes, describe clearly how they can distribute values to the executives to achieve the desired outcome, and describe how the executives will recover the secret. You should give some informal reasoning about the security of your proposal, but the CEO of PizzaCorp is not interested in hearing a formal security proof.

  3. Propose a security definition for secret sharing, using the left-or-right paradigm (section 2.7). Formally prove that if a secret sharing scheme satisfies the real-or-random definition (definition 3.1.2), then it also satisfies your definition.

  4. Suppose a tt-out-of-nn secret sharing scheme has message space M\M and share space S\mathcal{S}. Prove that if the scheme is secure, then MS|\M| \le |\mathcal{S}|. Use exercise 2.14 as inspiration.

  5. Generalize construction 3.2.1 to the nn-out-of-nn case. Propose an nn-out-of-nn secret sharing scheme and prove that it is secure.

  6. Let Σ3\Sigma_3 be a 3-out-of-3 secret sharing scheme, and Σ2\Sigma_2 be a 2-out-of-2 secret sharing scheme that is capable of sharing shares from Σ3\Sigma_3 (i.e., Σ3.SΣ2.M\Sigma_3.\mathcal{S} \subseteq \Sigma_2.\M). In this exercise we consider the following 2-out-of-3 scheme Σ\Sigma^*:

    Σ.Share(M)\Sigma^*.\Share(\ptxt):
    (S1,S2,S3):=Σ3.Share(M)(S_1, S_2, S_3) := \Sigma_3.\Share(\ptxt)
    (T12,T13):=Σ2.Share(S1)(T_{1\to2}, T_{1\to3}) := \Sigma_2.\Share(S_1)
    (T21,T23):=Σ2.Share(S2)(T_{2\to1}, T_{2\to3}) := \Sigma_2.\Share(S_2)
    (T31,T32):=Σ2.Share(S3)(T_{3\to1}, T_{3\to2}) := \Sigma_2.\Share(S_3)
    S1:=(S1,T21,T31)S^*_1 := (S_1, T_{2\to1}, T_{3\to1})
    S2:=(S2,T12,T32)S^*_2 := (S_2, T_{1\to2}, T_{3\to2})
    S3:=(S3,T13,T23)S^*_3 := (S_3, T_{1\to3}, T_{2\to3})
    return (S1,S2,S3)(S^*_1, S^*_2, S^*_3)
    1. Describe the corresponding Σ.Reconstruct\Sigma^*.\Reconstruct algorithm.

    2. Prove that Σ\Sigma^* is a secure 2-out-of-3 secret sharing scheme.

  7. Let Σss\Sigma_{\text{ss}} be a 2-out-of-2 secret sharing scheme, and let Σske-1\Sigma_{\text{ske-1}} and Σske-2\Sigma_{\text{ske-2}} be encryption schemes with plaintext spaces Σske-1.M=Σske-2.M=Σss.S\Sigma_{\text{ske-1}}.\M = \Sigma_{\text{ske-2}}.\M = \Sigma_{\text{ss}}.\mathcal{S}; in other words, Σske-1\Sigma_{\text{ske-1}} and Σske-2\Sigma_{\text{ske-2}} can encrypt shares from Σss\Sigma_{\text{ss}}. Define the following new encryption scheme Σ\Sigma^*:

    K=Σske-1.K×Σske-2.KM=Σss.MC=Σske-1.C×Σske-2.C\begin{aligned}\K &= \Sigma_{\text{ske-1}}.\K \times \Sigma_{\text{ske-2}}.\K \\ \M &= \Sigma_{\text{ss}}.\M \\ \C &= \Sigma_{\text{ske-1}}.\C \times \Sigma_{\text{ske-2}}.\C\end{aligned}
    Enc((K1,K2),M)\Enc\bigl( (\key_1,\key_2), \ptxt \bigr):
    (S1,S2):=Σss.Share(M)(S_1, S_2) := \Sigma_{\text{ss}}.\Share(\ptxt)
    C1:=Σske-1.Enc(K1,S1)\ctxt_1 := \Sigma_{\text{ske-1}}.\Enc(\key_1, S_1)
    C2:=Σske-2.Enc(K2,S2)\ctxt_2 := \Sigma_{\text{ske-2}}.\Enc(\key_2, S_2)
    return (C1,C2)(\ctxt_1, \ctxt_2)
    \quad
    Dec((K1,K2),(C1,C2))\Dec\bigl( (\key_1,\key_2), (\ctxt_1, \ctxt_2) \bigr):
    S1:=Σske-1.Dec(K1,C1)S_1 := \Sigma_{\text{ske-1}}.\Dec(\key_1, \ctxt_1)
    S2:=Σske-2.Dec(K2,C2)S_2 := \Sigma_{\text{ske-2}}.\Dec(\key_2, \ctxt_2)
    M:=Σss.Reconstruct(S1,S2)\ptxt := \Sigma_{\text{ss}}.\Reconstruct(S_1, S_2)
    return M\ptxt
    1. Prove that Σ\Sigma^* has left-or-right one-time secrecy (definition 2.7.1) if Σss\Sigma_{\text{ss}} is a secure secret sharing scheme, and either of Σske-1,Σske-2\Sigma_{\text{ske-1}}, \Sigma_{\text{ske-2}} has left-or-right one-time secrecy. Your proof should involve two cases: In the first case, assume that Σske-1\Sigma_{\text{ske-1}} is secure, but assume nothing about Σske-2\Sigma_{\text{ske-2}}. Then repeat, swapping the roles of Σske-1\Sigma_{\text{ske-1}} and Σske-2\Sigma_{\text{ske-2}}.

    2. Why do you suppose this question asks about left-or-right security rather than real-or-random?

  8. Generalize the previous exercise to the tt-out-of-nn case. Given nn different encryption schemes, describe how to construct a new encryption scheme that has (left-or-right) one-time secrecy if any tt of the underlying schemes do. Prove security of your construction. Be careful about choosing the threshold for any secret sharing scheme you use.

  9. It is not necessary to compute the entire polynomial during the reconstruction phase of Shamir secret sharing. All that is needed is the value Q(0)Q(0). Given x1,,xtx_1, \ldots, x_t, all distinct and all nonzero, show how to construct coefficients c1,,ctc_1, \ldots, c_t such that

    Q(0)=c1Q(x1)+c2Q(x2)++ctQ(xt), Q(0) = c_1 Q(x_1) + c_2 Q(x_2) + \cdots + c_t Q(x_t),

    for all degree-(t1)(t-1) polynomials QQ. To be clear, the cic_i coefficients depend only on the xix_i's but not on QQ.

  10. We didn't prove that multiplicative inverses are unique mod n\nmod. Prove the following: If xx and xx' are both multiplicative inverses of bb mod n\nmod, then xnxx \equiv_\nmod x'.

  11. Prove that if n\nmod is composite, then there is some integer b{1,,n1}b \in \{1, \ldots, \nmod-1\} that does not have a multiplicative inverse mod n\nmod.

  12. Give an example of a nonzero, degree-dd polynomial over Zn\Z_\nmod that has more than dd roots. Of course, n\nmod cannot be prime.

  13. Let n\nmod be a prime and consider the following variant of OTP:

    K=M=C={1,,n1}\K = \M = \C = \{1, \ldots, \nmod-1\}
    \quad
    Enc(K,M)\Enc(\key,\ptxt):
    C:=KM%n\ctxt := \key \cdot \ptxt \pct \nmod
    return C\ctxt
    1. Give the corresponding Dec\Dec algorithm and show that it is correct.

    2. Prove that the scheme has one-time secrecy.

  14. Below are parameters for Shamir's secret sharing scheme along with a set of shares. What is the secret, and what are the missing shares?

    n=10,t=4,p=16261100728086947379516237825246528373,S3=3256621440428047006295920894879234328,S5=14962107319351742694230294996446466335,S6=12284280758146456039859693602767230420,S9=2618242661644870291239011221231862685.\begin{aligned} n &= 10, \\ t &= 4, \\ \pmod &= 16261100728086947379516237825246528373, \\ S_3 &= 3256621440428047006295920894879234328, \\ S_5 &= 14962107319351742694230294996446466335, \\ S_6 &= 12284280758146456039859693602767230420, \\ S_9 &= 2618242661644870291239011221231862685.\end{aligned}
  15. h Suppose nn users hold secret shares of M\ptxt and M\ptxt', generated by Shamir's scheme with the same threshold tt and same prime p\pmod. Each user holds a share of M\ptxt and a share of M\ptxt'. Prove that if each user locally adds their shares (mod p\pmod), the result is a valid sharing of M+M%p\ptxt + \ptxt' \pct \pmod. In other words, prove that the following procedure always outputs M+M%p\ptxt + \ptxt' \pct \pmod:

    (S1,,Sn):=Share(M)(S_1, \ldots, S_n) := \Share(\ptxt)
    (S1,,Sn):=Share(M)(S'_1, \ldots, S'_n) := \Share(\ptxt')
    for i=1i=1 to nn:
    Si:=(Si+Si)%pS^*_i := (S_i + S'_i) \pct \pmod
    output Reconstruct(S1,,Sn)\Reconstruct(S^*_1, \ldots, S^*_n)

    What polynomial do the new shares lie on?

  16. Implement the algorithms of Shamir secret sharing in Sage.

  17. h Secret sharing schemes must satisfy two properties: (1) any collection of tt shares is enough to reconstruct the secret; (2) any collection of t1t-1 shares reveals no information about the secret. Suppose we are interested only in condition (1) and not (2). Describe a way to split an \ell-bit secret into nn “shares” of length roughly /t\ell/t (not \ell), so that the secret can be reconstructed from any collection of tt shares. Unlike in secret sharing, these “shares” are now allowed to leak information about the “secret.” As such, there is no security property to prove.

    Instead of encoding the target value as Q(0)Q(0), encode it as the entire polynomial QQ.

Chapter Notes

Secret sharing was proposed independently by Shamir [200] and by Blakley [47]. The scheme from [200] is the ubiquitous one still known as Shamir's scheme.

When you must choose from several reasonable choices for a cryptographic algorithm, you may live in fear that your chosen algorithm is broken. A combiner is a way to combine several cryptographic algorithms into a single algorithm that is secure if at least one of its components is secure, even if all the others are broken. Exercise 3.7 describes a simple combiner for one-time secrecy. Several other exercises throughout the book explore combiners for other primitives. Cryptographic combiners were first explicitly studied by Herzberg [121], who called them “tolerant” constructions. The term “combiner” is due to Harnik, Kilian, Naor, Reingold, and Rosen [120].

The problem in exercise 3.17 is called information dispersal, and was introduced by Rabin [186].

  1. Previous Chapter2. Rudiments of Provable Security
  2. Next Chapter4. Modern Computational Cryptography