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