private void runTest( TestThreadFactory f, EvaluationStrategy evalStrategy, StorageStrategy storageStrategy) throws Exception { Level logLevel = Level.FINE; Reporter.init(logLevel); // Since SCAPI currently does not work with ports > 9999 we use fixed // ports // here instead of relying on ephemeral ports which are often > 9999. List<Integer> ports = new ArrayList<Integer>(noOfParties); for (int i = 1; i <= noOfParties; i++) { ports.add(9000 + i); } Map<Integer, NetworkConfiguration> netConf = TestConfiguration.getNetworkConfigurations(noOfParties, ports, logLevel); Map<Integer, TestThreadConfiguration> conf = new HashMap<Integer, TestThreadConfiguration>(); for (int playerId : netConf.keySet()) { TestThreadConfiguration ttc = new TestThreadConfiguration(); ttc.netConf = netConf.get(playerId); // This fixes parameters, e.g., security parameter 80 is always // used. // To run tests with varying parameters, do as in the BGW case with // different thresholds. SpdzConfiguration spdzConf = new SpdzConfigurationFromProperties(); ttc.protocolSuiteConf = spdzConf; boolean useSecureConnection = false; // No tests of secure // connection // here. int noOfVMThreads = 3; int noOfThreads = 3; ProtocolSuite suite = SpdzProtocolSuite.getInstance(playerId); ProtocolEvaluator evaluator = EvaluationStrategy.fromEnum(evalStrategy); dk.alexandra.fresco.framework.sce.resources.storage.Storage storage = null; switch (storageStrategy) { case IN_MEMORY: storage = inMemStore; break; case MYSQL: storage = mySQLStore; break; } ttc.sceConf = new TestSCEConfiguration( suite, evaluator, noOfThreads, noOfVMThreads, ttc.netConf, storage, useSecureConnection); conf.put(playerId, ttc); } TestThreadRunner.run(f, conf); }
@Override public EvaluationStatus evaluate(int round, ResourcePool resourcePool, SCENetwork network) { int players = resourcePool.getNoOfParties(); switch (round) { case 0: network.sendToAll(commitment.getCommitment()); network.expectInputFromAll(); break; case 1: List<BigInteger> commitments = network.receiveFromAll(); for (int i = 0; i < commitments.size(); i++) { comms.put(i + 1, commitments.get(i)); } if (players < 3) { done = true; } else { broadcastDigest = sendBroadcastValidation( SpdzProtocolSuite.getInstance(resourcePool.getMyId()) .getMessageDigest(network.getThreadId()), network, commitments, players); network.expectInputFromAll(); } break; case 2: boolean validated = receiveBroadcastValidation(network, broadcastDigest); if (!validated) { throw new MPCException("Broadcast of commitments was not validated. Abort protocol."); } done = true; break; default: throw new MPCException("No further rounds."); } EvaluationStatus status = (done) ? EvaluationStatus.IS_DONE : EvaluationStatus.HAS_MORE_ROUNDS; return status; }