class AesDemo implements Application<List<Boolean>, ProtocolBuilderBinary> {

  public static <ResourcePoolT extends ResourcePool> void main(String[] args) throws IOException {
    CmdLineUtil<ResourcePoolT, ProtocolBuilderBinary> util = new CmdLineUtil<>();

    util.addOption(Option.builder("in")
        .desc("The input to use for encryption. " + "A " + INPUT_LENGTH
            + " char hex string. Required for player 1 and 2. "
            + "For player 1 this is interpreted as the AES key. "
            + "For player 2 this is interpreted as the plaintext block to encrypt.")
        .longOpt("input").hasArg().build());
    
    CommandLine cmd = util.parse(args);
    
    // Get and validate the AES specific input.
    Boolean[] input;
    int myId = util.getNetworkConfiguration().getMyId();
    if (myId == 1 || myId == 2) {

      if (!cmd.hasOption("in")) {
        throw new IllegalArgumentException("Player 1 and 2 must submit input");
      } else {
        if (cmd.getOptionValue("in").length() != INPUT_LENGTH) {
          throw new IllegalArgumentException(
              "bad input hex string: must be hex string of length " + INPUT_LENGTH);
        }
        input = ByteAndBitConverter.toBoolean(cmd.getOptionValue("in"));
      }
    } else {
      if (cmd.hasOption("in")) {
        throw new IllegalArgumentException("Only player 1 and 2 should submit input");
      }
      input = ByteAndBitConverter.toBoolean("00000000000000000000000000000000");
    }

    
    ProtocolSuite<ResourcePoolT, ProtocolBuilderBinary> psConf = util.getProtocolSuite();

    SecureComputationEngine<ResourcePoolT, ProtocolBuilderBinary> sce =
        new SecureComputationEngineImpl<>(psConf, util.getEvaluator());

    ResourcePoolT resourcePool = util.getResourcePool();
    AesDemo aes = new AesDemo(util.getNetworkConfiguration().getMyId(), input);
    List<Boolean> aesResult = sce.runApplication(aes, resourcePool, util.getNetwork());
    
    util.closeNetwork();
    sce.shutdownSCE();

    // Print result.
    boolean[] res = new boolean[BLOCK_SIZE];
    for (int i = 0; i < BLOCK_SIZE; i++) {
      res[i] = aesResult.get(i);
    }
    System.out.println("The resulting ciphertext is: " + ByteAndBitConverter.toHex(res));

  }

  public  AesDemo(int id, Boolean[] in);

}