Skip to content

Commit

Permalink
Confirm this works with Paillier with my refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewQuijano committed May 7, 2024
1 parent 3ff6729 commit 1df6810
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 44 deletions.
62 changes: 23 additions & 39 deletions src/main/java/BobThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,37 @@
public class BobThread implements Runnable {
private static final Logger logger = LogManager.getLogger(BobThread.class);
private final int port;
private static ServerSocket bob_socket = null;
private static Socket bob_client = null;
private final bob_joye this_guy;
private final bob_joye bob;

public BobThread(bob_joye this_guy, int port) {
this.this_guy = this_guy;
public BobThread(bob_joye bob, int port) {
this.bob = bob;
this.port = port;
}

public void run() {
try {
bob_socket = new ServerSocket(port);
bob_client = bob_socket.accept();
this_guy.set_socket(bob_client);
this_guy.sendPublicKeys();

while (true) {

int var = this_guy.readInt();

if (var == 1) {
this_guy.multiplication();
}

if (var == 2) {
this_guy.Protocol2();
}

if (var == 0) {
break;
}
}
try (ServerSocket bob_socket = new ServerSocket(port)) {
try (Socket bob_client = bob_socket.accept()) {
bob.set_socket(bob_client);
bob.sendPublicKeys();

while (true) {
int var = bob.readInt();
if (var == 1) {
bob.multiplication();
}

if (var == 2) {
bob.Protocol2();
}

if (var == 0) {
break;
}
} // while
}
}
catch (IOException | ClassNotFoundException | HomomorphicException e) {
logger.fatal(e);
}
finally {
try {
if (bob_client != null) {
bob_client.close();
}
if (bob_socket != null) {
bob_socket.close();
}
} catch (IOException e) {
logger.fatal(e);
}
}
}
}
9 changes: 4 additions & 5 deletions src/test/java/IntersectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void encrypted_test_intersections() {
alice_joye alice = new alice_joye();
bob_joye bob = new bob_joye(paillier, dgk);

alice.setDGKMode(true);
bob.setDGKMode(true);
alice.setDGKMode(false);
bob.setDGKMode(false);

while ((line = br.readLine()) != null) {
// Set-up
Expand All @@ -60,7 +60,6 @@ public void encrypted_test_intersections() {
alice.set_socket(connectWithRetry("127.0.0.1", 9200));
alice.receivePublicKeys();

PaillierPublicKey paillier_public_key = bob.getPaillierPublicKey();
EncryptedPathsComparison testing = new EncryptedPathsComparison(alice);

// Parse data and run-test
Expand All @@ -76,8 +75,8 @@ public void encrypted_test_intersections() {
List<BigIntPoint> cryptroute_list = shared.read_all_paths(cryptroute);

// Encrypt routes, DGK
List<BigIntPoint> encryptedownroute_list = shared.encrypt_dgk(ownroute_list, bob.getDGKPublicKey());
List<BigIntPoint> encryptedcryptroute_list = shared.encrypt_dgk(cryptroute_list, bob.getDGKPublicKey());
List<BigIntPoint> encryptedownroute_list = shared.encrypt_paillier(ownroute_list, bob.getPaillierPublicKey());
List<BigIntPoint> encryptedcryptroute_list = shared.encrypt_paillier(cryptroute_list, bob.getPaillierPublicKey());

// Update testing...
List<Integer> indexes = testing.encryptedWhereIntersection(encryptedownroute_list,
Expand Down

0 comments on commit 1df6810

Please sign in to comment.