cantonbecker / bitcoinpaperwallet

JavaScript Client-Side Bitcoin Wallet Generator
https://www.bitaddress.org
452 stars 165 forks source link

Change for issue #3 - Added Bip38 encryption #6

Closed artiomchi closed 10 years ago

artiomchi commented 10 years ago

As discussed in issue #3 - we love this wallet generator, but it lacks BIP0038 support.. I'd love to create a paper wallet, and then print a copy of it and give it to my friend/brother for safe storage, while not worrying that someone might take the money off the wallet.

I've taken the encryption code taken directly from the live bitaddress.org version

artiomchi commented 10 years ago

Here's a small self-contained page that demonstrates the issue: http://jsutftest.azurewebsites.net/testCrypto.html ( page blocking, wait for it to process first )

artiomchi commented 10 years ago

Ok, got some further progress on it. I've narrowed it down to the scrypt library, and managed to replicate it with minimal code.

Since no other library is required to replicate the test, I've opened an issue in the scrypt-js project, where we can follow-up, and hopefully find a fix.

cheongwy/node-scrypt-js#2

artiomchi commented 10 years ago

I can't be 100% certain, so this needs testing, but this may be the fix to the crypto_scrypt issue for Safari 6, without compromising performance or stability on other browsers.

Please test it out, and reply here with whether it works or now.

It would be also good to see if all the async tests start passing, so test this url as well: http://jsutftest.azurewebsites.net/generate-wallet.html?asyncunittests=1

I've written a bit more about it in the node_scrypt issue tracker above...

Fingers crossed!

cantonbecker commented 10 years ago

I loaded up pull revision 53aa090 on my local safari 6.05 and confirmed:

1) My original test case now works fine (tried about 6 passes, 100% success encrypting and validating/decrypting.)

2) asyncunittests runs fine, PRESUMING that the "fail testDecryptBip38 #0, error" has to do with the work-around as I remember you implementing it.

running 8 tests named testDecryptBip38 running 4 tests named testBip38Encrypt running 2 tests named cycleBip38 running 5 tests named testBip38Intermediate fail testDecryptBip38 #0, error: Incorrect passphrase for this encrypted private key. pass testDecryptBip38 #1 pass testDecryptBip38 #2 pass testDecryptBip38 #3 pass testDecryptBip38 #4 pass testDecryptBip38 #5 pass testDecryptBip38 #6 pass testDecryptBip38 #7 pass testBip38Encrypt #0 pass testBip38Encrypt #1 pass testBip38Encrypt #2 pass testBip38Encrypt #3 pass cycleBip38 test #0 pass cycleBip38 test #1 pass testBip38Intermediate #0 pass testBip38Intermediate #1 pass testBip38Intermediate #2 pass testBip38Intermediate #3 pass testBip38Intermediate #4 running of asynchronous unit tests complete!

cantonbecker commented 10 years ago

I've sent you a private email artiomchi, but I think with this safari fix (!! HUZZAH !!) all that remains to be done before I do my final rounds of tests and minor CSS tweaks are:

1) bring in the latest greatest bitaddress.org entropy gathering & visualization edits 2) add a "View / Print this as a paper wallet" button to the view details page (which will load the validated address up as a wallet front.) Superb feature for anyone wanting to convert a non-BIP38 wallet to a BIP38 wallet.

artiomchi commented 10 years ago

Hey Canton!

Here's a rather bulky update! Merged the changes from bitaddress again (got some visual improvements, and better entropy)

The upstream merge commits have also brought in the green seedpoint dots (on purpose, check out d5b2012 to see them) and I've removed them in 07ea52c (which makes it easier to bring them back if you want to)

The last commit adds the visual mockup for the entropy generator.. You would have to improve the visuals there though, I'm not that good with css :)

How does that look?

cantonbecker commented 10 years ago

Superb! Thanks Artiom. So far, the upstream entropy migrations seem to work great. Right now the hexadecimal display overprints the rest of the page and I assume that's what you'd like me to tackle. I think I'd like to use the "green dots" version (d5b2012) for the final candidate. I might style them a little differently, but let's leave them in for now.

Possible bug: I just noticed something now, sorry I didn't catch this earlier:

Typing an invalid key into the validate field and pressing "View Details" does nothing, and throws "11831: TypeError: 'undefined' is not an object (evaluating 'ninja.wallets.brainwallet.minPassphraseLength')"

I figure it should alert something like, "Sorry but that is not a valid private key. Supported formats include WIF and BIP38."

artiomchi commented 10 years ago

Hi Canton,

You're absolutely right.. I've gone with the same code/behaviour that is on bitaddress.org - if the key is not valid it will either show an error message, or if the message is long enough - show that message, suggesting to create a brain wallet out of it.

I've also reverted the previous commit, restoring the green dots.

By the way, e9afe25 should have taken care of the seed display overlaying the page.. It looks rather rough, and not quite as in the template (needs some positioning and font size playing around with) so you can adjust it to make it look as you see fit

cantonbecker commented 10 years ago

For anyone interested, Artiomchi's work is going live in the next few days unless any serious bugs are reported. Artiomchi, GREAT WORK, thanks.

Here's a preview URL of artiomchi's pull request merged with a bunch of interface changes/enhancements:

https://bitcoinpaperwallet.com/bitcoinpaperwallet/generate-wallet-bip38.html

cantonbecker commented 10 years ago

Closed with release of Feb. 10, 2014.