AesDemo implements Application<List<Boolean>, ProtocolBuilderBinary> { public AesDemo(int id, Boolean[] in) { this.in = in; this.id = id; } AesDemo(int id, Boolean[] in); static void main(String[] args); @Override DRes<List<Boolean>> buildComputation(ProtocolBuilderBinary producer);  }
@Test public void testAESDemo() { int noPlayers = 2; List<Integer> ports = NetworkUtil.getFreePorts(noPlayers); Map<Integer, NetworkConfiguration> netConf = NetworkUtil.getNetworkConfigurations(ports); Map<Integer, TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary>> conf = new HashMap<>(); for (int playerId : netConf.keySet()) { ProtocolSuite<ResourcePoolImpl, ProtocolBuilderBinary> suite = new DummyBooleanProtocolSuite(); ProtocolEvaluator<ResourcePoolImpl> evaluator = new BatchedProtocolEvaluator<>(new SequentialStrategy<>(), suite); SecureComputationEngine<ResourcePoolImpl, ProtocolBuilderBinary> sce = new SecureComputationEngineImpl<>(suite, evaluator); TestThreadConfiguration<ResourcePoolImpl, ProtocolBuilderBinary> ttc = new TestThreadConfiguration<>( sce, () -> new ResourcePoolImpl(playerId, noPlayers), () -> new SocketNetwork(netConf.get(playerId))); conf.put(playerId, ttc); } TestThreadFactory<ResourcePoolImpl, ProtocolBuilderBinary> f = new TestThreadFactory<ResourcePoolImpl, ProtocolBuilderBinary>() { @Override public TestThread<ResourcePoolImpl, ProtocolBuilderBinary> next() { return new TestThread<ResourcePoolImpl, ProtocolBuilderBinary>() { @Override public void test() throws Exception { Boolean[] input = null; if (conf.getMyId() == 2) { input = ByteAndBitConverter.toBoolean("00112233445566778899aabbccddeeff"); } else if (conf.getMyId() == 1) { input = ByteAndBitConverter.toBoolean("000102030405060708090a0b0c0d0e0f"); } AesDemo app = new AesDemo(conf.getMyId(), input); List<Boolean> aesResult = runApplication(app); String expected = "69c4e0d86a7b0430d8cdb78070b4c55a"; boolean[] actualBoolean = new boolean[aesResult.size()]; int i = 0; for (Boolean b : aesResult) { actualBoolean[i++] = b; } String actual = ByteAndBitConverter.toHex(actualBoolean); Assert.assertEquals(expected, actual); } }; } }; TestThreadRunner.run(f, conf); }