From 33a576a96983d9f26750598a1a0f82b27b2e95f3 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 24 Sep 2021 20:07:05 +0000 Subject: [PATCH] addr.py: KeyGeneratorPython: clean up code --- mmgen/addr.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/mmgen/addr.py b/mmgen/addr.py index 1e74f303..a6ddc21e 100755 --- a/mmgen/addr.py +++ b/mmgen/addr.py @@ -251,29 +251,16 @@ class KeyGenerator(MMGenObject): ymsg(str(e)) return False -import ecdsa class KeyGeneratorPython(KeyGenerator): desc = 'mmgen-python-ecdsa' - def __init__(self,*args,**kwargs): - # secp256k1: http://www.oid-info.com/get/1.3.132.0.10 - p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f - r = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 - b = 0x0000000000000000000000000000000000000000000000000000000000000007 - a = 0x0000000000000000000000000000000000000000000000000000000000000000 - Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 - curve_fp = ecdsa.ellipticcurve.CurveFp(p,a,b) - G = ecdsa.ellipticcurve.Point(curve_fp,Gx,Gy,r) - oid = (1,3,132,0,10) - self.secp256k1 = ecdsa.curves.Curve('secp256k1',curve_fp,G,oid) - # devdoc/guide_wallets.md: # Uncompressed public keys start with 0x04; compressed public keys begin with 0x03 or # 0x02 depending on whether they're greater or less than the midpoint of the curve. def privnum2pubhex(self,numpriv,compressed=False): - pko = ecdsa.SigningKey.from_secret_exponent(numpriv,self.secp256k1) + import ecdsa + pko = ecdsa.SigningKey.from_secret_exponent(numpriv,curve=ecdsa.SECP256k1) # pubkey = x (32 bytes) + y (32 bytes) (unsigned big-endian) pubkey = pko.get_verifying_key().to_string().hex() if compressed: # discard Y coord, replace with appropriate version byte