Skip to content

Commit

Permalink
Addresed minor review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jot2re committed Jan 24, 2018
1 parent 3e61953 commit 0515efa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
18 changes: 10 additions & 8 deletions core/src/main/java/dk/alexandra/fresco/framework/util/Drbg.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package dk.alexandra.fresco.framework.util;

/**
* Interface for Determenistic Random Bit Generators.
* Interface for Deterministic Random Bit Generators.
* <p>
* Often, we need a source of randomness that can be seeded 'deterministically', e.g. in the sense
* that two instances created with the same seed yields the same sequence of pseudo random bytes,
* but can still not be easily guessed by an adversary. That is, the generator is cryptographically
* secure if a long enough seed has been given.
* Often, we need a source of randomness that can be seeded 'deterministically',
* e.g. in the sense that two instances created with the same seed yields the
* same sequence of pseudo random bytes, but can still not be easily guessed by
* an adversary. That is, the generator is cryptographically secure if a long
* enough seed has been given.
* </p>
* <p>
* Implementations of this class will have the property that data generated is pseudo-random and if
* all parties uses the same seed(s), calls to {@link #nextBytes(byte[])} will be deterministic and
* secure against third parties trying to guess the resulting randomness. For actual security
* Implementations of this class will have the property that data generated is
* pseudo-random and if all parties uses the same seed(s), calls to
* {@link #nextBytes(byte[])} will be deterministic and secure against third
* parties trying to guess the resulting randomness. For actual security
* guarantees, we refer to the individual implementations.
* </p>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import java.util.List;

/**
* A wrapper class for a list of random seed OTs. An instance of this class (once {@code send}
* and/or {@code receive} has been called) is meant to be used for several OT extension instances.
* <br/>
* Notice that an instance of this class is only meant to contain a single and static list of OTs.
* Thus a new instance must be made if one wishes to construct a list of new and random OTs.
* A wrapper class for a list of random seed OTs. An instance of this class
* (once {@code send} and/or {@code receive} has been called) is meant to be
* used for several OT extension instances.
* <p>
* Notice that an instance of this class is only meant to contain a single and
* static list of OTs. Thus a new instance must be made if one wishes to
* construct a list of new and random OTs.
* </p>
*/
public class RotList {
private final int amount;
Expand Down Expand Up @@ -46,7 +49,11 @@ public RotList(Drbg rand, int amount) {
}

/**
* Sends the prepared random OTs using {@code ot} as the underlying OT functionality.
* Sends the prepared random OTs using {@code ot} as the underlying OT
* functionality.
* <p>
* This method should only be called once.
* </p>
*
* @param ot
* The OT functionality to use for sending the random OTs
Expand All @@ -62,7 +69,11 @@ public void send(Ot ot) {
}

/**
* Executes the receiving parts of the list of OTs using {@code ot} as the underlying OT protocol.
* Executes the receiving parts of the list of OTs using {@code ot} as the
* underlying OT protocol.
* <p>
* This method should only be called once.
* </p>
*
* @param ot
* The OT functionality to use for receiving the random OTs
Expand All @@ -79,8 +90,10 @@ public void receive(Ot ot) {
}

/**
* Retrieves the list of random messages used as the sending part of the OTs,
* assuming the OTs have been executed.
* Retrieves the list of random messages used as the sending part of the OTs.
* <p>
* Can only be called after {@link #send(Ot)}.
* </p>
*
* @return The random messages used for the sender in list of OTs
*/
Expand All @@ -92,8 +105,11 @@ public List<Pair<StrictBitVector, StrictBitVector>> getSentMessages() {
}

/**
* Retrieves the list of random messages used as the receiving part of the OTs,
* assuming the OTs have been executed.
* Retrieves the list of random messages used as the receiving part of the
* OTs.
* <p>
* Can only be called after {@link #receive(Ot)}.
* </p>
*
* @return The random messages used for the receiver in list of OTs
*/
Expand All @@ -105,9 +121,14 @@ public List<StrictBitVector> getLearnedMessages() {
}

/**
* Returns the bit vector of the random choices the receiving party has used in the list of OTs.
* Returns the bit vector of the random choices the receiving party has used
* in the list of OTs.
* <p>
* Can only be called after {@link #receive(Ot)}.
* </p>
*
* @return The bit vector of random choices used by the receiver in the list of OTs
* @return The bit vector of random choices used by the receiver in the list
* of OTs
*/
public StrictBitVector getChoices() {
if (received == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ protected List<StrictBitVector> hashBitVector(List<StrictBitVector> input, int s
List<StrictBitVector> res = new ArrayList<>(size);
// Allocate a buffer to contain the index of the value to hash along with
// the value itself.
// Size of an int is always 4 bytes in java
ByteBuffer indexBuffer = ByteBuffer
.allocate(4 + input.get(0).getSize() * 8);
.allocate(Integer.SIZE + input.get(0).getSize() / 8);
byte[] hash;
for (int i = 0; i < size; i++) {
indexBuffer.clear();
Expand Down

0 comments on commit 0515efa

Please sign in to comment.