(String[] args)
| 23 | private static String K_aes = "8975924566f6e252"; |
| 24 | |
| 25 | public static void main(String[] args) { |
| 26 | //Step 1 prepare the parameters |
| 27 | //the number of attributes which aren't the join attribute in the table. |
| 28 | int key_colnum = 9;//the values{5, 6, 7, 8, 9} for our dataset |
| 29 | //the number join attributes in the table. |
| 30 | int join_column = 1;//the values{5, 4, 3, 2, 1} for our dataset |
| 31 | int record_num = (int)Math.pow(2, 16);//the number of records of the table (65536 lines) |
| 32 | String condition = "";//used to choose different tables from dataset, e.g., "_4". |
| 33 | |
| 34 | System.out.println("------------- JXT+ ---------------"); |
| 35 | System.out.println("------------ JXT+ setup ------------"); |
| 36 | //Step 2 begin to set up |
| 37 | long setup_start = System.nanoTime(); |
| 38 | Setup_JXTp table_1 = new Setup_JXTp(1, key_colnum, join_column, record_num, condition); |
| 39 | table_1.construct(); |
| 40 | Map<BigInteger, ArrayList<byte[]>> tset = table_1.getTset(); |
| 41 | |
| 42 | Setup_JXTp table_2 = new Setup_JXTp(2, key_colnum, join_column, record_num, condition); |
| 43 | table_2.construct(); |
| 44 | tset.putAll(table_2.getTset()); |
| 45 | long setup_end = System.nanoTime(); |
| 46 | System.out.println("JXT+ setup time : " + (setup_end - setup_start)/Math.pow(10, 6) + " ms"); |
| 47 | //Step 3 begin to search |
| 48 | System.out.println("------------ JXT+ search ------------"); |
| 49 | String keyword1 = "keyword0" + "table1_keyword_0_0";//queried attribute-value pair w1 |
| 50 | String keyword2 = "keyword0" + "table2_keyword_0_0";//queried attribute-value pair w2 |
| 51 | //note that for JXT+ supporting equi-join, join attributes can own different names |
| 52 | String join_attr1 = "join-attr0";//chosen join attribute attr_1 |
| 53 | String join_attr2 = "join-attr0";//chosen join attribute attr_2 |
| 54 | long search_all = 0; |
| 55 | for (int x = 0; x < 1000; x++) {//run 1000 times |
| 56 | long search_start = System.nanoTime(); |
| 57 | Server_JXTp serverMJXT = new Server_JXTp(tset, table_1.getF(), |
| 58 | table_1.getCset(), table_2.getF(), table_2.getCset()); |
| 59 | //Step 3.1 compute the stag |
| 60 | BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword1 + join_attr1 + 1).getBytes(StandardCharsets.UTF_8))); |
| 61 | int cnt1 = serverMJXT.tset_table1_cnt(stag1); |
| 62 | byte[][] join_token1 = new byte[cnt1][]; |
| 63 | byte[][] join_token2 = new byte[cnt1][]; |
| 64 | byte[] w = Hash.Get_SHA_256((K_w + keyword1 + 0).getBytes(StandardCharsets.UTF_8)); |
| 65 | byte[] y = Hash.Get_SHA_256((K_w + keyword2 + 0).getBytes(StandardCharsets.UTF_8)); |
| 66 | byte[] join_hash1 = Hash.Get_SHA_256((K_h + join_attr1).getBytes(StandardCharsets.UTF_8)); |
| 67 | byte[] join_hash2 = Hash.Get_SHA_256((K_h + join_attr2).getBytes(StandardCharsets.UTF_8)); |
| 68 | //Step 3.2 compute the joinTokens |
| 69 | for (int i = 0; i < cnt1; i++) { |
| 70 | byte[] w_cnt = Hash.Get_SHA_256((K_w + keyword1 + (i + 1)).getBytes(StandardCharsets.UTF_8)); |
| 71 | join_token1[i] = tool.Xor(tool.Xor(w, w_cnt), join_hash1); |
| 72 | join_token2[i] = tool.Xor(tool.Xor(y, w_cnt), join_hash2); |
| 73 | } |
| 74 | //Step 3.3 the server returns the satisfying results |
| 75 | ArrayList<ArrayList<byte[]>> res = serverMJXT.search(join_token1, join_token2); |
| 76 | byte[] k_dec1 = Hash.Get_SHA_256((K_aes + keyword1).getBytes()); |
| 77 | byte[] k_dec2 = Hash.Get_SHA_256((K_aes + keyword2).getBytes()); |
| 78 | //Step 3.4 decrypt the encrypted identifiers |
| 79 | for (int i = 0; i < res.size(); i++) { |
| 80 | if (i % 2 == 0){ |
| 81 | ArrayList<byte[]> res_i = res.get(i); |
| 82 | for (int j = 0; j < res_i.size(); j++) { |
nothing calls this directly
no test coverage detected