Created
November 27, 2012 04:42
-
-
Save weex/4152422 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-def base58_check_encode(s, version=0): | |
+def base58_check_encode(s, version=48): | |
vs = chr(version) + s | |
check = dhash(vs)[:4] | |
return base58_encode_padded(vs + check) | |
-def base58_check_decode(s, version=0): | |
+def base58_check_decode(s, version=48): | |
k = base58_decode_padded(s) | |
v0, data, check0 = k[0], k[1:-4], k[-4:] | |
check1 = dhash(v0 + data)[:4] | |
@@ -134,7 +134,7 @@ def gen_eckey(passphrase=None, secret=None, pkey=None, compressed=False, rounds= | |
for i in xrange(rounds): | |
secret = hashlib.sha256(secret).digest() | |
if pkey: | |
- secret = base58_check_decode(pkey, 128) | |
+ secret = base58_check_decode(pkey, 176) | |
compressed = len(secret) == 33 | |
secret = secret[0:32] | |
k.generate(secret) | |
@@ -149,12 +149,13 @@ def get_addr(k): | |
payload = secret | |
if k.compressed: | |
payload = secret + chr(0) | |
- pkey = base58_check_encode(payload, 128) | |
+ pkey = base58_check_encode(payload, 176) | |
return addr, pkey | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment