even simpler schemes and stuff

This commit is contained in:
Alexander Munch-Hansen 2019-12-01 15:39:25 +01:00
parent 929a01c92c
commit 73aecc6420
6 changed files with 100 additions and 5 deletions

View File

@ -1,5 +1,8 @@
package dk.au.pir;
import dk.au.pir.protocols.evenSimpler.evenSimplerClient;
import dk.au.pir.protocols.evenSimpler.evenSimplerDatabase;
import dk.au.pir.protocols.evenSimpler.evenSimplerServer;
import dk.au.pir.protocols.interpoly.InterPolyClient;
import dk.au.pir.protocols.interpoly.InterPolyDatabase;
import dk.au.pir.protocols.interpoly.InterPolyServer;
@ -12,6 +15,24 @@ import java.util.Arrays;
public class Driver {
private static int[] evenSimplerScheme(int record) {
PIRSettings settings = new PIRSettings(8, 1, 2);
evenSimplerDatabase database = new evenSimplerDatabase(settings, new int[] {0, 0, 0, 1, 0, 0, 0, 0});
evenSimplerServer[] servers = new evenSimplerServer[settings.getNumServers()];
for (int i = 0; i < settings.getNumServers(); i++) {
servers[i] = new evenSimplerServer(database, settings);
}
evenSimplerClient client = new evenSimplerClient(settings, servers);
int[] res = client.receiveBits(record);
System.out.println("res: " + Arrays.toString(res));
return res;
}
private static int simpleScheme(int index) {
PIRSettings settings = new PIRSettings(8, 2, 1);
SimpleDatabase database = new SimpleDatabase(settings, new int[] {0, 0, 1, 0, 0, 0, 0, 0});
@ -104,7 +125,8 @@ public class Driver {
public static void main(String[] args) {
// generalBlockInterPolyTestButBetter(1);
simpleBlockScheme(1);
//simpleBlockScheme(1);
evenSimplerScheme(1);
/*
int sum = 0;
for (int i = 0; i < 1; i++) {

View File

@ -0,0 +1,30 @@
package dk.au.pir.protocols.evenSimpler;
import dk.au.pir.protocols.simple.SimpleServer;
import dk.au.pir.settings.PIRSettings;
public class evenSimplerClient {
private final PIRSettings settings;
private final evenSimplerServer[] servers;
public evenSimplerClient(PIRSettings settings, evenSimplerServer[] servers) {
this.settings = settings;
this.servers = servers;
}
public int receiveBit(int index) {
int[] data = this.servers[0].giveDatabase();
return data[index];
}
public int[] receiveBits(int record) {
int[] res = new int[settings.getBlocksize()];
int[] data = this.servers[0].giveDatabase();
System.arraycopy(data, (record * settings.getBlocksize()), res, 0, settings.getBlocksize());
return res;
}
}

View File

@ -0,0 +1,17 @@
package dk.au.pir.protocols.evenSimpler;
import dk.au.pir.settings.PIRSettings;
public class evenSimplerDatabase {
private final int[] x;
public evenSimplerDatabase(PIRSettings settings, int[] x) {
this.x = x;
}
public int[] getX() {
return x;
}
}

View File

@ -0,0 +1,22 @@
package dk.au.pir.protocols.evenSimpler;
import dk.au.pir.protocols.simple.SimpleDatabase;
import dk.au.pir.settings.PIRSettings;
public class evenSimplerServer {
private final evenSimplerDatabase database;
private final PIRSettings settings;
private final int[] x;
public evenSimplerServer(evenSimplerDatabase database, PIRSettings settings) {
this.database = database;
this.settings = settings;
this.x = database.getX();
}
public int[] giveDatabase() {
return this.x;
}
}

View File

@ -1,12 +1,9 @@
package dk.au.pir.protocols.simple;
import dk.au.pir.protocols.simple.SimpleServer;
import dk.au.pir.settings.PIRSettings;
import java.util.ArrayList;
import java.util.Random;
import static dk.au.pir.utils.ProtocolUtils.printIntArrayArray;
public class SimpleClient {

View File

@ -21,7 +21,14 @@ public class PIRSettings {
this.blocksize = blocksize;
this.sequences = ProtocolUtils.createSequences(s, 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.field = new BigIntegerField();
}