/** * Computes shares of products of this party's input elements and other party's mac key share. * * @param inputElements input field elements * @return shares of products of mac key share and input elements */ public List<FieldElement> extend(List<FieldElement> inputElements) { // use seeds to generate mask pairs List<Pair<FieldElement, FieldElement>> maskPairs = generateMaskPairs(inputElements.size()); // compute t0 - t1 + x for each input x for each mask pair List<FieldElement> diffs = helper.computeDiffs(maskPairs, inputElements); // send diffs network.send(otherId, resourcePool.getFieldDefinition().serialize(diffs)); // get zero index masks List<FieldElement> feZeroSeeds = maskPairs.parallelStream().map(Pair::getFirst).collect(Collectors.toList()); // compute product shares return helper.computeProductShares(feZeroSeeds, inputElements.size()); }
/** * Runs a batch of the entry wise product protocol with a given of right hand vector. * * <p> * For right vector <i><b>b</b>= b<sub>0</sub>, b<sub>1</sub>, ...)</i> and left vector of the * other party <i><b>a</b> = (a<sub>0</sub>, a<sub>1</sub>, ...)</i>, the protocol computes secret * shares of entry wise product <i>(a<sub>0</sub>b<sub>0</sub>, a<sub>1</sub>b<sub>1</sub>, ... * </i>). * </p> * * @param rightFactors this party's vector <i>b<sub>0</sub>, b<sub>1</sub> ...</i> * @return shares of the products <i>a<sub>0</sub>b<sub>0</sub>, a<sub>1</sub>b<sub>1</sub> ... * </i> */ public List<FieldElement> multiply(List<FieldElement> rightFactors) { List<Pair<StrictBitVector, StrictBitVector>> seedPairs = multiplyRightHelper.generateSeeds(rightFactors.size(), resourcePool.getModBitLength()); // convert seeds pairs to field elements so we can compute on them List<Pair<FieldElement, FieldElement>> feSeedPairs = seedsToFieldElements(seedPairs); // compute q0 - q1 + b for each seed pair List<FieldElement> diffs = multiplyRightHelper.computeDiffs(feSeedPairs, rightFactors); // send diffs over to other party network.send(otherId, resourcePool.getFieldDefinition().serialize(diffs)); // get zero index seeds List<FieldElement> feZeroSeeds = feSeedPairs.parallelStream().map(Pair::getFirst).collect(Collectors.toList()); // compute product shares return multiplyRightHelper.computeProductShares(feZeroSeeds, rightFactors.size()); }