private BigIntMatrix CreateUserQuery(BigIntMatrix[] Ms, BigInteger[,] splitted, int N, long n, BigInteger p) { int len = splitted.GetLength(0) * splitted.GetLength(1); BigIntMatrix Mat = new BigIntMatrix(len, 2 * N, 0); int l = 0; for (long i = 0; i < n; i++) { for (long j = 0; j < N; j++) { for (int k = 0; k < 2 * N; k++) { //BigInteger num = BigInteger.Remainder(BigInteger.Multiply(splitted[i][j], Ms[i, j, k]), p); BigInteger tmp = BigInteger.Multiply(splitted[i, j], Ms[i].GetElement(j, k)); Mat.SumElement(l, k, tmp); //V[0, k] = MyClass.mod((long)V[0, k], p); } l++; } } return(Mat.Modulus(p)); }
public BigIntMatrix getAndProcessRequest(BigIntMatrix[] Ms, int l0, int N, BigInteger p) { txtLog.AppendText("---------------------------- Server Started query process --------------------------"); Stopwatch sw = new Stopwatch(); sw.Start(); BigInteger[,] splittedList = spliteDB(l0, ll, N); /******* show splited list ****** * for (long i = 0; i < splittedList.GetLength(0); i++) * { * txtLog.AppendText(">>>>>>>>>> Splited Item({0})...", i); * for (long j = 0; j < splittedList.GetLength(1); j++) * { * txtLog.AppendText("> Splited({0}): {1}", j, splittedList[i,j]); * } * } * /*****************************/ BigIntMatrix Mat = CreateUserQuery(Ms, splittedList, N, n, p); BigIntMatrix V = new BigIntMatrix(1, 2 * N, 0); long len = splittedList.GetLength(0) * splittedList.GetLength(1); for (int i = 0; i < len; i++) { for (int j = 0; j < 2 * N; j++) { V.SumElement(0, j, Mat.GetElement(i, j)); } } sw.Stop(); Protocol2Time = sw.ElapsedMilliseconds; //txtLog.AppendText(">>>>>>>>>> Matrix Mat: {0}", Mat.ToString()); txtLog.AppendText(V.Modulus(p).Print("Matrix V")); txtLog.AppendText("---------------------------- Server Finished query process --------------------------"); return(V.Modulus(p)); }