@Test
public void testBasicEncryption() throws Exception {

  EllipticCurveType curve = EllipticCurveType.NIST_P384;
  HashType hashType = HashType.SHA256;
  EcPointFormat primaryPointFormat = EcPointFormat.UNCOMPRESSED;
  EcPointFormat rawPointFormat = EcPointFormat.COMPRESSED;
  KeyTemplate primaryDemKeyTemplate = AeadKeyTemplates.AES128_CTR_HMAC_SHA256;
  KeyTemplate rawDemKeyTemplate = AeadKeyTemplates.AES128_CTR_HMAC_SHA256;
  byte[] primarySalt = "some salt".getBytes("UTF-8");
  byte[] rawSalt = "other salt".getBytes("UTF-8");
  EciesAeadHkdfPrivateKey primaryPrivProto =
      TestUtil.generateEciesAeadHkdfPrivKey(
          curve, hashType, primaryPointFormat, primaryDemKeyTemplate, primarySalt);
  Key primaryPriv =
      TestUtil.createKey(
          TestUtil.createKeyData(
              primaryPrivProto,
              new EciesAeadHkdfPrivateKeyManager().getKeyType(),
              KeyData.KeyMaterialType.ASYMMETRIC_PRIVATE),
          8,
          KeyStatusType.ENABLED,
          OutputPrefixType.RAW);
  Key primaryPub =
      TestUtil.createKey(
          TestUtil.createKeyData(
              primaryPrivProto.getPublicKey(),
              new EciesAeadHkdfPublicKeyManager().getKeyType(),
              KeyData.KeyMaterialType.ASYMMETRIC_PUBLIC),
          42,
          KeyStatusType.ENABLED,
          OutputPrefixType.RAW);
  EciesAeadHkdfPrivateKey rawPrivProto =
      TestUtil.generateEciesAeadHkdfPrivKey(
          curve, hashType, rawPointFormat, rawDemKeyTemplate, rawSalt);
  Key rawPriv =
      TestUtil.createKey(
          TestUtil.createKeyData(
              rawPrivProto,
              new EciesAeadHkdfPrivateKeyManager().getKeyType(),
              KeyData.KeyMaterialType.ASYMMETRIC_PRIVATE),
          11,
          KeyStatusType.ENABLED,
          OutputPrefixType.RAW);
  Key rawPub =
      TestUtil.createKey(
          TestUtil.createKeyData(
              rawPrivProto.getPublicKey(),
              new EciesAeadHkdfPublicKeyManager().getKeyType(),
              KeyData.KeyMaterialType.ASYMMETRIC_PUBLIC),
          43,
          KeyStatusType.ENABLED,
          OutputPrefixType.RAW);
  KeysetHandle keysetHandlePub =
      TestUtil.createKeysetHandle(TestUtil.createKeyset(primaryPub, rawPub));
  KeysetHandle keysetHandlePriv =
      TestUtil.createKeysetHandle(TestUtil.createKeyset(primaryPriv, rawPriv));
  HybridEncrypt hybridEncrypt = HybridEncryptFactory.getPrimitive(keysetHandlePub);
  HybridDecrypt hybridDecrypt = HybridDecryptFactory.getPrimitive(keysetHandlePriv);
  byte[] plaintext = Random.randBytes(20);
  byte[] contextInfo = Random.randBytes(20);
  byte[] ciphertext = hybridEncrypt.encrypt(plaintext, contextInfo);
  assertArrayEquals(plaintext, hybridDecrypt.decrypt(ciphertext, contextInfo));
}