code: def sign_with_recid(self, secret_exponent, val, gen_k=None):
          
          if gen_k is None:
              gen_k = deterministic_generate_k
          n = self._order
          k = gen_k(n, secret_exponent, val)
          while True:
              p1 = k * self
              r = p1[0]
              s = (self.inverse(k) * (val + (secret_exponent * r) % n)) % n
              if r != 0 and s != 0:
                  recid = p1[1] & 1
                  if p1[1] > self._p:
                      recid += 2
                  return r, s, recid
              k += 1
docs: :param: secret_exponent: a :class:`Point <pycoin.ecdsa.Point.Point>` on the curve
          :param: val: an integer value
          :param: gen_k: a function generating __k values__
  
          :returns: a tuple of integers ``(r, s, recid)`` where ``(r, s)`` represents an ecdsa
              signature of ``val`` with public key ``self * secret_exponent``; and ``recid``
              is the **recovery id**, a number from 0-3 used to eliminate ambiguity about
              which public key signed the value.
  
          If gen_k is set, it will be called with (n, secret_exponent, val), and an unguessable
          K value should be returned. Otherwise, the default K value, generated according
          to rfc6979 will be used.