code: def pre_signature_part(ident, public_key=None, identifier=None, digest_alg=None, sign_alg=None):
      
  
      if not digest_alg:
          digest_alg = ds.DefaultSignature().get_digest_alg()
      if not sign_alg:
          sign_alg = ds.DefaultSignature().get_sign_alg()
      signature_method = ds.SignatureMethod(algorithm=sign_alg)
      canonicalization_method = ds.CanonicalizationMethod(
          algorithm=ds.ALG_EXC_C14N)
      trans0 = ds.Transform(algorithm=ds.TRANSFORM_ENVELOPED)
      trans1 = ds.Transform(algorithm=ds.ALG_EXC_C14N)
      transforms = ds.Transforms(transform=[trans0, trans1])
      digest_method = ds.DigestMethod(algorithm=digest_alg)
  
      reference = ds.Reference(
              uri='#{id}'.format(id=ident),
              digest_value=ds.DigestValue(),
              transforms=transforms,
              digest_method=digest_method)
  
      signed_info = ds.SignedInfo(
              signature_method=signature_method,
              canonicalization_method=canonicalization_method,
              reference=reference)
  
      signature = ds.Signature(
              signed_info=signed_info,
              signature_value=ds.SignatureValue())
  
      if identifier:
          signature.id = 'Signature{n}'.format(n=identifier)
  
      if public_key:
          x509_data = ds.X509Data(
              x509_certificate=[ds.X509Certificate(text=public_key)])
          key_info = ds.KeyInfo(x509_data=x509_data)
          signature.key_info = key_info
  
      return signature
docs: If an assertion is to be signed the signature part has to be preset
      with which algorithms to be used, this function returns such a
      preset part.
  
      :param ident: The identifier of the assertion, so you know which assertion
          was signed
      :param public_key: The base64 part of a PEM file
      :param identifier:
      :return: A preset signature part