Last active
June 2, 2020 11:36
-
-
Save guillaumevincent/60b0363820c7df1f9f71f6682824017c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
words = "gruyère apporter rituel mallette anguleux intime irréel ralentir posture orque grand fatal donner négation carotte replier nocif opprimer tenir accolade éprouver sonde tambour cylindre" | |
import binascii | |
from mnemonic import mnemonic | |
from bip32 import BIP32 | |
import base58 | |
import hashlib | |
mnemo = mnemonic.Mnemonic("french") | |
print("mnemo.check(words):", "ok" if mnemo.check(words) else "ko") | |
seed = mnemo.to_seed(words, "passphrase") | |
bip32 = BIP32.from_seed(seed) | |
pub_key = bip32.get_pubkey_from_path("m/44'/0'/0'/0/0") | |
hex_str = binascii.hexlify(pub_key) | |
print(b"031a8967c18a0b21dde8d38dbc3612163a0ad56c18dee08ba302b682587f7d3465" == hex_str) | |
def pubkey_to_address(pubkey: bytes) -> str: | |
sha = hashlib.sha256(pubkey).digest() | |
ripe = hashlib.new("ripemd160", sha).digest() | |
return base58.b58encode_check(b"\x00" + ripe) | |
bitcoin_address = pubkey_to_address(hex_str) | |
print(bitcoin_address) | |
print(bitcoin_address == "1smHE1UJeYMisGU6U6KCiZYNffQWFWHWY") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment