code: async def download_cot(chain):
      
      artifact_tasks = []
      # only deal with chain.links, which are previously finished tasks with
      # signed chain of trust artifacts.  ``chain.task`` is the current running
      # task, and will not have a signed chain of trust artifact yet.
      for link in chain.links:
          task_id = link.task_id
          parent_dir = link.cot_dir
          urls = []
  
          unsigned_url = get_artifact_url(chain.context, task_id, 'public/chain-of-trust.json')
          urls.append(unsigned_url)
          if chain.context.config['verify_cot_signature']:
              urls.append(
                  get_artifact_url(chain.context, task_id, 'public/chain-of-trust.json.sig')
              )
  
          artifact_tasks.append(
              asyncio.ensure_future(
                  download_artifacts(
                      chain.context, urls, parent_dir=parent_dir,
                      valid_artifact_task_ids=[task_id]
                  )
              )
          )
  
      artifacts_paths = await raise_future_exceptions(artifact_tasks)
  
      for path in artifacts_paths:
          sha = get_hash(path[0])
          log.debug("{} downloaded; hash is {}".format(path[0], sha))
docs: Download the signed chain of trust artifacts.
  
      Args:
          chain (ChainOfTrust): the chain of trust to add to.
  
      Raises:
          BaseDownloadError: on failure.