@Override
  int[] createInitialState(final int[] nonce, int counter) {
    if (nonce.length != nonceSizeInBytes() / 4) {
      throw new IllegalArgumentException(
          String.format(
              "XChaCha20 uses 192-bit nonces, but got a %d-bit nonce", nonce.length * 32));
    }
    // Set the initial state based on
    // https://tools.ietf.org/html/draft-arciszewski-xchacha-01#section-2.3.
    int[] state = new int[ChaCha20Util.BLOCK_SIZE_IN_INTS];
    ChaCha20Util.setSigmaAndKey(state, ChaCha20Util.hChaCha20(this.key, nonce));
    state[12] = counter;
    state[13] = 0;
    state[14] = nonce[4];
    state[15] = nonce[5];
    return state;
  }
Constructs a new InsecureNonceXChaCha20 cipher with the supplied {@code key}.

@throws IllegalArgumentException when {@code key} length is not {@link
    ChaCha20Util#KEY_SIZE_IN_BYTES}.
java_src/src/main/java/com/google/crypto/tink/aead/internal/InsecureNonceXChaCha20.java