From 73841f1cd1c3563c89a580e4d225b03f12ab4c6d Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Fri, 8 Nov 2019 11:36:20 +0100 Subject: [PATCH] Sober up. --- .../general/interpoly/GeneralInterPolyClient.java | 5 ++--- .../dk/au/pir/protocols/interpoly/InterPolyClient.java | 9 ++++----- ...agrangeInterpolation.java => BigIntegerLagrange.java} | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) rename pir/src/main/java/dk/au/pir/utils/{BigIntegerLagrangeInterpolation.java => BigIntegerLagrange.java} (87%) diff --git a/pir/src/main/java/dk/au/pir/protocols/general/interpoly/GeneralInterPolyClient.java b/pir/src/main/java/dk/au/pir/protocols/general/interpoly/GeneralInterPolyClient.java index 35e01c3..e60b4ce 100644 --- a/pir/src/main/java/dk/au/pir/protocols/general/interpoly/GeneralInterPolyClient.java +++ b/pir/src/main/java/dk/au/pir/protocols/general/interpoly/GeneralInterPolyClient.java @@ -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); } } 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 ac583e1..c671391 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 @@ -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); } } diff --git a/pir/src/main/java/dk/au/pir/utils/BigIntegerLagrangeInterpolation.java b/pir/src/main/java/dk/au/pir/utils/BigIntegerLagrange.java similarity index 87% rename from pir/src/main/java/dk/au/pir/utils/BigIntegerLagrangeInterpolation.java rename to pir/src/main/java/dk/au/pir/utils/BigIntegerLagrange.java index ac387d9..47c35df 100644 --- a/pir/src/main/java/dk/au/pir/utils/BigIntegerLagrangeInterpolation.java +++ b/pir/src/main/java/dk/au/pir/utils/BigIntegerLagrange.java @@ -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;