Bitcoin Forum
April 24, 2024, 02:10:51 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Electrum Seed Recovery Stand-alone Python Script  (Read 10395 times)
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
May 16, 2014, 10:09:45 PM
 #1

Greetings electrum users and bitcoiners!

I wrote this python script to be sure I could
understand exactly how electrum generates
addresses and keys using the mnemonic seed.

Some members of the bitcoin community have
expressed concerns over the use of brain wallets
because of the possibility that the code could
change over time and therefore, one should only
store private keys.

If for some reason, electrum failed to
restore your wallet, what would you do?

In order to mitigate this potential problem,
at least with electrum, I wanted a stand-alone
script that could generate all the wallet
addresses and their keys from Electrum's
mnemonic seed.

I basically copied all the necessary functions
and made only slight modifications to the way
the data and parameters are passed...bypassing
Electrum's class structure so that a minimum
of code is needed.

Thanks to Debura for pointing out the hex
encode of the seed.  That saved me some time!

Please take note of the following points:

1. If you want to run this, you will need to install

Python 2.7, the same version that Electrum uses.

2. You will also need to install the hashlib and

ecdsa modules into python.  I found this to be
easy using the pip utility.

3. Needless to say, please take the same security
precautions as you would with Electrum
, and
do not type a cold wallet seed on an online computer
or any computer that could have malware, viruses,
or a keylogger.

4. You can modify the file to use your own secret
seed, and modify the

   numberofreceivingaddresses
   numberofchangeaddresses

variables to generate as many addresses as you want.
Right now they are both set to 6.

5. Note that electrum does a pretty good job of
giving you new addresses, so if you have a wallet
that has seen some use, you may need to generate
a larger number of addresses to see the ones currently
in use.

6. This is not meant as any kind of substitute for
Electrum.  It is simply a tool to isolate the raw
code and calculations needed to generate addresses
from the seed.  Think of it as an extra "peace of mind"
insurance.  In case electrum library gets corrupted
or is no longer supported or loses backwards compatibility,
you will have a backup tool to recover your coins from
your seed.

Enjoy...feel free to run on the default seed and check
the output.  comments welcome!

Code:
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
#  - NOTE:  You will need to install the hashlib and ecdsa modules into Python!
#
#
#
import hashlib, ecdsa
from ecdsa.curves import SECP256k1
from ecdsa.ellipticcurve import Point
from ecdsa.util import string_to_number, number_to_string
from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1
#
#
#
#
#
#

##--------------------------------------------------------------------------

numberofreceivingaddresses=6;
numberofchangeaddresses=6;
seed="constant forest adore false green weave stop guy fur freeze giggle clock";

##--------------------------------------------------------------------------
def sha256(x):
    return hashlib.sha256(x).digest()

def Hash(x):
    if type(x) is unicode: x=x.encode('utf-8')
    return sha256(sha256(x))

def pw_decode(s, password):
    if password is not None:
        secret = Hash(password)
        try:
            d = DecodeAES(secret, s).decode("utf8")
        except Exception:
            raise Exception('Invalid password')
        return d
    else:
        return s

def get_address(mpk,  for_change, n):
        pubkey =  get_pubkey(mpk,for_change, n)
        address = public_key_to_bc_address( pubkey.decode('hex') )
print "Address " + str(n) + ": " + address;
print "public key";
print "     "+pubkey;
        return address


def get_pubkey(mpk, for_change, n):
        curve = SECP256k1
        z = get_sequence(mpk,for_change,n);
        master_public_key = ecdsa.VerifyingKey.from_string( mpk, curve = SECP256k1 )
        pubkey_point = master_public_key.pubkey.point + z*curve.generator
        public_key2 = ecdsa.VerifyingKey.from_public_point( pubkey_point, curve = SECP256k1 )
        return '04' + public_key2.to_string().encode('hex')

def get_sequence(mpk, for_change, n):
        return string_to_number( Hash( "%d:%d:"%(n,for_change) + mpk ) )

def get_private_key_from_stretched_exponent(mpk,for_change, n, secexp):
        order = generator_secp256k1.order()
        secexp = ( secexp + get_sequence(mpk,for_change, n) ) % order
        pk = number_to_string( secexp, generator_secp256k1.order() )
        compressed = False
        return SecretToASecret( pk, compressed )
       
def get_private_key(mpk,seed, sequence):
        for_change, n = sequence
        secexp = stretch_key(seed)
        pk = get_private_key_from_stretched_exponent(mpk,for_change, n, secexp)
        return pk;

def stretch_key(seed):
        oldseed = seed
        for i in range(100000):
            seed = hashlib.sha256(seed + oldseed).digest()
        return string_to_number( seed )

def public_key_to_bc_address(public_key):
    h160 = hash_160(public_key)
    return hash_160_to_bc_address(h160)

def SecretToASecret(secret, compressed=False, addrtype=0):
    vchIn = chr((addrtype+128)&255) + secret
    if compressed: vchIn += '\01'
    return EncodeBase58Check(vchIn)

def EncodeBase58Check(vchIn):
    hash = Hash(vchIn)
    return b58encode(vchIn + hash[0:4])

def b58encode(v):
    """ encode v, which is a string of bytes, to base58."""

    long_value = 0L
    for (i, c) in enumerate(v[::-1]):
        long_value += (256**i) * ord(c)
    result = ''
    while long_value >= __b58base:
        div, mod = divmod(long_value, __b58base)
        result = __b58chars[mod] + result
        long_value = div
    result = __b58chars[long_value] + result

    # Bitcoin does a little leading-zero-compression:
    # leading 0-bytes in the input become leading-1s
    nPad = 0
    for c in v:
        if c == '\0': nPad += 1
        else: break

    return (__b58chars[0]*nPad) + result

def hash_160(public_key):
    try:
        md = hashlib.new('ripemd160')
        md.update(sha256(public_key))
        return md.digest()
    except Exception:
        import ripemd
        md = ripemd.new(sha256(public_key))
        return md.digest()
   
def hash_160_to_bc_address(h160, addrtype = 0):
    vh160 = chr(addrtype) + h160
    h = Hash(vh160)
    addr = vh160 + h[0:4]
    return b58encode(addr)

__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)

##-------------------------------------------------------------------------------

words = [ "like", "just", "love", "know", "never", "want", "time", "out", "there", "make", "look", "eye", "down", "only", "think", "heart", "back", "then", "into", "about", "more", "away", "still", "them", "take", "thing", "even", "through", "long", "always", "world", "too", "friend", "tell", "try", "hand", "thought", "over", "here", "other", "need", "smile", "again", "much", "cry", "been", "night", "ever", "little", "said", "end", "some", "those", "around", "mind", "people", "girl", "leave", "dream", "left", "turn", "myself", "give", "nothing", "really", "off", "before", "something", "find", "walk", "wish", "good", "once", "place", "ask", "stop", "keep", "watch", "seem", "everything", "wait", "got", "yet", "made", "remember", "start", "alone", "run", "hope", "maybe", "believe", "body", "hate", "after", "close", "talk", "stand", "own", "each", "hurt", "help", "home", "god", "soul", "new", "many", "two", "inside", "should", "true", "first", "fear", "mean", "better", "play", "another", "gone", "change", "use", "wonder", "someone", "hair", "cold", "open", "best", "any", "behind", "happen", "water", "dark", "laugh", "stay", "forever", "name", "work", "show", "sky", "break", "came", "deep", "door", "put", "black", "together", "upon", "happy", "such", "great", "white", "matter", "fill", "past", "please", "burn", "cause", "enough", "touch", "moment", "soon", "voice", "scream", "anything", "stare", "sound", "red", "everyone", "hide", "kiss", "truth", "death", "beautiful", "mine", "blood", "broken", "very", "pass", "next", "forget", "tree", "wrong", "air", "mother", "understand", "lip", "hit", "wall", "memory", "sleep", "free", "high", "realize", "school", "might", "skin", "sweet", "perfect", "blue", "kill", "breath", "dance", "against", "fly", "between", "grow", "strong", "under", "listen", "bring", "sometimes", "speak", "pull", "person", "become", "family", "begin", "ground", "real", "small", "father", "sure", "feet", "rest", "young", "finally", "land", "across", "today", "different", "guy", "line", "fire", "reason", "reach", "second", "slowly", "write", "eat", "smell", "mouth", "step", "learn", "three", "floor", "promise", "breathe", "darkness", "push", "earth", "guess", "save", "song", "above", "along", "both", "color", "house", "almost", "sorry", "anymore", "brother", "okay", "dear", "game", "fade", "already", "apart", "warm", "beauty", "heard", "notice", "question", "shine", "began", "piece", "whole", "shadow", "secret", "street", "within", "finger", "point", "morning", "whisper", "child", "moon", "green", "story", "glass", "kid", "silence", "since", "soft", "yourself", "empty", "shall", "angel", "answer", "baby", "bright", "dad", "path", "worry", "hour", "drop", "follow", "power", "war", "half", "flow", "heaven", "act", "chance", "fact", "least", "tired", "children", "near", "quite", "afraid", "rise", "sea", "taste", "window", "cover", "nice", "trust", "lot", "sad", "cool", "force", "peace", "return", "blind", "easy", "ready", "roll", "rose", "drive", "held", "music", "beneath", "hang", "mom", "paint", "emotion", "quiet", "clear", "cloud", "few", "pretty", "bird", "outside", "paper", "picture", "front", "rock", "simple", "anyone", "meant", "reality", "road", "sense", "waste", "bit", "leaf", "thank", "happiness", "meet", "men", "smoke", "truly", "decide", "self", "age", "book", "form", "alive", "carry", "escape", "damn", "instead", "able", "ice", "minute", "throw", "catch", "leg", "ring", "course", "goodbye", "lead", "poem", "sick", "corner", "desire", "known", "problem", "remind", "shoulder", "suppose", "toward", "wave", "drink", "jump", "woman", "pretend", "sister", "week", "human", "joy", "crack", "grey", "pray", "surprise", "dry", "knee", "less", "search", "bleed", "caught", "clean", "embrace", "future", "king", "son", "sorrow", "chest", "hug", "remain", "sat", "worth", "blow", "daddy", "final", "parent", "tight", "also", "create", "lonely", "safe", "cross", "dress", "evil", "silent", "bone", "fate", "perhaps", "anger", "class", "scar", "snow", "tiny", "tonight", "continue", "control", "dog", "edge", "mirror", "month", "suddenly", "comfort", "given", "loud", "quickly", "gaze", "plan", "rush", "stone", "town", "battle", "ignore", "spirit", "stood", "stupid", "yours", "brown", "build", "dust", "hey", "kept", "pay", "phone", "twist", "although", "ball", "beyond", "hidden", "nose", "taken", "fail", "float", "pure", "somehow", "wash", "wrap", "angry", "cheek", "creature", "forgotten", "heat", "rip", "single", "space", "special", "weak", "whatever", "yell", "anyway", "blame", "job", "choose", "country", "curse", "drift", "echo", "figure", "grew", "laughter", "neck", "suffer", "worse", "yeah", "disappear", "foot", "forward", "knife", "mess", "somewhere", "stomach", "storm", "beg", "idea", "lift", "offer", "breeze", "field", "five", "often", "simply", "stuck", "win", "allow", "confuse", "enjoy", "except", "flower", "seek", "strength", "calm", "grin", "gun", "heavy", "hill", "large", "ocean", "shoe", "sigh", "straight", "summer", "tongue", "accept", "crazy", "everyday", "exist", "grass", "mistake", "sent", "shut", "surround", "table", "ache", "brain", "destroy", "heal", "nature", "shout", "sign", "stain", "choice", "doubt", "glance", "glow", "mountain", "queen", "stranger", "throat", "tomorrow", "city", "either", "fish", "flame", "rather", "shape", "spin", "spread", "ash", "distance", "finish", "image", "imagine", "important", "nobody", "shatter", "warmth", "became", "feed", "flesh", "funny", "lust", "shirt", "trouble", "yellow", "attention", "bare", "bite", "money", "protect", "amaze", "appear", "born", "choke", "completely", "daughter", "fresh", "friendship", "gentle", "probably", "six", "deserve", "expect", "grab", "middle", "nightmare", "river", "thousand", "weight", "worst", "wound", "barely", "bottle", "cream", "regret", "relationship", "stick", "test", "crush", "endless", "fault", "itself", "rule", "spill", "art", "circle", "join", "kick", "mask", "master", "passion", "quick", "raise", "smooth", "unless", "wander", "actually", "broke", "chair", "deal", "favorite", "gift", "note", "number", "sweat", "box", "chill", "clothes", "lady", "mark", "park", "poor", "sadness", "tie", "animal", "belong", "brush", "consume", "dawn", "forest", "innocent", "pen", "pride", "stream", "thick", "clay", "complete", "count", "draw", "faith", "press", "silver", "struggle", "surface", "taught", "teach", "wet", "bless", "chase", "climb", "enter", "letter", "melt", "metal", "movie", "stretch", "swing", "vision", "wife", "beside", "crash", "forgot", "guide", "haunt", "joke", "knock", "plant", "pour", "prove", "reveal", "steal", "stuff", "trip", "wood", "wrist", "bother", "bottom", "crawl", "crowd", "fix", "forgive", "frown", "grace", "loose", "lucky", "party", "release", "surely", "survive", "teacher", "gently", "grip", "speed", "suicide", "travel", "treat", "vein", "written", "cage", "chain", "conversation", "date", "enemy", "however", "interest", "million", "page", "pink", "proud", "sway", "themselves", "winter", "church", "cruel", "cup", "demon", "experience", "freedom", "pair", "pop", "purpose", "respect", "shoot", "softly", "state", "strange", "bar", "birth", "curl", "dirt", "excuse", "lord", "lovely", "monster", "order", "pack", "pants", "pool", "scene", "seven", "shame", "slide", "ugly", "among", "blade", "blonde", "closet", "creek", "deny", "drug", "eternity", "gain", "grade", "handle", "key", "linger", "pale", "prepare", "swallow", "swim", "tremble", "wheel", "won", "cast", "cigarette", "claim", "college", "direction", "dirty", "gather", "ghost", "hundred", "loss", "lung", "orange", "present", "swear", "swirl", "twice", "wild", "bitter", "blanket", "doctor", "everywhere", "flash", "grown", "knowledge", "numb", "pressure", "radio", "repeat", "ruin", "spend", "unknown", "buy", "clock", "devil", "early", "false", "fantasy", "pound", "precious", "refuse", "sheet", "teeth", "welcome", "add", "ahead", "block", "bury", "caress", "content", "depth", "despite", "distant", "marry", "purple", "threw", "whenever", "bomb", "dull", "easily", "grasp", "hospital", "innocence", "normal", "receive", "reply", "rhyme", "shade", "someday", "sword", "toe", "visit", "asleep", "bought", "center", "consider", "flat", "hero", "history", "ink", "insane", "muscle", "mystery", "pocket", "reflection", "shove", "silently", "smart", "soldier", "spot", "stress", "train", "type", "view", "whether", "bus", "energy", "explain", "holy", "hunger", "inch", "magic", "mix", "noise", "nowhere", "prayer", "presence", "shock", "snap", "spider", "study", "thunder", "trail", "admit", "agree", "bag", "bang", "bound", "butterfly", "cute", "exactly", "explode", "familiar", "fold", "further", "pierce", "reflect", "scent", "selfish", "sharp", "sink", "spring", "stumble", "universe", "weep", "women", "wonderful", "action", "ancient", "attempt", "avoid", "birthday", "branch", "chocolate", "core", "depress", "drunk", "especially", "focus", "fruit", "honest", "match", "palm", "perfectly", "pillow", "pity", "poison", "roar", "shift", "slightly", "thump", "truck", "tune", "twenty", "unable", "wipe", "wrote", "coat", "constant", "dinner", "drove", "egg", "eternal", "flight", "flood", "frame", "freak", "gasp", "glad", "hollow", "motion", "peer", "plastic", "root", "screen", "season", "sting", "strike", "team", "unlike", "victim", "volume", "warn", "weird", "attack", "await", "awake", "built", "charm", "crave", "despair", "fought", "grant", "grief", "horse", "limit", "message", "ripple", "sanity", "scatter", "serve", "split", "string", "trick", "annoy", "blur", "boat", "brave", "clearly", "cling", "connect", "fist", "forth", "imagination", "iron", "jock", "judge", "lesson", "milk", "misery", "nail", "naked", "ourselves", "poet", "possible", "princess", "sail", "size", "snake", "society", "stroke", "torture", "toss", "trace", "wise", "bloom", "bullet", "cell", "check", "cost", "darling", "during", "footstep", "fragile", "hallway", "hardly", "horizon", "invisible", "journey", "midnight", "mud", "nod", "pause", "relax", "shiver", "sudden", "value", "youth", "abuse", "admire", "blink", "breast", "bruise", "constantly", "couple", "creep", "curve", "difference", "dumb", "emptiness", "gotta", "honor", "plain", "planet", "recall", "rub", "ship", "slam", "soar", "somebody", "tightly", "weather", "adore", "approach", "bond", "bread", "burst", "candle", "coffee", "cousin", "crime", "desert", "flutter", "frozen", "grand", "heel", "hello", "language", "level", "movement", "pleasure", "powerful", "random", "rhythm", "settle", "silly", "slap", "sort", "spoken", "steel", "threaten", "tumble", "upset", "aside", "awkward", "bee", "blank", "board", "button", "card", "carefully", "complain", "crap", "deeply", "discover", "drag", "dread", "effort", "entire", "fairy", "giant", "gotten", "greet", "illusion", "jeans", "leap", "liquid", "march", "mend", "nervous", "nine", "replace", "rope", "spine", "stole", "terror", "accident", "apple", "balance", "boom", "childhood", "collect", "demand", "depression", "eventually", "faint", "glare", "goal", "group", "honey", "kitchen", "laid", "limb", "machine", "mere", "mold", "murder", "nerve", "painful", "poetry", "prince", "rabbit", "shelter", "shore", "shower", "soothe", "stair", "steady", "sunlight", "tangle", "tease", "treasure", "uncle", "begun", "bliss", "canvas", "cheer", "claw", "clutch", "commit", "crimson", "crystal", "delight", "doll", "existence", "express", "fog", "football", "gay", "goose", "guard", "hatred", "illuminate", "mass", "math", "mourn", "rich", "rough", "skip", "stir", "student", "style", "support", "thorn", "tough", "yard", "yearn", "yesterday", "advice", "appreciate", "autumn", "bank", "beam", "bowl", "capture", "carve", "collapse", "confusion", "creation", "dove", "feather", "girlfriend", "glory", "government", "harsh", "hop", "inner", "loser", "moonlight", "neighbor", "neither", "peach", "pig", "praise", "screw", "shield", "shimmer", "sneak", "stab", "subject", "throughout", "thrown", "tower", "twirl", "wow", "army", "arrive", "bathroom", "bump", "cease", "cookie", "couch", "courage", "dim", "guilt", "howl", "hum", "husband", "insult", "led", "lunch", "mock", "mostly", "natural", "nearly", "needle", "nerd", "peaceful", "perfection", "pile", "price", "remove", "roam", "sanctuary", "serious", "shiny", "shook", "sob", "stolen", "tap", "vain", "void", "warrior", "wrinkle", "affection", "apologize", "blossom", "bounce", "bridge", "cheap", "crumble", "decision", "descend", "desperately", "dig", "dot", "flip", "frighten", "heartbeat", "huge", "lazy", "lick", "odd", "opinion", "process", "puzzle", "quietly", "retreat", "score", "sentence", "separate", "situation", "skill", "soak", "square", "stray", "taint", "task", "tide", "underneath", "veil", "whistle", "anywhere", "bedroom", "bid", "bloody", "burden", "careful", "compare", "concern", "curtain", "decay", "defeat", "describe", "double", "dreamer", "driver", "dwell", "evening", "flare", "flicker", "grandma", "guitar", "harm", "horrible", "hungry", "indeed", "lace", "melody", "monkey", "nation", "object", "obviously", "rainbow", "salt", "scratch", "shown", "shy", "stage", "stun", "third", "tickle", "useless", "weakness", "worship", "worthless", "afternoon", "beard", "boyfriend", "bubble", "busy", "certain", "chin", "concrete", "desk", "diamond", "doom", "drawn", "due", "felicity", "freeze", "frost", "garden", "glide", "harmony", "hopefully", "hunt", "jealous", "lightning", "mama", "mercy", "peel", "physical", "position", "pulse", "punch", "quit", "rant", "respond", "salty", "sane", "satisfy", "savior", "sheep", "slept", "social", "sport", "tuck", "utter", "valley", "wolf", "aim", "alas", "alter", "arrow", "awaken", "beaten", "belief", "brand", "ceiling", "cheese", "clue", "confidence", "connection", "daily", "disguise", "eager", "erase", "essence", "everytime", "expression", "fan", "flag", "flirt", "foul", "fur", "giggle", "glorious", "ignorance", "law", "lifeless", "measure", "mighty", "muse", "north", "opposite", "paradise", "patience", "patient", "pencil", "petal", "plate", "ponder", "possibly", "practice", "slice", "spell", "stock", "strife", "strip", "suffocate", "suit", "tender", "tool", "trade", "velvet", "verse", "waist", "witch", "aunt", "bench", "bold", "cap", "certainly", "click", "companion", "creator", "dart", "delicate", "determine", "dish", "dragon", "drama", "drum", "dude", "everybody", "feast", "forehead", "former", "fright", "fully", "gas", "hook", "hurl", "invite", "juice", "manage", "moral", "possess", "raw", "rebel", "royal", "scale", "scary", "several", "slight", "stubborn", "swell", "talent", "tea", "terrible", "thread", "torment", "trickle", "usually", "vast", "violence", "weave", "acid", "agony", "ashamed", "awe", "belly", "blend", "blush", "character", "cheat", "common", "company", "coward", "creak", "danger", "deadly", "defense", "define", "depend", "desperate", "destination", "dew", "duck", "dusty", "embarrass", "engine", "example", "explore", "foe", "freely", "frustrate", "generation", "glove", "guilty", "health", "hurry", "idiot", "impossible", "inhale", "jaw", "kingdom", "mention", "mist", "moan", "mumble", "mutter", "observe", "ode", "pathetic", "pattern", "pie", "prefer", "puff", "rape", "rare", "revenge", "rude", "scrape", "spiral", "squeeze", "strain", "sunset", "suspend", "sympathy", "thigh", "throne", "total", "unseen", "weapon", "weary" ]

def mn_decode( wlist ):
    n=1626;
    out = ''
    for i in range(len(wlist)/3):
        word1, word2, word3 = wlist[3*i:3*i+3]
        w1 =  words.index(word1)
        w2 = (words.index(word2))%n
        w3 = (words.index(word3))%n
        x = w1 +n*((w2-w1)%n) +n*n*((w3-w2)%n)
        out += '%08x'%x
    return out

##--------------------------------------------------------------------------------

print "......ready to compute.....";
print " ";
seedlist=str.split(seed);

password = None;
seed=mn_decode(seedlist);

oldseed=seed;
newseed=stretch_key(seed);
curve = SECP256k1
master_private_key = ecdsa.SigningKey.from_secret_exponent( newseed, curve = SECP256k1 );
master_public_key = master_private_key.get_verifying_key().to_string().encode('hex');
mpk=master_public_key.decode('hex');

print "MASTER PUBLIC KEY IS "
print "  ";
print master_public_key;
 

print "  ";
print "  ";

print "++++++++++++++++++++++++++++++++++";

print "RECEIVING ADDRESSES ";
print "  ";
print "  ";

for ra in range(0,numberofreceivingaddresses):
addy=get_address(mpk,0,ra);
pk=get_private_key(mpk,oldseed,(0,ra));
print "private key";
print "     "+pk;
print "  ";


print "++++++++++++++++++++++++++++++++++";

print "CHANGE ADDRESSES";

print "  ";
print "  ";

for ca in range(0,numberofchangeaddresses):
addy=get_address(mpk,1,ca);
pk=get_private_key(mpk,oldseed,(1,ca));
print "private key";
print "     "+pk;
print "  ";


print " ";
print " ";
print "++++++++++++++++++++++++++";
print " ";
print " ";
print "END OF PROGRAM.  - Jonald Fyookball 2014...";

Transactions must be included in a block to be properly completed. When you send a transaction, it is broadcast to miners. Miners can then optionally include it in their next blocks. Miners will be more inclined to include your transaction if it has a higher transaction fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713924651
Hero Member
*
Offline Offline

Posts: 1713924651

View Profile Personal Message (Offline)

Ignore
1713924651
Reply with quote  #2

1713924651
Report to moderator
1713924651
Hero Member
*
Offline Offline

Posts: 1713924651

View Profile Personal Message (Offline)

Ignore
1713924651
Reply with quote  #2

1713924651
Report to moderator
jbrnt
Hero Member
*****
Offline Offline

Activity: 672
Merit: 500



View Profile
May 16, 2014, 10:16:02 PM
Last edit: May 16, 2014, 11:13:09 PM by jbrnt
 #2

I have seen you posting questions on the electrum source lately and I had no idea you are working on such a wonderful tool. Thanks jonald.

I have no experience with this, but I will google what "ecdsa" and "pip utility" means and give this a try.
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
May 16, 2014, 10:44:20 PM
 #3

Thanks!  Glad to give back in a small way.

Really makes me appreciate what Thomas has created
for us... not to mention Satoshi and all the devs.

dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
May 17, 2014, 03:13:02 AM
 #4

pw_decode method and "password = None" aren't needed. However, you could use raw input to allow the user to input their own seed (string of words) or the encrypted seed from their wallet file. (Heck you could even have them type in the filepath of their wallet file and then pw_decode the seed from that (note: encrypted seed from wallet >> pw_decode is equal to the output of mn_decode, so you won't need to run it through)

Right now, this is only really useful for people who know python enough to run this source. I would maybe stick a little gui on it (maybe use QT4) and have the option for the user to retrieve all their private keys or just give them the master public key only, etc.

It's pretty nice to have all the methods in a neat package and might be a great tool to stick a gui on and compile into an exe for newbies, but I think anyone who knows python enough to run this would have been able to retrieve their private keys anyways.

Just remember, the licensing agreement would require you to make all files open source including posting the compile method for the exe if you make one.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
May 17, 2014, 03:28:14 AM
 #5

Thanks man.  We'll see.

It really doesn't do anything electrum doesn't already do.

It's just a good tool to provide transparency into the inner workings of electrum and show exactly what it is doing with the seed, without digging through the entire electrum source code.  It hopefully quells the concerns of people who say not to use a brain wallet because the calculations could change in the future.


JonCD
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
June 18, 2014, 01:39:31 PM
 #6

This is really cool man. I was having a discussion with you a few bitcoiners the other day about the most secure way to store your bitcoin.

When I talked about electrum, they kept saying that if the servers went down you would never have any way to get your bitcoin from your seed.

Now I have a rebuttal. Nice work dude!
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
June 18, 2014, 03:47:16 PM
 #7

This is really cool man. I was having a discussion with you a few bitcoiners the other day about the most secure way to store your bitcoin.

When I talked about electrum, they kept saying that if the servers went down you would never have any way to get your bitcoin from your seed.

Now I have a rebuttal. Nice work dude!

Thanks!

Actually, electrum isn't dependent on the servers for that.

The server are used to broadcast transactions and check your
balances.  You can still generate addresses and keys using electrum
while you are offline without any of the servers.

I wrote this script as sort of a due dilligence to fully understand
what it does and in the (hopefully unlikely) scenario where
electrum developers disregard backward compatibility.  

For me, it is peace of mind knowing I have one simple script I
can use to recover my coins from seed regardless of what happens
to the Electrum code.

 

JonCD
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
June 18, 2014, 10:42:25 PM
 #8

This is really cool man. I was having a discussion with you a few bitcoiners the other day about the most secure way to store your bitcoin.

When I talked about electrum, they kept saying that if the servers went down you would never have any way to get your bitcoin from your seed.

Now I have a rebuttal. Nice work dude!

Thanks!

Actually, electrum isn't dependent on the servers for that.

The server are used to broadcast transactions and check your
balances.  You can still generate addresses and keys using electrum
while you are offline without any of the servers.

I wrote this script as sort of a due dilligence to fully understand
what it does and in the (hopefully unlikely) scenario where
electrum developers disregard backward compatibility.  

For me, it is peace of mind knowing I have one simple script I
can use to recover my coins from seed regardless of what happens
to the Electrum code.

 

I'm really glad you cleared this up. At an Ethereum meetup the other day a couple guys explained it to me differently, saying that the seed is tied to your private keys which are encrypted on the electrum servers.

I was actually disappointed to hear that, so this is awesome news. So the servers only broadcast transactions and check balances, while the seed and corresponding private keys are held locally. So even if there were no servers available, and the new electrum client did not support old seeds, you can still gain access to your bitcoin by using this script to derive the private keys. (Correct me if I have anything wrong)
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
June 19, 2014, 01:42:44 AM
 #9

you are correct.

plus you can always run your own server Smiley

dabura667
Sr. Member
****
Offline Offline

Activity: 475
Merit: 252


View Profile
June 19, 2014, 02:50:19 AM
 #10

I'm really glad you cleared this up. At an Ethereum meetup the other day a couple guys explained it to me differently, saying that the seed is tied to your private keys which are encrypted on the electrum servers.

I was actually disappointed to hear that, so this is awesome news. So the servers only broadcast transactions and check balances, while the seed and corresponding private keys are held locally. So even if there were no servers available, and the new electrum client did not support old seeds, you can still gain access to your bitcoin by using this script to derive the private keys. (Correct me if I have anything wrong)
I think they were getting confused with Blockchain.info.

Electrum can be generated completely offline and still function perfectly.

My Tip Address:
1DXcHTJS2DJ3xDoxw22wCt11FeAsgfzdBU
kopipe
Full Member
***
Offline Offline

Activity: 246
Merit: 124



View Profile
June 28, 2015, 08:01:51 AM
 #11

Sorry to bump a very old thread, but I've been looking at this code recently.

It seems like at some point Electrum changed from BIP39 addresses to a new kind of deterministic wallet address generation.

Therefore newer seeds are not supported by this...

e.g. here is a new example seed made with
Code:
electrum make_seed
: provide stamp need token vibrant describe ten syrup rookie easy rack impose acid

Of course it says:
Code:
Traceback (most recent call last):
  File "fyook.py", line 169, in <module>
    seed=mn_decode(seedlist);
  File "fyook.py", line 155, in mn_decode
    w1 =  words.index(word1)
ValueError: 'provide' is not in list

I wonder if anyone has a new version, or if I need to write it myself?

コピペ copypaste
jonald_fyookball (OP)
Legendary
*
Offline Offline

Activity: 1302
Merit: 1004


Core dev leaves me neg feedback #abuse #political


View Profile
June 28, 2015, 12:15:31 PM
 #12

I never upgraded it for new versions of electrum. 
an upgrade would be awesome if you want to code it up.

believe it or not, I've referred people to this several times
who were wondering about the transparency of electrum
and how they can manually calculate their keys. there
was even one link from stackoverflow or somewhere.

so it's far from useless!

Prospero
Full Member
***
Offline Offline

Activity: 194
Merit: 100


View Profile
August 09, 2015, 05:23:54 PM
 #13

Maybe if you stick it up on github, somebody might update it to support 2.0.

1Ja2AxA8hfFMrPwSTV9nP6kq7bp3f7x734
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!