From 200d5548829f1f2bdc6c2a855d29bff18901c532 Mon Sep 17 00:00:00 2001 From: Andrew Quijano Date: Sat, 24 Jun 2023 18:54:17 +0000 Subject: [PATCH] Removed Level-sites needing precision as we shouldn't trust it with thresholds. Also removed the 'site' suffix for both client and server, to stay consistent with the paper. --- README.md | 6 ++--- eks-config/config.yaml | 24 ++++--------------- .../server_service.yaml} | 4 ++-- .../server_training_job.yaml} | 4 ++-- .../server_service.yaml} | 4 ++-- .../server_training_job.yaml} | 6 ++--- src/main/java/weka/finito/client.java | 1 - .../java/weka/finito/level_site_server.java | 6 ----- .../finito/{server_site.java => server.java} | 18 +++++++------- .../weka/finito/structs/level_order_site.java | 4 ---- src/test/java/PrivacyTest.java | 4 ++-- 11 files changed, 28 insertions(+), 53 deletions(-) rename eks-config/k8/{server_site/server_site_service.yaml => server/server_service.yaml} (68%) rename eks-config/k8/{server_site/server_site_training_job.yaml => server/server_training_job.yaml} (93%) rename k8/{server_site/server_site_service.yaml => server/server_service.yaml} (68%) rename k8/{server_site/server_site_training_job.yaml => server/server_training_job.yaml} (86%) rename src/main/java/weka/finito/{server_site.java => server.java} (94%) diff --git a/README.md b/README.md index 9ddfc9a..6290881 100644 --- a/README.md +++ b/README.md @@ -242,10 +242,10 @@ aws eks update-kubeconfig --name ppdt --region us-east-2 - Run the same commands as shown below. It is similar to [the previous section](#running-kubernetes-commands), but we point to different yaml files since it is pulling the container image from dockerhub. ```bash # Make sure you aren't running these too early! -kubectl apply -f eks-config/k8/level_sites -kubectl apply -f eks-config/k8/server_site +kubectl apply -f eks-config/k8/level_sites +kubectl apply -f eks-config/k8/server -l role=server -kubectl apply -f eks-config/k8/client +kubectl apply -f eks-config/k8/client -l role=client kubectl exec -- bash -c "gradle run -PchooseRole=weka.finito.client --args " ``` - Obtain the results of the classification using `kubectl logs` to the pods deployed on EKS. diff --git a/eks-config/config.yaml b/eks-config/config.yaml index 2a25114..28a2aac 100644 --- a/eks-config/config.yaml +++ b/eks-config/config.yaml @@ -7,27 +7,13 @@ metadata: version: "1.27" # Managed Node Groups show up on AWS console +# Label is necessary so I can target where the pods go with kubectl apply +# For best performance, I am isolating each level-site pod to its own node. managedNodeGroups: +# Currently I have 10 level-sites - name: level-sites instanceType: t2.large labels: { role: level-site } - minSize: 10 + minSize: 12 maxSize: 15 - desiredCapacity: 10 - maxPodsPerNode: 1 - -- name: client - instanceType: t2.large - labels: { role: client } - minSize: 1 - maxSize: 1 - desiredCapacity: 1 - maxPodsPerNode: 1 - -- name: server - instanceType: t2.large - labels: { role: server-site } - minSize: 1 - maxSize: 1 - desiredCapacity: 1 - maxPodsPerNode: 1 \ No newline at end of file + desiredCapacity: 12 diff --git a/eks-config/k8/server_site/server_site_service.yaml b/eks-config/k8/server/server_service.yaml similarity index 68% rename from eks-config/k8/server_site/server_site_service.yaml rename to eks-config/k8/server/server_service.yaml index b4a36b2..757d7cd 100644 --- a/eks-config/k8/server_site/server_site_service.yaml +++ b/eks-config/k8/server/server_service.yaml @@ -1,11 +1,11 @@ kind: Service apiVersion: v1 metadata: - name: ppdt-server-site-service + name: ppdt-server-service spec: clusterIP: None # clusterIP must be None to create a headless service selector: - job-name: ppdt-server-site-deploy # must match Job name + job-name: ppdt-server-deploy # must match Job name ports: - protocol: TCP port: 9000 diff --git a/eks-config/k8/server_site/server_site_training_job.yaml b/eks-config/k8/server/server_training_job.yaml similarity index 93% rename from eks-config/k8/server_site/server_site_training_job.yaml rename to eks-config/k8/server/server_training_job.yaml index 7098a76..7e78efa 100644 --- a/eks-config/k8/server_site/server_site_training_job.yaml +++ b/eks-config/k8/server/server_training_job.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: ppdt-server-site-deploy + name: ppdt-server-deploy spec: template: spec: @@ -9,7 +9,7 @@ spec: restartPolicy: OnFailure containers: - - name: ppdt-server-site-deploy + - name: ppdt-server-deploy image: andrewquijano92/ppdt imagePullPolicy: IfNotPresent command: ["/bin/sh"] diff --git a/k8/server_site/server_site_service.yaml b/k8/server/server_service.yaml similarity index 68% rename from k8/server_site/server_site_service.yaml rename to k8/server/server_service.yaml index b4a36b2..757d7cd 100644 --- a/k8/server_site/server_site_service.yaml +++ b/k8/server/server_service.yaml @@ -1,11 +1,11 @@ kind: Service apiVersion: v1 metadata: - name: ppdt-server-site-service + name: ppdt-server-service spec: clusterIP: None # clusterIP must be None to create a headless service selector: - job-name: ppdt-server-site-deploy # must match Job name + job-name: ppdt-server-deploy # must match Job name ports: - protocol: TCP port: 9000 diff --git a/k8/server_site/server_site_training_job.yaml b/k8/server/server_training_job.yaml similarity index 86% rename from k8/server_site/server_site_training_job.yaml rename to k8/server/server_training_job.yaml index 0e58271..63b274f 100644 --- a/k8/server_site/server_site_training_job.yaml +++ b/k8/server/server_training_job.yaml @@ -1,15 +1,15 @@ apiVersion: batch/v1 kind: Job metadata: - name: ppdt-server-site-deploy + name: ppdt-server-deploy spec: template: spec: - subdomain: ppdt-server-site-service # has to match Service name + subdomain: ppdt-server-service # has to match Service name restartPolicy: OnFailure containers: - - name: ppdt-server-site-deploy + - name: ppdt-server-deploy image: ppdt:experiment imagePullPolicy: IfNotPresent command: ["/bin/sh"] diff --git a/src/main/java/weka/finito/client.java b/src/main/java/weka/finito/client.java index b85574c..8660337 100644 --- a/src/main/java/weka/finito/client.java +++ b/src/main/java/weka/finito/client.java @@ -7,7 +7,6 @@ import java.security.KeyPair; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; import java.util.Base64; import java.util.HashMap; import java.util.Hashtable; diff --git a/src/main/java/weka/finito/level_site_server.java b/src/main/java/weka/finito/level_site_server.java index e441d8d..f116025 100644 --- a/src/main/java/weka/finito/level_site_server.java +++ b/src/main/java/weka/finito/level_site_server.java @@ -32,12 +32,6 @@ public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgo System.out.println("Port is not defined."); System.exit(1); } - try { - our_precision = Integer.parseInt(System.getenv("PRECISION")); - } catch (NumberFormatException e) { - System.out.println("Precision is not defined."); - System.exit(1); - } if(AES_Pass == null || AES_Pass.isEmpty()) { System.out.println("AES_PASS is empty."); System.exit(1); diff --git a/src/main/java/weka/finito/server_site.java b/src/main/java/weka/finito/server.java similarity index 94% rename from src/main/java/weka/finito/server_site.java rename to src/main/java/weka/finito/server.java index bf4d239..47631da 100644 --- a/src/main/java/weka/finito/server_site.java +++ b/src/main/java/weka/finito/server.java @@ -30,7 +30,7 @@ import weka.finito.structs.NodeInfo; -public final class server_site implements Runnable { +public final class server implements Runnable { private static final String os = System.getProperty("os.name").toLowerCase(); private final String training_data; @@ -80,12 +80,12 @@ public static void main(String[] args) { // Create and run the server. System.out.println("Server Initialized and started running"); - server_site server = new server_site(args[0], level_domains, port, precision, port); + server server = new server(args[0], level_domains, port, precision, port); server.run(); } // For local host testing, (GitHub Actions CI, on PrivacyTest.java) - public server_site(String training_data, String [] level_site_ips, int [] level_site_ports, int precision, + public server(String training_data, String [] level_site_ips, int [] level_site_ports, int precision, int server_port) { this.training_data = training_data; this.level_site_ips = level_site_ips; @@ -95,7 +95,7 @@ public server_site(String training_data, String [] level_site_ips, int [] level_ } // For Cloud environment, (Testing with Kubernetes) - public server_site(String training_data, String [] level_site_domains, int port, int precision, int server_port) { + public server(String training_data, String [] level_site_domains, int port, int precision, int server_port) { this.training_data = training_data; this.level_site_ips = level_site_domains; this.port = port; @@ -111,7 +111,7 @@ private static String hash(String text) throws NoSuchAlgorithmException { private void client_communication() throws Exception { ServerSocket serverSocket = new ServerSocket(server_port); - System.out.println("Server-site ready to get public keys from client-site"); + System.out.println("Server ready to get public keys from client"); try (Socket client_site = serverSocket.accept()) { ObjectOutputStream to_client_site = new ObjectOutputStream(client_site.getOutputStream()); @@ -124,24 +124,24 @@ private void client_communication() throws Exception { o = from_client_site.readObject(); this.dgk_public = (DGKPublicKey) o; - System.out.println("Server-site collected keys from client"); + System.out.println("Server collected keys from client"); // Train level-sites get_level_site_data(ppdt, all_level_sites); - System.out.println("Server-site trained DT and created level-sites"); + System.out.println("Server trained DT and created level-sites"); // Now I know the leaves to send back to the client String [] leaf_array = leaves.toArray(new String[0]); to_client_site.writeObject(leaf_array); - System.out.println("Server-site sent the leaves back to the client"); + System.out.println("Server sent the leaves back to the client"); } serverSocket.close(); } private static boolean isUnix() { - return (server_site.os.contains("nix") || server_site.os.contains("nux") || server_site.os.contains("aix")); + return (server.os.contains("nix") || server.os.contains("nux") || server.os.contains("aix")); } private static void printTree(ClassifierTree j48, String base_name) diff --git a/src/main/java/weka/finito/structs/level_order_site.java b/src/main/java/weka/finito/structs/level_order_site.java index a431517..8c5eec3 100644 --- a/src/main/java/weka/finito/structs/level_order_site.java +++ b/src/main/java/weka/finito/structs/level_order_site.java @@ -1,13 +1,9 @@ package weka.finito.structs; -import security.DGK.DGKOperations; import security.DGK.DGKPublicKey; -import security.misc.HomomorphicException; -import security.paillier.PaillierCipher; import security.paillier.PaillierPublicKey; import java.io.Serializable; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/PrivacyTest.java b/src/test/java/PrivacyTest.java index 6a1c1ac..e7082bc 100644 --- a/src/test/java/PrivacyTest.java +++ b/src/test/java/PrivacyTest.java @@ -3,7 +3,7 @@ import weka.finito.AES; import weka.finito.client; import weka.finito.level_site_server; -import weka.finito.server_site; +import weka.finito.server; import javax.crypto.NoSuchPaddingException; import java.io.BufferedReader; @@ -90,7 +90,7 @@ public static String test_case(String training_data, String features_file, int l } // Create the server - server_site cloud = new server_site(training_data, level_site_ips, level_site_ports, precision, server_port); + server cloud = new server(training_data, level_site_ips, level_site_ports, precision, server_port); Thread server = new Thread(cloud); server.start();