async function aesEncrypt(payload: string, key: CryptoKey, ivStr: string | ArrayBuffer): Promise<string> {
  const iv = typeof ivStr === "string" ? uint8arrays.fromString(ivStr, "base64") : ivStr
  return utils.arrBufToBase64(
    await webcrypto.subtle.encrypt(
      { name: "AES-GCM", iv },