/// <summary> /// Evaluates the shared secrets of secret with polynom of degree t and numberOfPlayers players. /// </summary> public static ShareDetails DetailedShare(Zp secret, int numPlayers, int polynomDeg) { if (numPlayers <= polynomDeg) throw new ArgumentException("Polynomial degree cannot be bigger or equal to the number of players"); // Creating the Random Polynomial - f(x) var randomMatrix = ZpMatrix.GetRandomMatrix(1, polynomDeg + 1, secret.Prime); // The free variable in the Random Polynomial( f(x) ) is the seceret randomMatrix.SetMatrixCell(0, 0, secret); // Create vanderMonde matrix var vanderMonde = ZpMatrix.GetPrimitiveVandermondeMatrix(polynomDeg + 1, numPlayers, secret.Prime); // Compute f(i) for the i-th player var sharesArr = randomMatrix.Times(vanderMonde).ZpVector; var details = new ShareDetails(randomMatrix.GetMatrixRow(0), sharesArr); return details; }
/// <summary> /// Evaluates the shared secrets of secret with polynom of degree t and numberOfPlayers players. /// </summary> public static ShareDetails DetailedShare(Zp secret, int numPlayers, int polynomDeg) { if (numPlayers <= polynomDeg) { throw new ArgumentException("Polynomial degree cannot be bigger or equal to the number of players"); } // Creating the Random Polynomial - f(x) var randomMatrix = ZpMatrix.GetRandomMatrix(1, polynomDeg + 1, secret.Prime); // The free variable in the Random Polynomial( f(x) ) is the seceret randomMatrix.SetMatrixCell(0, 0, secret); // Create vanderMonde matrix var vanderMonde = ZpMatrix.GetPrimitiveVandermondeMatrix(polynomDeg + 1, numPlayers, secret.Prime); // Compute f(i) for the i-th player var sharesArr = randomMatrix.Times(vanderMonde).ZpVector; var details = new ShareDetails(randomMatrix.GetMatrixRow(0), sharesArr); return(details); }
private IList<Zp> ConstructRxPolynomial(ShareDetails aSharesDetails, ShareDetails bSharesDetails, ShareDetails abSharesDetails, ShareDetails rSharesDetails) { var fax = aSharesDetails.RandomPolynomial; var fbx = bSharesDetails.RandomPolynomial; var hx = abSharesDetails.RandomPolynomial; var rx = rSharesDetails.RandomPolynomial; var RxPolynomial = new Zp[2 * PolynomialDeg + 1]; /* Initialize RxPolynomial coefs with zeros */ for (int i = 0; i < 2 * PolynomialDeg + 1; i++) RxPolynomial[i] = new Zp(Prime, 0); /* First calculate fax*fbx - hx */ for (int i = 0; i < fax.Count; i++) { Zp temp = fax[i]; for (int j = 0; j < fax.Count; j++) RxPolynomial[i + j].Add(temp.ConstMul(fbx[j])); RxPolynomial[i].Sub(hx[i]); } /* Calculate x*rx+fax*fbx - hx*/ for (int i = 0; i < rx.Count; i++) RxPolynomial[i + 1].Add(rx[i]); return new List<Zp>(RxPolynomial); }