Seed Generator for Bitcoin Cash / Electron CashsteemCreated with Sketch.

in #bitcoin7 years ago (edited)

Bitcoin_Cash.png


The Electrum and it’s cousin the Electron Cash software is so simplistic that you only need 1 file and a few imported functions for it to generate a seed. I realize that the latest Electron-Cash RPC bug and others could make the software complex and risky.

So I thought what if I strip the code down just to the bare basics, and make a SEED GENERATOR from the minimum code needed to generate an Electron-Cash wallet for Cold Storage.

Because who knows what kind of bugs and stuff can be included in later version of the software, and people who want to hold large amounts, only need a seed generator to create a seed for offline use.

And that should be minimalistic, so I just made a seed generator from the basic code.

Now the software is experimental, so it’s not recommended to use it on real money, but it’s minimalistic enough to be made safe eventually.

It’s just 1 file, which runs in python3, python 3.5 and above to be precise.


Use

So all you need to do is just run the code in the console with the command python3 seed_generator.py

Then enter the language of the seed, you can choose from 5 languages.

And then enter the entropy of the seed, it’s recommended to use 132 bits or above.

And then it gives you the seed, which is confidential of course:

sd.png


Installation

fold.png

Now you can just run it with python3 seed_generator.py command from the Seed Generator folder.

But keep in mind the software is still experimental, so not recommended for real money!


Development Log

What I did was simple. The entire seed generation procedure is run by the mnemonic.py file. So I cleaned up that file and only left the essentials there. I could have cleaned up the Unicode part too,but I figured I keep it multilingual, although I don’t know who would use Chinese Seed for that matter. If it’s only English, then the code would be even simpler, since we would not have to normalize it for ASCII.

There are other imports from bitcoin.py but that I just copied there into the Mnemonic class.

The version.py is useless, especially if we don’t use multisig or segwit wallets, only 1 variable is needed from there and it can be made even simpler by just replacing the SEED_PREFIX everywhere with just 01.

There is 1 new stuff since the old Electrum versions, I think they have ported it completely to python 3.5 now, whereas in the old python in the HMAC part they read in the string, now they read in the bytes, so that was changed to:

bh2u(hmac_sha_512(b"Seed version", x.encode('utf8')))

Whereas in the past it was called:

hmac_sha_512("Seed version", x.encode('utf8')).encode('hex')

(Yes I remember this, because I have looked into the Electrum code in the past to make sure it’s seed generation is secure.)

The bh2u function is from the utils.py file ,it’s basically just calling the binascii package to transform the byte stream into hex I think. I just added that there too in the same file, no need for separate files.

And I have also removed the old_seed generator, which was based on a different wordlist, so we are just working with the new seed versions (2016+) I think.

I haven’t touched anything else, and haven’t modified the other functions, they should be identical.

Finally, in the end we have 2 keyboard inputs, one for the language code and one for the number of bits, so we call the Mnemonic class with those 2 user inputted parameters.

So that’s about it, it should be as simple as possible, I was careful, though I could have made mistakes, so you should inspect the code yourself.



Disclaimer: This software is licensed under MIT license. It’s experimental, use it at your own risk, I shall not be responsible for any losses that may occur by using the software. The software is not endorsed by neither the Electrum nor the Electron-Cash team.


Sources:
https://pixabay.com
https://www.pexels.com


Upvote, ReSteem & bluebutton


Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.028
BTC 63597.74
ETH 2476.06
USDT 1.00
SBD 2.53