private void evaluate(ProtocolBuilderNumeric spdzBuilder, SpdzResourcePool tripleResourcePool, Network network) { BatchedStrategy<SpdzResourcePool> batchedStrategy = new BatchedStrategy<>(); SpdzProtocolSuite spdzProtocolSuite = createProtocolSuite(maxBitLength); BatchedProtocolEvaluator<SpdzResourcePool> batchedProtocolEvaluator = new BatchedProtocolEvaluator<>(batchedStrategy, spdzProtocolSuite); batchedProtocolEvaluator.eval(spdzBuilder.build(), tripleResourcePool, network); } }
private void doMacCheck(Spdz2kResourcePool<PlainT> resourcePool, Network network) { Spdz2kBuilder<PlainT> builder = new Spdz2kBuilder<>(resourcePool.getFactory(), protocolSuite.createBasicNumericContext(resourcePool)); BatchEvaluationStrategy<Spdz2kResourcePool<PlainT>> batchStrategy = new BatchedStrategy<>(); BatchedProtocolEvaluator<Spdz2kResourcePool<PlainT>> evaluator = new BatchedProtocolEvaluator<>( batchStrategy, protocolSuite, batchSize); OpenedValueStore<Spdz2kSInt<PlainT>, PlainT> store = resourcePool.getOpenedValueStore(); Spdz2kMacCheckComputation<HighT, LowT, PlainT> macCheck = new Spdz2kMacCheckComputation<>( store.popValues(), resourcePool, converter); ProtocolBuilderNumeric sequential = builder.createSequential(); macCheck.buildComputation(sequential); evaluator.eval(sequential.build(), resourcePool, network); }
protected void doMacCheck(SpdzResourcePool resourcePool, Network network) { SpdzBuilder spdzBuilder = new SpdzBuilder( spdzProtocolSuite.createNumericContext(resourcePool), spdzProtocolSuite.createRealNumericContext()); BatchEvaluationStrategy<SpdzResourcePool> batchStrategy = new BatchedStrategy<>(); BatchedProtocolEvaluator<SpdzResourcePool> evaluator = new BatchedProtocolEvaluator<>(batchStrategy, spdzProtocolSuite, batchSize); OpenedValueStore<SpdzSInt, FieldElement> store = resourcePool.getOpenedValueStore(); SpdzMacCheckProtocol macCheck = new SpdzMacCheckProtocol(secRand, resourcePool.getMessageDigest(), store.popValues(), resourcePool.getModulus(), resourcePool.getRandomGenerator(), resourcePool.getDataSupplier().getSecretSharedKey()); ProtocolBuilderNumeric sequential = spdzBuilder.createSequential(); macCheck.buildComputation(sequential); evaluator.eval(sequential.build(), resourcePool, network); }
/** * Evaluates, on the fly, a coin-tossing computation to get joint seed. */ private byte[] runCoinTossing(Computation<byte[], ProtocolBuilderNumeric> coinTossing, Network network) { NetworkBatchDecorator networkBatchDecorator = new NetworkBatchDecorator( this.getNoOfParties(), network); BuilderFactoryNumeric builderFactory = new Spdz2kBuilder<>(factory, new BasicNumericContext(effectiveBitLength, getMyId(), getNoOfParties(), null)); ProtocolBuilderNumeric root = builderFactory.createSequential(); DRes<byte[]> jointSeed = coinTossing .buildComputation(root); ProtocolProducer coinTossingProducer = root.build(); do { ProtocolCollectionList<Spdz2kResourcePool> protocolCollectionList = new ProtocolCollectionList<>( 128); // batch size is irrelevant since this is a very light-weight protocol coinTossingProducer.getNextProtocols(protocolCollectionList); new BatchedStrategy<Spdz2kResourcePool>() .processBatch(protocolCollectionList, this, networkBatchDecorator); } while (coinTossingProducer.hasNextProtocols()); return jointSeed.out(); } }