Fuck sockets.

This commit is contained in:
Casper 2019-11-20 14:33:53 +01:00
parent 41189ad927
commit 8e5bbaa8ac
3 changed files with 4 additions and 11 deletions

View File

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

View File

@ -2,20 +2,12 @@ package dk.au.pir.protocols.interpoly;
import dk.au.pir.settings.PIRSettings; import dk.au.pir.settings.PIRSettings;
import static dk.au.pir.utils.ProtocolUtils.printIntArrayArray;
public class InterPolyDatabase { public class InterPolyDatabase {
private final int[] x; private final int[] x;
public InterPolyDatabase(PIRSettings settings) { public InterPolyDatabase(PIRSettings settings) {
this.x = new int[settings.getDatabaseSize()]; this.x = new int[settings.getDatabaseSize()];
this.x[2] = 1; this.x[2] = 1;
int[][] y = new int[1][settings.getDatabaseSize()];
y[0]= this.x;
System.out.println("This is the database");
printIntArrayArray(y);
System.out.println();
} }
public int[] getX() { public int[] getX() {

View File

@ -6,6 +6,7 @@ import java.util.Arrays;
public class FieldElementLagrange { public class FieldElementLagrange {
public static FieldElement interpolate(BigIntegerField field, FieldElement[] y) { public static FieldElement interpolate(BigIntegerField field, FieldElement[] y) {
// https://stackoverflow.com/questions/16375163/lagrange-interpolation-in-java
System.out.println("y: " + Arrays.deepToString(y)); System.out.println("y: " + Arrays.deepToString(y));
FieldElement xPoint = field.valueOf(0); // we want to find f(0), so xpoint=0 FieldElement xPoint = field.valueOf(0); // we want to find f(0), so xpoint=0
FieldElement sum = field.valueOf(0); FieldElement sum = field.valueOf(0);