private static void validateX25519PrivateKeyBytes(byte[] privateKeyBytes, byte[] publicKeyBytes)
      throws GeneralSecurityException {
    if (privateKeyBytes.length != 32) {
      throw new GeneralSecurityException("Private key bytes length for X25519 curve must be 32");
    }
    byte[] expectedPublicKeyBytes = X25519.publicFromPrivate(privateKeyBytes);
    if (!Arrays.equals(expectedPublicKeyBytes, publicKeyBytes)) {
      throw new GeneralSecurityException("Invalid private key for public key.");
    }
  }
Exactly one of nistPrivateKeyValue and x25519PrivateKeyBytes is non-null.
java_src/src/main/java/com/google/crypto/tink/hybrid/EciesPrivateKey.java