/** * Sends own commitment to others and receives others' commitments. * * @param comm own commitment */ private List<HashBasedCommitment> distributeCommitments(HashBasedCommitment comm) { // broadcast own commitment broadcaster.sendToAll(getResourcePool().getCommitmentSerializer().serialize(comm)); // receive other parties' commitments from broadcast List<byte[]> rawComms = broadcaster.receiveFromAll(); // parse return rawComms.stream() .map(getResourcePool().getCommitmentSerializer()::deserialize) .collect(Collectors.toList()); }
/** * Generates random seed and calls {@link CoinTossingMpc#generateJointSeed(StrictBitVector)}. * * @param bitLengthSeed bit length of seed * @return shared seed */ public StrictBitVector generateJointSeed(int bitLengthSeed) { // generate own seed return generateJointSeed(new StrictBitVector(bitLengthSeed, super.getResourcePool().getRandomGenerator())); }
/** * Uses commitments to securely distribute the given value to the other parties and receive their * inputs. * * @param value value to commit to * @return the other parties' values */ protected List<T> allCommit(T value) { // commit to sigma HashBasedCommitment ownComm = new HashBasedCommitment(); // commit to value locally byte[] ownOpening = ownComm .commit(getResourcePool().getRandomGenerator(), serializer.serialize(value)); // all parties commit List<HashBasedCommitment> comms = distributeCommitments(ownComm); // all parties send opening info List<byte[]> openings = distributeOpenings(ownOpening); // open commitments using received opening info return open(comms, openings); }