/** * Constructs new mac checker. */ public MacCheck(MascotResourcePool resourcePool, Network network) { super(resourcePool, network, resourcePool.getFieldDefinition()); }
@Override public int getPrgSeedLength() { return mascotSecurityParameters.getPrgSeedLength(); } }
/** * Creates new coin-tossing protocol. */ public CoinTossingMpc(MascotResourcePool resourcePool, Network network) { super(resourcePool, network, resourcePool.getStrictBitVectorSerializer()); }
private void ensureInitialized() { if (mascot != null) { return; } int numCandidatesPerTriple = 3; mascot = new Mascot( new MascotResourcePoolImpl(myId, numberOfPlayers, instanceId, drbg, seedOts, new MascotSecurityParameters(modBitLength, prgSeedLength, numCandidatesPerTriple), this.fieldDefinition), tripleNetwork.get(), ssk); } }
/** * Creates a new {@link CopeInputter} and initializes the COPE protocol. * * <p>This will run the initialization sub-protocol of COPE using an OT protocol to set up the PRG * seeds used in the <i>Extend</i> sub-protocol.</p> */ public CopeInputter(MascotResourcePool resourcePool, Network network, int otherId) { this.otherId = otherId; this.resourcePool = resourcePool; this.network = network; this.leftPrgs = new ArrayList<>(); this.rightPrgs = new ArrayList<>(); this.helper = new MultiplyRightHelper(resourcePool, network, otherId); seedPrgs(helper.generateSeeds(1, resourcePool.getLambdaSecurityParam())); }
public MultiplyLeftHelper(MascotResourcePool resourcePool, Network network, int otherId) { this.resourcePool = resourcePool; this.fieldElementUtils = new FieldElementUtils(resourcePool.getFieldDefinition()); this.rot = resourcePool.createRot(otherId, network); }
private void seedPrgs(List<StrictBitVector> seeds) { for (StrictBitVector seed : seeds) { prgs.add(new FieldElementPrgImpl(seed, resourcePool.getFieldDefinition())); } } }
/** * Generates random bits (as authenticated elements). * * @param numBits number of bits to generate * @return random bits */ public List<AuthenticatedElement> getRandomBits(int numBits) { return bitConverter.convertToBits(getRandomElements(numBits)); } }
/** * Creates new {@link CommitmentBasedInput}. */ public CommitmentBasedInput(MascotResourcePool resourcePool, Network network, ByteSerializer<T> serializer) { this.resourcePool = resourcePool; this.network = network; this.serializer = serializer; // for more than two parties, we need to use broadcast if (resourcePool.getNoOfParties() > 2) { this.broadcaster = new BroadcastingNetworkProxy(network, new BroadcastValidation(resourcePool, network)); } else { // if we have two parties or less we can just use the regular network this.broadcaster = this.network; } }
/** * Creates new triple generation protocol. */ public TripleGeneration(MascotResourcePool resourcePool, Network network, ElementGeneration elementGeneration, FieldElementPrg jointSampler) { this.resourcePool = resourcePool; this.fieldElementUtils = new FieldElementUtils(resourcePool.getFieldDefinition()); this.leftMultipliers = new HashMap<>(); this.rightMultipliers = new HashMap<>(); initializeMultipliers(resourcePool, network); this.elementGeneration = elementGeneration; this.jointSampler = jointSampler; }
/** * 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())); }
@Override public int getLambdaSecurityParam() { return mascotSecurityParameters.getLambdaSecurityParam(); }
@Override public int getNumCandidatesPerTriple() { return mascotSecurityParameters.getNumCandidatesPerTriple(); }
/** * Computes digest of messages and resets md. */ private byte[] computeDigest(List<byte[]> messages) { for (byte[] message : messages) { resourcePool.getMessageDigest().update(message); } byte[] digest = resourcePool.getMessageDigest().digest(); resourcePool.getMessageDigest().reset(); return digest; }
public MultiplyRightHelper(MascotResourcePool resourcePool, Network network, int otherId) { this.resourcePool = resourcePool; this.fieldElementUtils = new FieldElementUtils(resourcePool.getFieldDefinition()); this.rot = resourcePool.createRot(otherId, network); }
private void seedPrgs(List<Pair<StrictBitVector, StrictBitVector>> seeds) { for (Pair<StrictBitVector, StrictBitVector> seedPair : seeds) { FieldDefinition definition = resourcePool.getFieldDefinition(); this.leftPrgs.add(new FieldElementPrgImpl(seedPair.getFirst(), definition)); this.rightPrgs.add(new FieldElementPrgImpl(seedPair.getSecond(), definition)); } } }
private Drbg getDrbg() { byte[] drbgSeed = new byte[mascotSecurityParameters.getPrgSeedLength() / 8]; new SecureRandom().nextBytes(drbgSeed); Drbg drbg = AesCtrDrbgFactory.fromDerivedSeed(drbgSeed); return drbg; }
private FieldElement fromBits(StrictBitVector vector) { // safe since the modulus is guaranteed to be close enough to 2^modBitLength return resourcePool.getFieldDefinition().deserialize(vector.toByteArray()); } }
private Map<Integer, FieldElement> setupMacKeyShares() { Map<Integer, FieldElement> macKeyShares = new HashMap<>(); for (int myId = 1; myId <= noOfParties; myId++) { FieldElement ssk = SpdzMascotDataSupplier .createRandomSsk(definition, mascotSecurityParameters.getPrgSeedLength()); macKeyShares.put(myId, ssk); } return macKeyShares; }
private FieldElement fromBits(StrictBitVector vector) { // safe since the modulus is guaranteed to be close enough to 2^modBitLength return resourcePool.getFieldDefinition().deserialize(vector.toByteArray()); }