Sober up.

This commit is contained in:
Alexander Munch-Hansen 2019-11-08 11:36:20 +01:00
parent 1dd308df42
commit 73841f1cd1
3 changed files with 8 additions and 10 deletions

View File

@ -2,11 +2,10 @@ package dk.au.pir.protocols.general.interpoly;
import dk.au.pir.BigIntegerField;
import dk.au.pir.settings.PIRSettings;
import dk.au.pir.utils.BigIntegerLagrangeInterpolation;
import dk.au.pir.utils.BigIntegerLagrange;
import dk.au.pir.utils.FieldElement;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Random;
public class GeneralInterPolyClient {
@ -57,7 +56,7 @@ public class GeneralInterPolyClient {
for (int i = 0; i < PIRSettings.MOD_BIT_LENGTH + 1; i++) {
fuckingXs[i] = BigInteger.valueOf(i);
}
return BigIntegerLagrangeInterpolation.doIt(fuckingXs, results);
return BigIntegerLagrange.interpolate(fuckingXs, results);
}
}

View File

@ -2,11 +2,10 @@ package dk.au.pir.protocols.interpoly;
import dk.au.pir.BigIntegerField;
import dk.au.pir.settings.PIRSettings;
import dk.au.pir.utils.BigIntegerLagrangeInterpolation;
import dk.au.pir.utils.BigIntegerLagrange;
import dk.au.pir.utils.FieldElement;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Random;
public class InterPolyClient {
@ -53,10 +52,10 @@ public class InterPolyClient {
public BigInteger receiveResults(BigInteger[] results) {
BigInteger[] fuckingXs = new BigInteger[PIRSettings.MOD_BIT_LENGTH + 1];
BigInteger[] xs = new BigInteger[PIRSettings.MOD_BIT_LENGTH + 1];
for (int i = 0; i < PIRSettings.MOD_BIT_LENGTH + 1; i++) {
fuckingXs[i] = BigInteger.valueOf(i);
xs[i] = BigInteger.valueOf(i);
}
return BigIntegerLagrangeInterpolation.doIt(fuckingXs, results);
return BigIntegerLagrange.interpolate(xs, results);
}
}

View File

@ -2,8 +2,8 @@ package dk.au.pir.utils;
import java.math.BigInteger;
public class BigIntegerLagrangeInterpolation {
public static BigInteger doIt(BigInteger[] x, BigInteger[] y) {
public class BigIntegerLagrange {
public static BigInteger interpolate(BigInteger[] x, BigInteger[] y) {
// https://stackoverflow.com/questions/16375163/lagrange-interpolation-in-java
BigInteger xPoint = BigInteger.ZERO; // we want to find f(0), so xpoint=0
BigInteger sum = BigInteger.ZERO;