Suppose we have a (5, 8) Shamir secret sharing scheme. Everything is mod the prime
Find the secret.
SOLUTION
One way: First, find the Lagrange interpolating polynomial through the five points:
> interp([9853,4421,6543,93293,12398],
[853,4387,1234,78428,7563],x)
−49590037201346405337547133788641510994876594882226797600000X4+3531308571691925577790733078919242767399658439658815119840000X3−882962897832113977107683736148119112663072999268084983175256800000X2+974904923047445071695080351981108144596213836998292198294075599200000X+20448432615404498323011459243394428259122298106918499146099147037799600000
Now evaluate at
> eval(%,x=0)
20448432615404498323011459243394428259122298106918499146099147037799600000
We need to change this to an integer mod 987541:
> % mod 987541
678987
Therefore, 678987 is the secret.
Here is another way. Set up the matrix equations as in the text and then solve for the coefficients of the polynomial mod 987541:
> map(x->x mod 987541,evalm(inverse(matrix(5,5,
[1,9853,
9853aˆ 2,9853aˆ 3,9853aˆ 4,1,4421,
4421aˆ 2,4421aˆ 3,4421aˆ 4,1,6543,
6543aˆ 2,6543aˆ 3,6543aˆ 4,1, 93293,
93293aˆ 2,93293aˆ 3,93293aˆ 4,1, 12398,
12398aˆ 2,12398aˆ 3,12398aˆ 4]))&*matrix(5,1,[853,4387,1234,78428,7563])))
⎡⎣⎢⎢⎢⎢⎢⎢678987147281651574413456741⎤⎦⎥⎥⎥⎥⎥⎥
The constant term is