class InitialAEAD {

  public static AEAD create(final byte[] keyMaterial, final boolean isClient) {
    final byte[] initialSecret = HKDF.extract(QUIC_VERSION_1_SALT, keyMaterial);

    final int length = 32;

    final byte[] clientSecret = expand(initialSecret, CLIENT_INITIAL, length);
    final byte[] serverSecret = expand(initialSecret, SERVER_INITIAL, length);

    final byte[] mySecret;
    final byte[] otherSecret;
    if (isClient) {
      mySecret = clientSecret;
      otherSecret = serverSecret;
    } else {
      mySecret = serverSecret;
      otherSecret = clientSecret;
    }

    final byte[] myKey = expand(mySecret, KEY, 16);
    final byte[] myIV = expand(mySecret, IV, 12);

    final byte[] otherKey = expand(otherSecret, KEY, 16);
    final byte[] otherIV = expand(otherSecret, IV, 12);

    final byte[] myPnKey = expand(mySecret, HP_KEY, 16);
    final byte[] otherPnKey = expand(otherSecret, HP_KEY, 16);

    return new AEAD(myKey, otherKey, myIV, otherIV, myPnKey, otherPnKey);
  }

}