Exemple #1
0
 def sign_rfc6979(self, msg, pv_key, hasher=None, canonical=False):
     """ Signs a message hash according to RFC6979 
     Args:
         msg (bytes)                    : the message hash to sign
         pv_key (ecpy.keys.ECPrivateKey): key to use for signing
     """
     hasher = self._hasher if hasher == None else hasher
     field = pv_key.curve.field
     V = None
     for i in range(1, self.maxtries):
         k, V = ecrand.rnd_rfc6979(msg, pv_key.d, field, self._hasher, V)
         sig = self._do_sign(msg, pv_key, k)
         if sig:
             return sig
         return None
Exemple #2
0
    def sign_rfc6979(self, msg, pv_key, hasher, canonical=False):
        """ Signs a message hash according to RFC6979 

        Args:
            msg (bytes)                    : the message hash to sign
            pv_key (ecpy.keys.ECPrivateKey): key to use for signing
            hasher (hashlib)               : hasher conform to hashlib interface
        """
        field = pv_key.curve.field
        V = None
        for i in range(1, self.maxtries):
            k, V = ecrand.rnd_rfc6979(msg, pv_key.d, field, hasher, V)
            sig = self._do_sign(msg, pv_key, k, canonical)
            if sig:
                return sig
        return None