1

I'm working on an SPV wallet using bitpay's bitcore lib package.

Am I able to save to local storage the privateKey object generated with 'new bitcore.PrivateKey()'

Or should I be converting it to WIF before setting it to local storage? Are there any drawbacks or advantages of doing it one way over the other?

1 Answer 1

2

Am I able to save to local storage the privateKey object generated with 'new bitcore.PrivateKey()'

"Able" vs "should". Yes you are able to save whatever you want to localStorage including the private key in string format or if an object use JSON.stringify(). It is never wise to store private keys on an internet connected machine. The localStorage data can only been read by the domain that saved the data, so it does have some security, but that's not much. It's essentially just cookie data saved on the users machine, unencrypted. So this approach might be useful when developing wallet concepts or personal projects, but definitely not kosher for production level.

3
  • How do spv wallets such as Coinbase, BitPay or Bitcoin_com persist the wallet info? I can't imagine they send the private keys over the wire to a db. Besides saving it to localStorage (asyncStorage on mobile), what over options are there?
    – Hyetigran
    Aug 10, 2021 at 4:29
  • Those are all custodial wallets where the provider keeps the keys on their server(s), they are not storing them in the users browser localStorage. I have built some wallet projects myself that store keys in localStorage, works great, haven't had an issue, but these are just fun personal projects.
    – m1xolyd1an
    Aug 10, 2021 at 14:50
  • That's insane if true. A quick google search says that coinbase wallet is non-custodial and does not keep nor can restore your seed if lost. I've quickly looked at edge wallet repo on github and from initial glance it doesn't look like they store seed upon wallet creation. Which wallets are non-custodial then and how do devs go about keeping seeds off servers but also safe?
    – Hyetigran
    Aug 10, 2021 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.