From 059387bbd65cfa90f0c970b3aced7f8b783eec2d Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Tue, 3 Dec 2019 12:58:24 +0100 Subject: [PATCH] pls --- pir/src/main/java/dk/au/pir/Driver.java | 26 ++++++++++--------- .../java/dk/au/pir/profilers/Profiler.java | 14 ++++++++++ .../evenSimpler/EvenSimplerClient.java | 2 +- .../protocols/interpoly/InterPolyClient.java | 3 ++- .../au/pir/protocols/simple/SimpleClient.java | 1 - .../java/dk/au/pir/settings/PIRSettings.java | 8 ++---- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/pir/src/main/java/dk/au/pir/Driver.java b/pir/src/main/java/dk/au/pir/Driver.java index 122de81..31f897a 100644 --- a/pir/src/main/java/dk/au/pir/Driver.java +++ b/pir/src/main/java/dk/au/pir/Driver.java @@ -69,11 +69,11 @@ public class Driver { } public static void runTests() { - for (int numServers = 2; numServers <= 8; numServers = (int) Math.pow(2, ++numServers)) { - for (int databaseSize = 2; databaseSize <= 32; databaseSize = (int) Math.pow(2, ++databaseSize)) { - for (int blockSize = 1; blockSize <= Math.min(4, databaseSize); blockSize = (int) Math.pow(2, ++blockSize)) { + for (int numServers = 1; numServers <= 8; numServers = numServers*2) { + for (int databaseSize = 2; databaseSize <= 4096; databaseSize = databaseSize*2) { + for (int blockSize = 1; blockSize <= Math.min(512, databaseSize); blockSize = blockSize*2) { for (int latency = 0; latency <= 50; latency = latency + 10) { - for (int bandwidth = 1024; bandwidth <= 2048; bandwidth = (int) Math.pow(2, ++bandwidth)) { + for (int bandwidth = 1024; bandwidth <= 2048; bandwidth = bandwidth*2) { runTest(numServers, databaseSize, blockSize, latency, bandwidth); } } @@ -91,20 +91,22 @@ public class Driver { Database database = new MemoryDatabase(settings, x); Profiler profiler = new Profiler(latency, bandwidth/10, bandwidth); - profiler.reset(); testEvenSimplerScheme(settings, database, profiler); reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "EvenSimplerScheme"); - profiler.reset(); - testSimpleScheme(settings, database, profiler); - reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleScheme"); - profiler.reset(); - testSimpleBlockScheme(settings, database, profiler); - reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleBlockScheme"); + if (numServers == 2) { + profiler.reset(); + testSimpleScheme(settings, database, profiler); + reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleScheme"); - if (settings.getS() != 0) { + profiler.reset(); + testSimpleBlockScheme(settings, database, profiler); + reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "SimpleBlockScheme"); + } + + if (settings.getS() != 0 && numServers != 1) { profiler.reset(); testGeneralInterPolyScheme(settings, database, profiler); reportResult(numServers, databaseSize, blockSize, latency, bandwidth, profiler, "GeneralInterPolyScheme"); diff --git a/pir/src/main/java/dk/au/pir/profilers/Profiler.java b/pir/src/main/java/dk/au/pir/profilers/Profiler.java index 8bb6114..c74b630 100644 --- a/pir/src/main/java/dk/au/pir/profilers/Profiler.java +++ b/pir/src/main/java/dk/au/pir/profilers/Profiler.java @@ -72,6 +72,13 @@ public class Profiler { return elements; } + public FieldElement[][] clientSend(FieldElement[][] elements) { + for (FieldElement[] fe : elements) { + this.clientSend(fe); + } + return elements; + } + public int clientReceive(int number) { this.received += log2(number); return number; @@ -89,6 +96,13 @@ public class Profiler { return element; } + public FieldElement[] clientReceive(FieldElement[] elements) { + for (FieldElement fe : elements) { + clientReceive(fe); + } + return elements; + } + public int getSent() { return this.sent; } diff --git a/pir/src/main/java/dk/au/pir/protocols/evenSimpler/EvenSimplerClient.java b/pir/src/main/java/dk/au/pir/protocols/evenSimpler/EvenSimplerClient.java index cf63d56..e66a981 100644 --- a/pir/src/main/java/dk/au/pir/protocols/evenSimpler/EvenSimplerClient.java +++ b/pir/src/main/java/dk/au/pir/protocols/evenSimpler/EvenSimplerClient.java @@ -15,7 +15,7 @@ public class EvenSimplerClient { } public int receiveBit(int index) { - this.profiler.addNetworkDelay(); + this.profiler.addNetworkDelay(2); int[] data = this.profiler.clientReceive(this.servers[0].giveDatabase()); return data[index]; } diff --git a/pir/src/main/java/dk/au/pir/protocols/interpoly/InterPolyClient.java b/pir/src/main/java/dk/au/pir/protocols/interpoly/InterPolyClient.java index 126213c..a0f9cf2 100644 --- a/pir/src/main/java/dk/au/pir/protocols/interpoly/InterPolyClient.java +++ b/pir/src/main/java/dk/au/pir/protocols/interpoly/InterPolyClient.java @@ -84,12 +84,13 @@ public class InterPolyClient { /** * 1) Compute all the Gs for each server, s.t. the first index should be the blocksize and it should contain all the Gs for the given index */ + this.profiler.addNetworkDelay(2); for (int z = 0; z < this.servers.length; z++) { FieldElement[][] Gs = new FieldElement[settings.getBlocksize()][this.s]; for (int i = 0; i < settings.getBlocksize(); i++) { Gs[i] = this.getGs(record*settings.getBlocksize() + i, z+1, randoms[i]); } - Fs[z] = this.servers[z].FBlock(Gs); + Fs[z] = profiler.clientReceive(this.servers[z].FBlock(profiler.clientSend(Gs))); } for (int i = 0; i < settings.getBlocksize(); i++) { diff --git a/pir/src/main/java/dk/au/pir/protocols/simple/SimpleClient.java b/pir/src/main/java/dk/au/pir/protocols/simple/SimpleClient.java index ae2a1d2..4236223 100644 --- a/pir/src/main/java/dk/au/pir/protocols/simple/SimpleClient.java +++ b/pir/src/main/java/dk/au/pir/protocols/simple/SimpleClient.java @@ -36,7 +36,6 @@ public class SimpleClient { S2[index] = 1; } - // TODO: Hardcoded, should be a loop this.profiler.addNetworkDelay(2); int resBit1 = this.profiler.clientReceive(this.servers[0].computeBit(this.profiler.clientSend(S1))); int resBit2 = this.profiler.clientReceive(this.servers[1].computeBit(this.profiler.clientSend(S2))); diff --git a/pir/src/main/java/dk/au/pir/settings/PIRSettings.java b/pir/src/main/java/dk/au/pir/settings/PIRSettings.java index f8700e8..4fb5f1a 100644 --- a/pir/src/main/java/dk/au/pir/settings/PIRSettings.java +++ b/pir/src/main/java/dk/au/pir/settings/PIRSettings.java @@ -21,13 +21,9 @@ public class PIRSettings { try { this.s = calculateS(numServers, databaseSize); - // TODO: lol - if (numServers > 1) { - this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize); - } else { - this.sequences = ProtocolUtils.createSequences(calculateS(2, databaseSize), 2, databaseSize); - } + this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize); } catch (IllegalArgumentException error) { + System.out.println("pls"); this.s = 0; }