Skip to content

Commit

Permalink
I almost got this working...
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewQuijano committed Jan 14, 2024
1 parent 43b147d commit b662b8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 5 additions & 6 deletions src/main/java/weka/finito/client.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,10 @@ private void communicate_with_level_site(Socket level_site)
// Send bool:
// 1- true, there is an encrypted index coming
// 2- false, there is NO encrypted index coming
to_level_site.writeInt(next_index);
to_level_site.flush();
client.writeInt(next_index);

// Get the comparison
int comparison_type = from_level_site.readInt();
int comparison_type = client.readInt();
if (comparison_type == -1) {
System.out.println("LEVEL-SITE DOESN'T HAVE DATA!!!");
this.classification_complete = true;
Expand All @@ -366,16 +365,16 @@ else if (comparison_type == 1) {
// Get boolean from level-site:
// true - get leaf value
// false - get encrypted AES index for next round
classification_complete = from_level_site.readBoolean();
classification_complete = client.readBoolean();
if (classification_complete) {
o = from_level_site.readObject();
o = client.readObject();
if (o instanceof String) {
classification = (String) o;
classification = hashed_classification.get(classification);
}
}
else {
next_index = from_level_site.readInt();
next_index = client.readInt();
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/main/java/weka/finito/level_site_evaluation_thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,24 @@ public final void run() {
ObjectInputStream ois = null;
ObjectOutputStream oos = null;
try {
ois = new ObjectInputStream(client_socket.getInputStream());
oos = new ObjectOutputStream(client_socket.getOutputStream());
niu.set_socket(client_socket);
niu.setDGKPublicKey(this.level_site_data.dgk_public_key);
niu.setPaillierPublicKey(this.level_site_data.paillier_public_key);

level_site_data.set_current_index(ois.readInt());
level_site_data.set_current_index(niu.readInt());

// Null, keep going down the tree,
// Not null, you got the correct leaf node of your DT!
NodeInfo reply = traverse_level(level_site_data, encrypted_features, niu);

if (reply != null) {
// Tell the client the value
oos.writeBoolean(true);
oos.writeObject(reply.getVariableName());
niu.writeBoolean(true);
niu.writeObject(reply.getVariableName());
}
else {
oos.writeBoolean(false);
oos.writeInt(level_site_data.get_next_index());
niu.writeBoolean(false);
niu.writeInt(level_site_data.get_next_index());
}
long stop_time = System.nanoTime();
double run_time = (double) (stop_time - start_time);
Expand Down

0 comments on commit b662b8b

Please sign in to comment.