@Override
  public byte[] decapsulate(byte[] encapsulatedKey, HpkeKemPrivateKey recipientPrivateKey)
      throws GeneralSecurityException {
    ECPrivateKey privateKey =
        EllipticCurves.getEcPrivateKey(
            curve, recipientPrivateKey.getSerializedPrivate().toByteArray());
    ECPublicKey publicKey =
        EllipticCurves.getEcPublicKey(curve, PointFormatType.UNCOMPRESSED, encapsulatedKey);
    byte[] dhSharedSecret = EllipticCurves.computeSharedSecret(privateKey, publicKey);
    return deriveKemSharedSecret(
        dhSharedSecret, encapsulatedKey, recipientPrivateKey.getSerializedPublic().toByteArray());
  }
Helper function factored out to facilitate unit testing.
java_src/src/main/java/com/google/crypto/tink/hybrid/internal/NistCurvesHpkeKem.java