MCPcopy Index your code
hub / github.com/CDSecLab/MJXT / main

Method main

src/test/java/M_JXTp.java:26–106  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

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;//the values{5, 6, 7, 8, 9} for our dataset
30 //the number join attributes in the table.
31 int join_column = 1;//the values{5, 4, 3, 2, 1} for our dataset
32 int record_num = (int)Math.pow(2, 16);//the number of records of the table (65536 lines)
33 int table_num = 3;//the number of the queried tables
34 String condition = "";//used to choose different tables from dataset, e.g., "_4".
35 String[] keyword = new String[table_num];
36 String[] join_attr = new String[table_num];
37 //Step 2 begin to set up
38 System.out.println("------------- MJXT+ ---------------");
39 System.out.println("---------- MJXT+ setup ------------");
40 long setup_start = System.nanoTime();
41 Setup_JXTp[] table = new Setup_JXTp[table_num];
42 Map<BigInteger, ArrayList<byte[]>> tset = new LinkedHashMap<>();
43 for (int i = 0; i < table_num; i++) {
44 table[i] = new Setup_JXTp(i + 1, key_colnum, join_column, record_num, condition);
45 table[i].construct();
46 tset.putAll(table[i].getTset());
47 }
48 long setup_end = System.nanoTime();
49 System.out.println("JXT+ setup time : " + (setup_end - setup_start)/Math.pow(10, 6) + " ms");
50
51 //Step 3 begin to search
52 for (int i = 0; i < table_num; i++) {//set the queried attribute-value pairs and join attributes
53 keyword[i] = "keyword0" + "table" + (i + 1) + "_keyword_0_0";
54 join_attr[i] = "join-attr0";
55 }
56
57 long search_all = 0;
58 for (int x = 0; x < 1000; x++) {//run 1000 times
59 long search_start = System.nanoTime();
60 Server_MJXTp serverMJXTp = new Server_MJXTp(tset, table);
61 //Step 3.1 compute the stags
62 BigInteger stag1 = new BigInteger(Hash.Get_SHA_256((K_token + keyword[0] + join_attr[0] + 1).getBytes(StandardCharsets.UTF_8)));
63 int cnt1 = serverMJXTp.tset_table1_cnt(stag1);
64 //Step 3.2 compute the joinTokens
65 ArrayList<byte[][]> join_tokens = new ArrayList<>();
66 byte[][] w_cnt = new byte[cnt1][];
67 for (int i = 0; i < cnt1; i++) {
68 w_cnt[i] = Hash.Get_SHA_256((K_w + keyword[0] + (i + 1)).getBytes(StandardCharsets.UTF_8));
69 }
70 for (int i = 0; i < table_num; i++) {
71 byte[] w = Hash.Get_SHA_256((K_w + keyword[i] + 0).getBytes(StandardCharsets.UTF_8));
72 byte[] join_hash = Hash.Get_SHA_256((K_h + join_attr[i]).getBytes(StandardCharsets.UTF_8));
73 byte[][] join_token = new byte[cnt1][];
74 for (int j = 0; j < cnt1; j++) {
75 join_token[j] = tool.Xor(tool.Xor(w_cnt[j], w), join_hash);
76 }
77 join_tokens.add(join_token);
78 }
79 //Step 3.3 the server returns the satisfying results
80 ArrayList<ArrayList<byte[]>> res = serverMJXTp.search(join_tokens);
81 //Step 3.4 decrypt the encrypted identifiers
82 byte[][] k_dec = new byte[table_num][];
83 for (int i = 0; i < table_num; i++) {

Callers

nothing calls this directly

Calls 8

Get_SHA_256Method · 0.95
tset_table1_cntMethod · 0.95
searchMethod · 0.95
decryptMethod · 0.95
XorMethod · 0.80
addMethod · 0.80
constructMethod · 0.45
getTsetMethod · 0.45

Tested by

no test coverage detected