From e4ec6b421e0e7d0f4c2ab0b051648b3020c74430 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Thu, 5 Dec 2019 17:12:38 +0100 Subject: [PATCH] pls works --- .../balancedBlockScheme/balancedBlockClient.java | 8 +++++--- .../balancedBlockScheme/balancedBlockServer.java | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockClient.java b/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockClient.java index 0cb9edd..7e11bf0 100644 --- a/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockClient.java +++ b/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockClient.java @@ -47,7 +47,7 @@ public class balancedBlockClient { - int impBlock = index % this.sqrtSize; + int impBlock = (int) Math.floor(index/this.sqrtSize); System.out.println("ImpBlock: " + impBlock); if (S1[index % this.sqrtSize] == 1) { S2[index % this.sqrtSize] = 0; // Remove the index, if it's contained in S. @@ -62,6 +62,8 @@ public class balancedBlockClient { int[] resBit1 = this.servers[0].computeBit(S1); int[] resBit2 = this.servers[1].computeBit(S2); + + return ((resBit1[impBlock] + resBit2[impBlock]) % 2); } @@ -70,13 +72,13 @@ public class balancedBlockClient { PIRSettings settings = new PIRSettings(16, 2, 1); balancedBlockServer[] servers = new balancedBlockServer[settings.getNumServers()]; - Database database = new MemoryDatabase(settings, new int[] {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0}); + Database database = new MemoryDatabase(settings, new int[] {0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0}); for (int i = 0; i < settings.getNumServers(); i++) { servers[i] = new balancedBlockServer(database, settings); } balancedBlockClient client = new balancedBlockClient(settings, servers, null); - System.out.println(client.receiveBit(6)); + System.out.println(client.receiveBit(11)); } } diff --git a/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockServer.java b/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockServer.java index cd61086..a4be041 100644 --- a/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockServer.java +++ b/pir/src/main/java/dk/au/pir/protocols/balancedBlockScheme/balancedBlockServer.java @@ -37,6 +37,7 @@ public class balancedBlockServer { try { boolean test = indexes[j] == 1; if (test) { + System.out.println("Looking at index: " + (j + (this.sqrtSize * i))); tmpRes = (tmpRes + db[j + (this.sqrtSize * i)]) % 2; }