| 27 | private static String K_c = "6574b33984e7fb55"; |
| 28 | |
| 29 | public static void main(String[] args) { |
| 30 | //Step 1 prepare the parameters |
| 31 | //the number of attributes which aren't the join attribute in the table. |
| 32 | int key_colnum = 9; |
| 33 | //the number join attributes in the table. |
| 34 | int join_column = 1; |
| 35 | int record_num = (int) Math.pow(2, 16); |
| 36 | int table_num = 2;//the number of the queried tables |
| 37 | String condition = "";//the condition aims to choose different tables from dataset |
| 38 | int[][] l_max = new int[table_num][join_column]; |
| 39 | String[] keyword = new String[table_num]; |
| 40 | String[] join_attr = new String[table_num]; |
| 41 | //Step 2 begin to set up |
| 42 | System.out.println("--------------------- JXT++ -----------------------"); |
| 43 | Setup_JXTpp[] table = new Setup_JXTpp[table_num]; |
| 44 | Map<BigInteger, ArrayList<byte[]>> tset = new LinkedHashMap<>(); |
| 45 | for (int i = 0; i < table_num; i++) { |
| 46 | table[i] = new Setup_JXTpp(i + 1, key_colnum, join_column, record_num, condition); |
| 47 | table[i].construct(); |
| 48 | tset.putAll(table[i].getTset()); |
| 49 | System.arraycopy(table[i].getL_max(), 0, l_max[i], 0, join_column); |
| 50 | } |
| 51 | //Step 3 begin to search |
| 52 | for (int v = 0; v < 20; v++) { |
| 53 | for (int i = 0; i < table_num; i++) { |
| 54 | keyword[i] = "keyword0" + "table" + (i + 1) + "_keyword_" + v + "_0"; |
| 55 | join_attr[i] = "join-attr0"; |
| 56 | } |
| 57 | System.out.println("--------- JXT++ search(table_keyword_" + v + "_0) --------"); |
| 58 | long search_all = 0; |
| 59 | for (int x = 0; x < 1000; x++) {//run 1000 times |
| 60 | long search_start = System.nanoTime(); |
| 61 | //Step 3.1 compute the stag |
| 62 | BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword[0] + join_attr[0] + 1).getBytes(StandardCharsets.UTF_8))); |
| 63 | Server_JXTpp serverMMJXTpp = new Server_JXTpp(tset, table, stag1); |
| 64 | byte[] w_0 = Hash.Get_SHA_256((K_w + keyword[0]).getBytes(StandardCharsets.UTF_8)); |
| 65 | Map<Integer, byte[]> map_cnt = new LinkedHashMap<>(); |
| 66 | ArrayList<byte[][]> join_tokens = new ArrayList<>(); |
| 67 | for (int i = 0; i < table_num; i++) {//Step 3.2 compute the joinTokens |
| 68 | byte[] w_i = Hash.Get_SHA_256((K_wp + keyword[i]).getBytes(StandardCharsets.UTF_8)); |
| 69 | byte[] join_hash = Hash.Get_SHA_256((K_h + join_attr[i]).getBytes(StandardCharsets.UTF_8)); |
| 70 | byte[][] join_token = new byte[l_max[i][0]][]; |
| 71 | for (int j = 1; j <= l_max[i][0]; j++) { |
| 72 | byte[] cnt; |
| 73 | if (map_cnt.containsKey(j)) { |
| 74 | cnt = map_cnt.get(j); |
| 75 | } else { |
| 76 | cnt = Hash.Get_SHA_256((K_c + j).getBytes(StandardCharsets.UTF_8)); |
| 77 | map_cnt.put(j, cnt); |
| 78 | } |
| 79 | join_token[j - 1] = tool.Xor(tool.Xor(tool.Xor(w_0, w_i), join_hash), cnt); |
| 80 | } |
| 81 | join_tokens.add(join_token); |
| 82 | } |
| 83 | //Step 3.3 the server returns the satisfying results |
| 84 | ArrayList<byte[][]> res = serverMMJXTpp.search(join_tokens); |
| 85 | int res_size = 0; |
| 86 | //Step 3.4 decrypt the encrypted identifiers |