Python ecdsa.SigningKey.from_secret_exponent() Examples
The following are 6
code examples of ecdsa.SigningKey.from_secret_exponent().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ecdsa.SigningKey
, or try the search function
.
Example #1
Source File: __init__.py From ecdsa-private-key-recovery with GNU General Public License v2.0 | 6 votes |
def recover_nonce_reuse(self, other): sig2 = other.sig # rename it h2 = other.h # rename it # precalculate static values z = self.h - h2 r_inv = inverse_mod(self.sig.r, self.n) # # try all candidates # for candidate in (self.sig.s - sig2.s, self.sig.s + sig2.s, -self.sig.s - sig2.s, -self.sig.s + sig2.s): k = (z * inverse_mod(candidate, self.n)) % self.n d = (((self.sig.s * k - self.h) % self.n) * r_inv) % self.n signingkey = SigningKey.from_secret_exponent(d, curve=self.curve) if signingkey.get_verifying_key().pubkey.verifies(self.h, self.sig): self.signingkey = signingkey self.k = k self.x = d return self assert False # could not recover private key
Example #2
Source File: keys.py From python-bitcoin-utils with MIT License | 6 votes |
def __init__(self, wif=None, secret_exponent=None): """With no parameters a random key is created Parameters ---------- wif : str, optional the key in WIF of WIFC format (default None) secret_exponent : int, optional used to create a specific key deterministically (default None) """ if not secret_exponent and not wif: self.key = SigningKey.generate(curve=SECP256k1) else: if wif: self._from_wif(wif) elif secret_exponent: self.key = SigningKey.from_secret_exponent(secret_exponent, curve=SECP256k1)
Example #3
Source File: keys.py From multimerchant-python with MIT License | 5 votes |
def __init__(self, secret_exponent, network=BitcoinMainNet, *args, **kwargs): if not isinstance(secret_exponent, six.integer_types): raise ValueError("secret_exponent must be a long") super(PrivateKey, self).__init__(network=network, *args, **kwargs) self._private_key = SigningKey.from_secret_exponent( secret_exponent, curve=SECP256k1)
Example #4
Source File: keys.py From bitmerchant with MIT License | 5 votes |
def __init__(self, secret_exponent, network=BitcoinMainNet, *args, **kwargs): if not isinstance(secret_exponent, six.integer_types): raise ValueError("secret_exponent must be a long") super(PrivateKey, self).__init__(network=network, *args, **kwargs) self._private_key = SigningKey.from_secret_exponent( secret_exponent, curve=SECP256k1)
Example #5
Source File: keys.py From pywallet with MIT License | 5 votes |
def __init__(self, secret_exponent, network=BitcoinMainNet, *args, **kwargs): if not isinstance(secret_exponent, six.integer_types): raise ValueError("secret_exponent must be a long") super(PrivateKey, self).__init__(network=network, *args, **kwargs) self._private_key = SigningKey.from_secret_exponent( secret_exponent, curve=SECP256k1)
Example #6
Source File: wallet.py From halocoin with Apache License 2.0 | 5 votes |
def __init__(self, name, privkey=None): """ A wallet object is initialized by a private key. """ self.name = name if privkey is None: secexp = randrange_from_seed__trytryagain(os.urandom(SECP256k1.baselen), SECP256k1.order) self.privkey = SigningKey.from_secret_exponent(secexp, curve=SECP256k1) else: self.privkey = privkey self.pubkey = self.privkey.get_verifying_key() self.address = tools.make_address([self.pubkey], 1)