private void testSenderAndRecipientAuthContexts(
      byte[] mode, byte[] kemId, byte[] kdfId, byte[] aeadId, HpkeParameters parameters)
      throws GeneralSecurityException {
    HpkeTestVector testVector = getTestVector(mode, kemId, kdfId, aeadId);
    HpkeTestSetup testSetup = testVector.getTestSetup();

    HpkeKem kem = HpkePrimitiveFactory.createKem(kemId);
    HpkeKdf kdf = HpkePrimitiveFactory.createKdf(kdfId);
    HpkeAead aead = HpkePrimitiveFactory.createAead(aeadId);

    HpkePublicKey recipientPublicKey =
        HpkePublicKey.create(
            parameters, Bytes.copyFrom(testSetup.recipientPublicKey), /* idRequirement= */ null);
    HpkePrivateKey recipientPrivateKey =
        HpkePrivateKey.create(
            recipientPublicKey,
            SecretBytes.copyFrom(testSetup.recipientPrivateKey, InsecureSecretKeyAccess.get()));
    HpkePublicKey senderPublicKey =
        HpkePublicKey.create(
            parameters, Bytes.copyFrom(testSetup.senderPublicKey), /* idRequirement= */ null);
    HpkePrivateKey senderPrivateKey =
        HpkePrivateKey.create(
            senderPublicKey,
            SecretBytes.copyFrom(testSetup.senderPrivateKey, InsecureSecretKeyAccess.get()));

    HpkeKemPrivateKey senderKemPrivateKey = HpkeKemKeyFactory.createPrivate(senderPrivateKey);
    HpkeContext senderContext =
        HpkeContext.createAuthSenderContext(
            recipientPublicKey, kem, kdf, aead, testSetup.info, senderKemPrivateKey);

    HpkeKemPrivateKey recipientKemPrivateKey = HpkeKemKeyFactory.createPrivate(recipientPrivateKey);
    HpkeContext recipientContext =
        HpkeContext.createAuthRecipientContext(
            senderContext.getEncapsulatedKey(),
            recipientKemPrivateKey,
            kem,
            kdf,
            aead,
            testSetup.info,
            senderPublicKey);

    byte[] plaintext = Random.randBytes(200);
    byte[] aad = Random.randBytes(100);
    byte[] ciphertext = senderContext.seal(plaintext, aad);
    expect.that(recipientContext.open(ciphertext, aad)).isEqualTo(plaintext);
  }
Helper method to verify context API provided to Tink users.
java_src/src/test/java/com/google/crypto/tink/hybrid/internal/HpkeContextTest.java