code: def serialize(self) -> str:
          
  
          return {
              '@context': DIDDoc.CONTEXT,
              'id': canon_ref(self.did, self.did),
              'publicKey': [pubkey.to_dict() for pubkey in self.pubkey.values()],
              'authentication': [{
                  'type': pubkey.type.authn_type,
                  'publicKey': canon_ref(self.did, pubkey.id)
              } for pubkey in self.pubkey.values() if pubkey.authn],
              'service': [service.to_dict() for service in self.service.values()]
          }
docs: Dump current object to a JSON-compatible dictionary.
  
          :return: dict representation of current DIDDoc