@Test
  public void sameKeysAreEqual() throws Exception {
    HpkeParameters params =
        HpkeParameters.builder()
            .setVariant(HpkeParameters.Variant.NO_PREFIX)
            .setKemId(HpkeParameters.KemId.DHKEM_X25519_HKDF_SHA256)
            .setKdfId(HpkeParameters.KdfId.HKDF_SHA256)
            .setAeadId(HpkeParameters.AeadId.AES_128_GCM)
            .build();
    Bytes publicKeyBytes = Bytes.copyFrom(X25519.publicFromPrivate(X25519.generatePrivateKey()));

    HpkePublicKey publicKey1 =
        HpkePublicKey.create(params, publicKeyBytes, /* idRequirement= */ null);
    HpkePublicKey publicKey2 =
        HpkePublicKey.create(params, publicKeyBytes, /* idRequirement= */ null);

    assertThat(publicKey1.equalsKey(publicKey2)).isTrue();
  }
Copied from {@link EllipticCurves#pointEncode} to bypass point validation.
java_src/src/test/java/com/google/crypto/tink/hybrid/HpkePublicKeyTest.java