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

Class test_JXTp

src/test/java/test_JXTp.java:20–99  ·  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/08/14:36 @Description: JXT+

Source from the content-addressed store, hash-verified

18 * @Description: JXT+
19 */
20public class test_JXTp {
21 private static String K_token = "89b7a92966f6eb32";
22 private static String K_w = "7975922666f6eb02";
23 private static String K_h = "9874a22554e7db85";
24 private static String K_aes = "8975924566f6e252";
25
26 public static void main(String[] args) {
27 //Step 1 prepare the parameters
28 //the number of attributes which aren't the join attribute in the table.
29 int key_colnum = 9;
30 //the number join attributes in the table.
31 int join_column = 1;
32 int record_num = (int)Math.pow(2, 16);//the number of records of the table (65536 lines)
33 String condition = "";//used to choose different tables from dataset, e.g., "_14".
34
35 System.out.println("--------------------- JXT+ -----------------------");
36 //Step 2 begin to set up
37 Setup_JXTp table_1 = new Setup_JXTp(1, key_colnum, join_column, record_num, condition);
38 table_1.construct();
39 Map<BigInteger, ArrayList<byte[]>> tset = table_1.getTset();
40
41 Setup_JXTp table_2 = new Setup_JXTp(2, key_colnum, join_column, record_num, condition);
42 table_2.construct();
43 tset.putAll(table_2.getTset());
44 //Step 3 begin to search
45 for (int v = 0; v < 20; v++) {
46 String keyword1 = "keyword0" + "table1_keyword_" + v + "_0";
47 String keyword2 = "keyword0" + "table2_keyword_" + v + "_0";
48 System.out.println("--------- JXT+ search(table_keyword_" + v + "_0) ---------");
49 String join_attr1 = "join-attr0";
50 String join_attr2 = "join-attr0";
51 long search_all = 0;
52 for (int x = 0; x < 1000; x++) {
53 long search_start = System.nanoTime();
54 Server_JXTp serverMJXT = new Server_JXTp(tset, table_1.getF(),
55 table_1.getCset(), table_2.getF(), table_2.getCset());
56 //Step 3.1 compute the stag
57 BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword1 + join_attr1 + 1).getBytes(StandardCharsets.UTF_8)));
58 int cnt1 = serverMJXT.tset_table1_cnt(stag1);
59 byte[][] join_token1 = new byte[cnt1][];
60 byte[][] join_token2 = new byte[cnt1][];
61 byte[] w = Hash.Get_SHA_256((K_w + keyword1 + 0).getBytes(StandardCharsets.UTF_8));
62 byte[] y = Hash.Get_SHA_256((K_w + keyword2 + 0).getBytes(StandardCharsets.UTF_8));
63 byte[] join_hash1 = Hash.Get_SHA_256((K_h + join_attr1).getBytes(StandardCharsets.UTF_8));
64 byte[] join_hash2 = Hash.Get_SHA_256((K_h + join_attr2).getBytes(StandardCharsets.UTF_8));
65 //Step 3.2 compute the joinTokens
66 for (int i = 0; i < cnt1; i++) {
67 byte[] w_cnt = Hash.Get_SHA_256((K_w + keyword1 + (i + 1)).getBytes(StandardCharsets.UTF_8));
68 join_token1[i] = tool.Xor(tool.Xor(w, w_cnt), join_hash1);
69 join_token2[i] = tool.Xor(tool.Xor(y, w_cnt), join_hash2);
70 }
71 //Step 3.3 the server returns the satisfying results
72 ArrayList<ArrayList<byte[]>> res = serverMJXT.search(join_token1, join_token2);
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 //Step 3.4 decrypt the encrypted identifiers
76 for (int i = 0; i < res.size(); i++) {
77 if (i % 2 == 0){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected