@Theory
  public void createNistCurvePublicKey_failsIfPointNotOnCurve(
      @FromDataPoints("nistKemTuples") NistKemTuple tuple) throws Exception {
    HpkeParameters params =
        HpkeParameters.builder()
            .setVariant(HpkeParameters.Variant.NO_PREFIX)
            .setKemId(tuple.kemId)
            .setKdfId(HpkeParameters.KdfId.HKDF_SHA256)
            .setAeadId(HpkeParameters.AeadId.AES_128_GCM)
            .build();
    ECPublicKey ecPublicKey = (ECPublicKey) EllipticCurves.generateKeyPair(tuple.curve).getPublic();
    ECPoint point = ecPublicKey.getW();
    ECPoint badPoint = new ECPoint(point.getAffineX(), point.getAffineY().subtract(BigInteger.ONE));

    Bytes publicKeyBytes =
        Bytes.copyFrom(
            encodeUncompressedPoint(EllipticCurves.getCurveSpec(tuple.curve).getCurve(), badPoint));

    assertThrows(
        GeneralSecurityException.class,
        () -> HpkePublicKey.create(params, publicKeyBytes, /* idRequirement= */ null));
  }
Copied from {@link EllipticCurves#pointEncode} to bypass point validation.
java_src/src/test/java/com/google/crypto/tink/hybrid/HpkePublicKeyTest.java