I'm implementing Shamir secret sharing in C using OpenSSL.
I've split up the private key and I'm ready to start decrypting the original message using some of the shares. I set $n = 5$ (5 shares total) and $t = 3$ (3 shares required to decrypt).
The way my encrypted message is stored is in a ${\rm msg} = (c_1, c_2)$ format, so I don't think I can just follow the example on Wikipedia, though I may be mistaken. Here is how my book tells me to do it (image). I've highlighted the particular part I'm stuck on:
"The dealer then sends $\langle i, s_i \rangle$ to authority $i$ in a secure manner.
To collectively decrypt an encrypted ballot $c$, where $c = (c_1=g \bmod p, c_2 = Y^r \times m \bmod p)$, $t$ such election authorities $\{i_1, i_2, \dotsc, i_t\}$, where $1 \le i_j \le n$, for $1 \le j \le t$, perform the following calculations (Desmedt & Frankel, 1990):
- Each entity uses its share $s_{i_j}$ to calculate $\alpha_{i_j} = c_1^{i_j} \bmod p$ and broadcasts it.
- Each entity calculates $c_{i_j} = \displaystyle \prod_{1 \le k \le t, k \ne j} \frac{i_k}{i_k - i_j} \bmod q$ $\color{red}{(\Leftarrow \text{HERE})}$ and $\mu_1 = \displaystyle \prod_{j=1}^t \alpha_{i_j}^{c_{i_j}} \bmod p$. Note that $\mu_1 = c_1^s \bmod p$.
- Each entity calculates $\mu2 = \mu1-1 \bmod p$ and $m' = \mu2 \times c2 \bmod p$, where $m'$ is the recovered ballot."
In this portion, I'm confused by the values $i_k$ and $i_j$. It seems to indicate that $1 \le i_j\leq n$ (values 1–5). Then it says $1 \le j \le t$ (values 1–3). Can someone straighten me out?
Let's say I'm using the following keys, just for reference:
- Key #2 | 1234
- Key #4 | 4567
- Key #5 | 5678
Final question: do I need to $\bmod$ each result, or just the final sum?