@Override public List<Pair<StrictBitVector, StrictBitVector>> send(int numMessages, int sizeOfEachMessage) { if (this.sender == null) { this.sender = rot.createSender(); } int amountToPreprocess = computeExtensionSize(numMessages, comSecParam, statSecParam); Pair<List<StrictBitVector>, List<StrictBitVector>> messages = sender.extend(amountToPreprocess); List<StrictBitVector> zeroMessages = messages.getFirst().parallelStream().limit(numMessages) .map(m -> LengthAdjustment.adjust(m.toByteArray(), sizeOfEachMessage / Byte.SIZE)) .map(StrictBitVector::new) .collect(Collectors.toList()); List<StrictBitVector> oneMessages = messages.getSecond().parallelStream().limit(numMessages) .map(m -> LengthAdjustment.adjust(m.toByteArray(), sizeOfEachMessage / Byte.SIZE)) .map(StrictBitVector::new) .collect(Collectors.toList()); return IntStream.range(0, numMessages).parallel() .mapToObj(i -> new Pair<>(zeroMessages.get(i), oneMessages.get(i))) .collect(Collectors.toList()); }
@Override public List<StrictBitVector> receive(StrictBitVector choiceBits, int sizeOfEachMessage) { if (this.receiver == null) { this.receiver = rot.createReceiver(); } int amountToPreprocess = computeExtensionSize(choiceBits.getSize(), comSecParam, statSecParam); byte[] extraByteChoices = Arrays.copyOf(choiceBits.toByteArray(), amountToPreprocess / Byte.SIZE); List<StrictBitVector> messages = receiver.extend(new StrictBitVector(extraByteChoices)); return messages.parallelStream().limit(choiceBits.getSize()) .map(m -> LengthAdjustment.adjust(m.toByteArray(), sizeOfEachMessage / Byte.SIZE)) .map(StrictBitVector::new) .collect(Collectors.toList()); }