MCPcopy Create free account
hub / github.com/CDSecLab/MJXT / test_JXT

Class test_JXT

src/test/java/test_JXT.java:23–90  ·  view source on GitHub ↗

This java file aims to test JXT's query efficiency for the table where 20 attribute-value pairs are queried in batches. This code can generate the data about JXT for Figure 2 and Figure 3 in the paper. @Author: 杜凯 @Date: 2023/09/12/15:23 @Description:

Source from the content-addressed store, hash-verified

21 * @Description:
22 */
23public class test_JXT {
24
25 private static String K_token = "89b7a92966f6eb32";
26 private static String K_h1 = "9874a22554e7db85";
27 private static String K_h2 = "fad78974156f6b25";
28 private static String K_aes = "8975924566f6e252";
29
30 public static void main(String[] args) {
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);//the number of records of the table (65536 lines)
36 String condition = "";//used to choose different tables from dataset, e.g., "_4".
37 System.out.println("--------------------- JXT ------------------------");
38 //Step 2 begin to set up
39 Setup_JXT table_1 = new Setup_JXT(1, key_colnum, join_column, record_num, condition);
40 table_1.construct();
41 Map<BigInteger, ArrayList<tuple>> tset = table_1.getTset();
42 Setup_JXT table_2 = new Setup_JXT(2, key_colnum, join_column, record_num, condition);
43 table_2.construct();
44 tset.putAll(table_2.getTset());
45 //Step 3 begin to search
46 for (int v = 0; v < 20; v++) {
47 String keyword1 = "keyword0" + "table1_keyword_" + v + "_0";
48 String keyword2 = "keyword0" + "table2_keyword_" + v + "_0";
49 System.out.println("----- JXT search(table_keyword_" + v + "_0) -----");
50 long search_all = 0;
51 for (int x = 0; x < 1000; x++) {//run 1000 times
52 long search_start = System.nanoTime();
53 Server_JXT serverJXT = new Server_JXT(tset, table_1.getF(),table_2.getF());
54 //Step 3.1 compute the stags
55 BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword1 + 1).getBytes(StandardCharsets.UTF_8)));
56 BigInteger stag2 = new BigInteger(Hash.Get_SHA_256((K_token + keyword2 + 2).getBytes(StandardCharsets.UTF_8)));
57 int cnt1 = serverJXT.tset_table1_cnt(stag1);
58 int cnt2 = serverJXT.tset_table2_cnt(stag2);
59 byte[][] join_token1 = new byte[cnt1][];
60 byte[][] join_token2 = new byte[cnt2][];
61 byte[] keyword1_0 = Hash.Get_SHA_256((K_h2 + keyword1 + 0).getBytes(StandardCharsets.UTF_8));
62 byte[] keyword2_0 = Hash.Get_SHA_256((K_h1 + keyword2 + 0).getBytes(StandardCharsets.UTF_8));
63 //Step 3.2 compute the joinTokens
64 for (int i = 0; i < cnt1; i++) {
65 join_token1[i] = tool.Xor(Hash.Get_SHA_256((K_h2 + keyword1 + (i + 1)).getBytes(StandardCharsets.UTF_8)), keyword2_0);
66 }
67 for (int i = 0; i < cnt2; i++) {
68 join_token2[i] = tool.Xor(Hash.Get_SHA_256((K_h1 + keyword2 + (i + 1)).getBytes(StandardCharsets.UTF_8)), keyword1_0);
69 }
70 //Step 3.3 the server returns the satisfying results
71 ArrayList<byte[]> res = serverJXT.search(join_token1, join_token2, 0);
72 //Step 3.4 decrypt the encrypted identifiers
73 byte[] k_dec1 = Hash.Get_SHA_256((K_aes + keyword1).getBytes());
74 byte[] k_dec2 = Hash.Get_SHA_256((K_aes + keyword2).getBytes());
75 for (int i = 0; i < res.size(); i++) {
76 if (i % 2 == 0) AESUtil.decrypt(k_dec1, res.get(i));
77 else AESUtil.decrypt(k_dec2, res.get(i));
78
79 }
80 long search_end = System.nanoTime();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected