@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 RotBatch createRot(int otherId, Network network) { if (getMyId() == otherId) { throw new IllegalArgumentException("Cannot initialize with self"); } CoinTossing ct = new CoinTossing(getMyId(), otherId, getRandomGenerator()); ct.initialize(network); OtExtensionResourcePool otResources = new OtExtensionResourcePoolImpl(getMyId(), otherId, getPrgSeedLength(), getLambdaSecurityParam(), getInstanceId(), getRandomGenerator(), ct, seedOts.get(otherId)); return new BristolRotBatch(new RotFactory(otResources, network), getPrgSeedLength(), getLambdaSecurityParam()); }
@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()); }