@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()); }
/** * Receive the serialized message from the current 1-out-of-2 OT. * * @param choiceBit * Choice-bit. False for message 0, true for message 1. * @return The serialized message from the OT */ public byte[] receive(boolean choiceBit) { // Check if there is still an unused random OT stored, if not, execute a // random OT extension if (offset < 0 || offset >= batchSize) { choices = new StrictBitVector(batchSize, resources.getRandomGenerator()); randomMessages = receiver.extend(choices); offset = 0; } // Notify the sender if it should switch the 0 and 1 messages around (s.t. // the random choice bit in the preprocessed random OTs matches the true // choice bit sendSwitchBit(choiceBit); // Receive the serialized adjusted messages byte[] zeroAdjustment = network.receive(resources.getOtherId()); byte[] oneAdjustment = network.receive(resources.getOtherId()); byte[] res = doActualReceive(zeroAdjustment, oneAdjustment); offset++; return res; }