Det var det.

This commit is contained in:
Thomas Carlsen 2019-11-20 16:47:15 +01:00
parent 8e5bbaa8ac
commit 306f2d660b
4 changed files with 29 additions and 11 deletions

View File

@ -5,13 +5,15 @@ import dk.au.pir.protocols.interpoly.InterPolyDatabase;
import dk.au.pir.protocols.interpoly.InterPolyServer;
import dk.au.pir.settings.PIRSettings;
import java.util.Arrays;
public class Driver {
private static int generalInterPolyTest(int index) {
PIRSettings settings = new PIRSettings(8, 3);
private static int[] generalInterPolyTest(int index) {
PIRSettings settings = new PIRSettings(8, 3, 2);
int s = settings.getS();
System.out.println("s is: " + s);
InterPolyDatabase database = new InterPolyDatabase(settings);
InterPolyDatabase database = new InterPolyDatabase(settings, new int[] {0,0, 1,0, 0,0, 0,1});
InterPolyServer[] servers = new InterPolyServer[settings.getNumServers()];
for (int i = 0; i < settings.getNumServers(); i++) {
@ -19,13 +21,13 @@ public class Driver {
}
InterPolyClient client = new InterPolyClient(settings, servers);
int res = client.receive(index);
System.out.println("res: " + res);
int[] res = client.receive(index);
System.out.println("res: " + Arrays.toString(res));
return res;
}
public static void main(String[] args) {
generalInterPolyTest(2);
generalInterPolyTest(1);
/*
int sum = 0;
for (int i = 0; i < 1; i++) {

View File

@ -46,7 +46,7 @@ public class InterPolyClient {
}
public int receive(int index) {
private int receiveBit(int index) {
FieldElement[] randoms = this.getRandomFieldElements();
FieldElement[] Fs = new FieldElement[this.servers.length];
for (int z = 0; z < this.servers.length; z++) {
@ -55,4 +55,12 @@ public class InterPolyClient {
FieldElement res = FieldElementLagrange.interpolate(this.field, Fs);
return res.getValue().intValue();
}
public int[] receive(int record) {
int[] results = new int[settings.getBlocksize()];
for (int i = 0; i < settings.getBlocksize(); i++) {
results[i] = this.receiveBit((settings.getBlocksize() * record) + i);
}
return results;
}
}

View File

@ -5,9 +5,9 @@ import dk.au.pir.settings.PIRSettings;
public class InterPolyDatabase {
private final int[] x;
public InterPolyDatabase(PIRSettings settings) {
this.x = new int[settings.getDatabaseSize()];
this.x[2] = 1;
public InterPolyDatabase(PIRSettings settings, int[] x) {
//this.x = new int[settings.getDatabaseSize() * settings.getBlocksize()];
this.x = x;
}
public int[] getX() {

View File

@ -12,10 +12,14 @@ public class PIRSettings {
private final int[][] sequences;
private final BigIntegerField field;
public PIRSettings(int databaseSize, int numServers) {
private final int blocksize;
public PIRSettings(int databaseSize, int numServers, int blocksize) {
this.databaseSize = databaseSize;
this.numServers = numServers;
this.s = calculateS(numServers, databaseSize);
this.blocksize = blocksize;
this.sequences = ProtocolUtils.createSequences(s, numServers, databaseSize);
this.field = new BigIntegerField();
@ -49,4 +53,8 @@ public class PIRSettings {
public BigIntegerField getField() {
return field;
}
public int getBlocksize() {
return this.blocksize;
}
}