/** * Creates a new {@link CopeInputter} and initializes the COPE protocol. * * <p>This will run the initialization sub-protocol of COPE using an OT protocol to set up the PRG * seeds used in the <i>Extend</i> sub-protocol.</p> */ public CopeInputter(MascotResourcePool resourcePool, Network network, int otherId) { this.otherId = otherId; this.resourcePool = resourcePool; this.network = network; this.leftPrgs = new ArrayList<>(); this.rightPrgs = new ArrayList<>(); this.helper = new MultiplyRightHelper(resourcePool, network, otherId); seedPrgs(helper.generateSeeds(1, resourcePool.getLambdaSecurityParam())); }
/** * 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()); }