private static IList <Zp> GenerateG_i_yPolynomial(ZpMatrix f_x_y, Zp secret, int playerNum) { int w = NumTheoryUtils.GetFieldMinimumPrimitive(secret.Prime); int w_i = NumTheoryUtils.ModPow(w, playerNum, secret.Prime); var x_values = new Zp[f_x_y.RowCount]; for (int i = 0; i < f_x_y.RowCount; i++) { x_values[i] = new Zp(secret.Prime, NumTheoryUtils.ModPow(w_i, i, secret.Prime)); } var tempArr = f_x_y.Times(new ZpMatrix(x_values, VectorType.Column)).ZpVector; return(tempArr); }
//public override void loadFromByteArrayNoHeader(BitStream bs, int prime) //{ // if (bs.readBoolean()) // fi_x = bs.readList(prime); // if (bs.readBoolean()) // gi_y = bs.readList(prime); //} //public override void writeToBitStreamNoHeader(BitStream bs) //{ // bs.writeBoolean(fi_x != null); // if (fi_x != null) // bs.writeList(fi_x); // bs.writeBoolean(gi_y != null); // if (gi_y != null) // bs.writeList(gi_y); //} //public override byte[] writeToByteArray() //{ // var bs = new BitStream(); // bs.writeMessageType(MessageType.ZP_LISTS); // writeToBitStreamNoHeader(bs); // bs.close(); // return bs.ByteArray; //} public virtual IList <Zp> CalculateF_i_xValuesForPlayers(int numOfPlayers, int prime) { int w_i, w = NumTheoryUtils.GetFieldMinimumPrimitive(prime); int value; var f_i_xValues = new List <Zp>(); for (int playerNum = 0; playerNum < numOfPlayers; playerNum++) { w_i = NumTheoryUtils.ModPow(w, playerNum, prime); value = 0; for (int j = 0; j < fi_x.Count; j++) { value += NumTheoryUtils.ModPow(w_i, j, prime) * fi_x[j].Value; } f_i_xValues.Add(new Zp(prime, value)); } return(f_i_xValues); }