private void seedPrgs(List<StrictBitVector> seeds) { for (StrictBitVector seed : seeds) { prgs.add(new FieldElementPrgImpl(seed, resourcePool.getFieldDefinition())); } } }
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)); } } }
/** * Creates random field element that can be used as the mac key share by the calling party. */ public static FieldElement createRandomSsk(FieldDefinition definition, int prgSeedLength) { byte[] seedBytes = new byte[prgSeedLength / 8]; new SecureRandom().nextBytes(seedBytes); StrictBitVector seed = new StrictBitVector(seedBytes); FieldElementPrg localSampler = new FieldElementPrgImpl(seed, definition); return localSampler.getNext(); }
/** * Creates new {@link MascotResourcePoolImpl}. * * @param myId this party's id * @param noOfParties number of parties * @param instanceId the instance ID which is unique for this particular resource pool object, * but * only in the given execution. * @param drbg source of randomness * @param seedOts pre-computed base OTs * @param mascotSecurityParameters mascot security parameters ({@link * MascotSecurityParameters}) * @param fieldDefinition field used for calculations */ public MascotResourcePoolImpl(int myId, int noOfParties, int instanceId, Drbg drbg, Map<Integer, RotList> seedOts, MascotSecurityParameters mascotSecurityParameters, FieldDefinition fieldDefinition) { super(myId, noOfParties); this.drbg = drbg; this.instanceId = instanceId; this.seedOts = seedOts; this.fieldDefinition = fieldDefinition; this.mascotSecurityParameters = mascotSecurityParameters; this.localSampler = new FieldElementPrgImpl( new StrictBitVector(mascotSecurityParameters.getPrgSeedLength(), drbg), this.fieldDefinition); this.messageDigest = ExceptionConverter.safe(() -> MessageDigest.getInstance("SHA-256"), "Configuration error, SHA-256 is needed for Mascot"); }
/** * Creates new {@link Mascot}. */ public Mascot(MascotResourcePool resourcePool, Network network, FieldElement macKeyShare) { this.resourcePool = resourcePool; // agree on joint seed StrictBitVector jointSeed = new CoinTossingMpc(resourcePool, network) .generateJointSeed(resourcePool.getPrgSeedLength()); FieldElementPrg jointSampler = new FieldElementPrgImpl(jointSeed, resourcePool.getFieldDefinition()); this.elementGeneration = new ElementGeneration(resourcePool, network, macKeyShare, jointSampler); this.tripleGeneration = new TripleGeneration(resourcePool, network, elementGeneration, jointSampler); this.bitConverter = new BitConverter(resourcePool, new OnlinePhase(resourcePool, tripleGeneration, elementGeneration, macKeyShare), macKeyShare); }