// In the shuffle phase, we have to receive a set of strings from the previous player and // decrypt them all. final Message decryptAll(Message message, DecryptionKey key, int expected) throws IOException, InterruptedException, FormatException { Message decrypted = messages.make(); int count = 0; Set<String> addrs = new HashSet<>(); // Used to check that all addresses are different. while (!message.isEmpty()) { String encrypted = message.readString(); message = message.rest(); addrs.add(encrypted); count++; decrypted = decrypted.attach(key.decrypt(encrypted)); } if (addrs.size() != count || count != expected) { phase.set(Phase.Blame); mailbox.broadcast( messages.make().attach(Blame.ShuffleFailure(players.get(N))), phase.get()); return null; } return decrypted; }