/** * Agree on a list of {@code size} coin-tossed elements, represented by StrictBitVectors. Each * consisting of bits reflecting the computational security used at initialization of this class * * @param size The amount of elements in the resultant list * @return The list of coin-tossed elements */ protected List<StrictBitVector> getChallenges(int size) { List<StrictBitVector> list = new ArrayList<>(size); for (int i = 0; i < size; i++) { StrictBitVector currentToss = ct.toss(comSecParam); list.add(currentToss); } return list; } }
/** * Initialize the coin-tossing functionality by making the parties agree on a seed. * * @param network * The network instance */ public void initialize(Network network) { if (initialized) { throw new IllegalStateException("Already initialized"); } // Make space for a seed by allocating as many bytes as needed, which is // exactly 32 bytes for AesCtrDrbg byte[] seed = new byte[32]; rand.nextBytes(seed); byte[] otherSeed = exchangeSeeds(seed, network); ByteArrayHelper.xor(seed, otherSeed); this.coinTossingPrg = new AesCtrDrbg(seed); initialized = true; }
@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()); }
this.supplier = () -> { RotList rotList = new RotList(drbg, computationalSecurity); CoinTossing ct = new CoinTossing(myId, Util.otherPlayerId(myId), drbg); OtExtensionResourcePool otExtRes = new OtExtensionResourcePoolImpl(myId, Util.otherPlayerId(myId), rotList.send(baseOt); ct.initialize(network.get());