diff --git a/mixer/src/main/java/meerkat/mixer/mixing/BenesNetwork.java b/mixer/src/main/java/meerkat/mixer/mixing/BenesNetwork.java index fc0e37a..ded8997 100644 --- a/mixer/src/main/java/meerkat/mixer/mixing/BenesNetwork.java +++ b/mixer/src/main/java/meerkat/mixer/mixing/BenesNetwork.java @@ -33,16 +33,16 @@ public class BenesNetwork implements PermutationNetwork * (that is, switch j has inputs/outputs 2j and 2j+1) * * @param logN log (base 2) of number of inputs to Benes network (N = 2^{logN}) - * @param layer current layer index. Must be between 1 and 2*logN-2 (layer 0 doesn't have a previous layer) + * @param layer current layer index. Must be between 0 and 2*logN-1 (layer -1 is the inputs and layer 2*logN-1 is the outputs) * @param inputIdx the input Idx for the current layer (must be between 0 and (1 << logN) - 1 * * @return the requested index */ public static int getOutputIdxInPreviousLayer(int logN, int layer, int inputIdx) { - assert (layer >= 0) && (layer < 2*logN - 1); + assert (layer >= 0) && (layer <= 2*logN - 1); assert (inputIdx >= 0) && (inputIdx < 1 << logN); - if ((layer == 0) || (inputIdx & 1) == 0) { + if ((layer == 0) || (layer == 2*logN - 1) || (inputIdx & 1) == 0) { // layer 0 inputs and all even inputs // are connected straight "across" everywhere return inputIdx; diff --git a/mixer/src/main/java/meerkat/mixer/mixing/Mixer.java b/mixer/src/main/java/meerkat/mixer/mixing/Mixer.java index 0b6e184..5f013e3 100644 --- a/mixer/src/main/java/meerkat/mixer/mixing/Mixer.java +++ b/mixer/src/main/java/meerkat/mixer/mixing/Mixer.java @@ -147,9 +147,6 @@ public class Mixer implements meerkat.crypto.mixnet.Mixer { , EncryptionRandomness[][] randomnesses) throws InvalidProtocolBufferException { int layers = mixNetwork.getNumLayers(); int n = mixNetwork.getNumInputs(); - Switch[] switchesLayer; - int index1,index2; - int switchIndex = 0; int numSwitches = n >> 1; Mix2Proof[][] proofsTable = new Mix2Proof[layers][numSwitches]; @@ -168,7 +165,7 @@ public class Mixer implements meerkat.crypto.mixnet.Mixer { r1 = randomnesses[layer][2 * switchIdx]; r2 = randomnesses[layer][2 * switchIdx + 1]; - proofsTable[layer][switchIndex] = + proofsTable[layer][switchIdx] = prover.prove(a, b, c, d, isCrossed, layer, switchIdx, out0, out1, r1, r2); } } @@ -187,7 +184,7 @@ public class Mixer implements meerkat.crypto.mixnet.Mixer { int n = ciphertexts.size(); assert (n > 1 && isPowerOfTwo(n)); - int logN = Integer.numberOfTrailingZeros(Integer.highestOneBit(n)) + 1; + int logN = Integer.numberOfTrailingZeros(Integer.highestOneBit(n)); PermutationNetwork net = generateMixNetwork(logN,random); diff --git a/mixer/src/main/java/meerkat/mixer/proofs/Mix2.java b/mixer/src/main/java/meerkat/mixer/proofs/Mix2.java index 616b7fd..9884e36 100644 --- a/mixer/src/main/java/meerkat/mixer/proofs/Mix2.java +++ b/mixer/src/main/java/meerkat/mixer/proofs/Mix2.java @@ -18,6 +18,7 @@ public class Mix2 { public ChallengeGenerator(ECElGamalEncryption encryptor, Random rand) { this.encryptor = encryptor; + this.rand = rand; group = encryptor.getGroup(); }