# Secret sharing using the Chinese remainder theorem

Secret sharing consists of recovering a secret S from a set of shares, each containing partial information about the secret. The Chinese remainder theorem (CRT) states that for a given system of simultaneous congruence equations, the solution is unique in some Z/nZ, with n > 0 under some appropriate conditions on the congruences. Secret sharing can thus use the CRT to produce the shares presented in the congruence equations and the secret could be recovered by solving the system of congruences to get the unique solution, which will be the secret to recover.

## Secret sharing schemes: several types

There are several types of secret sharing schemes. The most basic types are the so-called threshold schemes, where only the cardinality of the set of shares matters. In other words, given a secret S, and n shares, any set of t shares is a set with the smallest cardinality from which the secret can be recovered, in the sense that any set of t − 1 shares is not enough to give S. This is known as a threshold access structure. We call such schemes (t, n) threshold secret sharing schemes, or t-out-of-n scheme.
Threshold secret sharing schemes differ from one another by the method of generating the shares, starting from a certain secret. The first ones are Shamir's threshold secret sharing scheme, which is based on polynomial interpolation in order to find S from a given set of shares, and George Blakley's geometric secret sharing scheme, which uses geometric methods to recover the secret S. Threshold secret sharing schemes based on the CRT are due to Mignotte and Asmuth–Bloom, they use special sequences of integers along with the CRT.

## Chinese remainder theorem

Let $k\geqslant 2,m_{1},...,m_{k}\geqslant 2$, and $b_{1},...,b_{k}\in \mathbf {Z}$. The system of congruences
    ${\begin{cases}x\equiv &b_{1}\ {\bmod {\ }}m_{1}\\&\vdots \\x\equiv &b_{k}\ {\bmod {\ }}m_{k}\\\end{cases}}$
has solutions in Z if and only if $b_{i}\equiv b_{j}{\bmod {}m_{i},m_{j})$ for all $1\leqslant i,j\leqslant k$, where $(m_{i},m_{j})$ denotes the greatest common divisor (GCD) of m$_i$ and m$_j$. Furthermore, under these conditions, the system has a unique solution in Z/nZ where $n=[m_{1},...,m_{k}]$, which denotes the least common multiple (LCM) of $m_{1},...,m_{k}$.

## Secret sharing using the CRT

Since the Chinese remainder theorem provides us with a method to uniquely determine a number S modulo k-many relatively prime integers $m_{1},m_{2},...,m_{k}$, given that S<∏$_{i=1}$$^k$m$_i${\textstyle S<\prod _{i=1}^{k}m_{i}}, then, the idea is to construct a scheme that will determine the secret S given any k shares (in this case, the remainder of S modulo each of the numbers m$_i$), but will not reveal the secret given less than k of such shares.
Ultimately, we choose n relatively prime integers $m_{1}<m_{2}<...<m_{n}$ such that S is smaller than the product of any choice of k of these integers, but at the same time is greater than any choice of k − 1 of them. Then the shares $s_{1},s_{2},...,s_{n}$ are defined by $s_{i}=S{\bmod {\ }}m_{i}$ for $i=1,2,...,n$. In this manner, thanks to the CRT, we can uniquely determine S from any set of k or more shares, but not from less than k. This provides the so-called threshold access structure.
This condition on S can also be regarded as
    $\prod _{i=n-k+2}^{n}m_{i}<S<\prod _{i=1}^{k}m_{i}.$
Since S is smaller than the smallest product of k of the integers, it will be smaller than the product of any k of them. Also, being greater than the product of the greatest k − 1 integers, it will be greater than the product of any k − 1 of them.
There are two secret sharing schemes that utilize essentially this idea, the Mignotte and Asmuth–Bloom schemes, which are explained below.

### Mignotte threshold secret sharing scheme

As said before, the Mignotte threshold secret sharing scheme uses, along with the CRT, special sequences of integers called the (k, n)-Mignotte sequences which consist of n integers, pairwise coprime, such that the product of the smallest k of them is greater than the product of the k − 1 biggest ones. This condition is crucial because the scheme is built on choosing the secret as an integer between the two products, and this condition ensures that at least k shares are needed to fully recover the secret, no matter how they are chosen.
Formally, let 2 ≤ k ≤ n be integers. A (k, n)-Mignotte sequence is a strictly increasing sequence of positive integers $m_{1}<\cdots <m_{n}$, with $(m_{i},m_{j})=1$ for all 1 ≤ i < j ≤ n, such that $m_{n-k+2}\cdots m_{n}<m_{1}\cdots m_{k}$. Let $\alpha =m_{n-k+2}\cdots m_{n}$ and $\beta =m_{1}\cdots m_{k}$; we call the integers lying strictly between $\alpha$ and $\beta$ the authorized range. We build a (k, n)-threshold secret sharing scheme as follows: We choose the secret S as a random integer $\alpha <S<\beta$ in the authorized range. We compute, for every 1 ≤ i ≤ n, the reduction modulo m$_i$ of S that we call s$_i$, these are the shares. Now, for any k different shares $s_{i_{1}},\ldots ,s_{i_{k}}$, we consider the system of congruences:
    ${\begin{cases}x\equiv &s_{i_{1}}\ {\bmod {\ }}m_{i_{1}}\\&\vdots \\x\equiv &s_{i_{k}}\ {\bmod {\ }}m_{i_{k}}\\\end{cases}}$
By the Chinese remainder theorem, since $m_{i_{1}},\ldots ,m_{i_{k}}$ are pairwise coprime, the system has a unique solution modulo $m_{i_{1}}\cdots m_{i_{k}}$. By the construction of our shares, this solution is nothing but the secret S to recover.

### Asmuth–Bloom threshold secret sharing scheme

This scheme also uses special sequences of integers. Let 2 ≤ k ≤ n be integers. We consider a sequence of pairwise coprime positive integers $m_{0}<...<m_{n}$ such that $m_{0}\cdot m_{n-k+2}\cdots m_{n}<m_{1}\cdots m_{k}$. For this given sequence, we choose the secret S as a random integer in the set Z/m$_0$Z.
We then pick a random integer α such that $S+\alpha \cdot m_{0}<m_{1}\cdots m_{k}$. We compute the reduction modulo m$_i$ of $S+\alpha \cdot m_{0}$, for all 1 ≤ i ≤ n, these are the shares $I_{i}=(s_{i},m_{i})$. Now, for any k different shares $I_{i_{1}},...,I_{i_{k}}$, we consider the system of congruences:
    ${\begin{cases}x\equiv &s_{i_{1}}\ {\bmod {\ }}m_{i_{1}}\\&\vdots \\x\equiv &s_{i_{k}}\ {\bmod {\ }}m_{i_{k}}\\\end{cases}}$
By the Chinese remainder theorem, since $m_{i_{1}},...,m_{i_{k}}$ are pairwise coprime, the system has a unique solution S$_0$ modulo $m_{i_{1}}\cdots m_{i_{k}}$. By the construction of our shares, the secret S is the reduction modulo m$_0$ of S$_0$.
It is important to notice that the Mignotte (k, n)-threshold secret-sharing scheme is not perfect in the sense that a set of less than k shares contains some information about the secret. The Asmuth–Bloom scheme is perfect: α is independent of the secret S and
    $\left.{\begin{array}{r}\prod _{i=n-k+2}^{n}m_{i}\\\alpha \end{array}}\right\$
Therefore α can be any integer modulo
    $\prod _{i=n-k+2}^{n}m_{i}.$
This product of k − 1 moduli is the largest of any of the n choose k − 1 possible products, therefore any subset of k − 1 equivalences can be any integer modulo its product, and no information from S is leaked.

### Example

The following is an example on the Asmuth–Bloom scheme. For practical purposes we choose small values for all parameters. We choose k = 3 and n = 4. Our pairwise coprime integers being $m_{0}=3,m_{1}=11,m_{2}=13,m_{3}=17$ and $m_{4}=19$. They satisfy the Asmuth–Bloom required sequence because $3\cdot 17\cdot 19<11\cdot 13\cdot 17$.
Say our secret S is 2. Pick $\alpha =51$, satisfying the required condition for the Asmuth–Bloom scheme. Then $2+51\cdot 3=155$ and we compute the shares for each of the integers 11, 13, 17 and 19. They are respectively 1, 12, 2 and 3. We consider one possible set of 3 shares: among the 4 possible sets of 3 shares we take the set {1, 12, 2} and show that it recovers the secret S = 2. Consider the following system of congruences:
    ${\begin{cases}x\equiv &1\ {\bmod {\ }}11\\x\equiv &12\ {\bmod {\ }}13\\x\equiv &2\ {\bmod {\ }}17\\\end{cases}}$
To solve the system, let $M=11\cdot 13\cdot 17$. From a constructive algorithm for solving such a system, we know that a solution to the system is $x_{0}=1\cdot e_{1}+12\cdot e_{2}+2\cdot e_{3}$, where each e$_i$ is found as follows:
By Bézout's identity, since $(m_{i},M/m_{i})=1$, there exist positive integers r$_i$ and s$_i$, that can be found using the Extended Euclidean algorithm, such that $r_{i}.m_{i}+s_{i}.M/m_{i}=1$. Set $e_{i}=s_{i}\cdot M/m_{i}$.
From the identities $1=1\cdot 221-20\cdot 11=(-5)\cdot 187+72\cdot 13=5\cdot 143+(-42)\cdot 17$, we get that $e_{1}=221,e_{2}=-935,e_{3}=715$, and the unique solution modulo $11\cdot 13\cdot 17$ is 155. Finally, $S=155\equiv 2\mod 3$.