A powerful security technique to prevent theft of Bitcoins from a user's online wallet is to encrypt the user's private key with his password without ever stroring the PK directly in the database. Even if a hacker compromises the server they still won't be able to access the user's wallet without his password.

In case a website needs to have custodial control over a user's funds (for example, an exchange or escrow service in a marketplace) this solution isn't viable as the exchange needs to have complete control over the user's funds to move funds from one party to another (say from the buyer to the merchant or to a trader in an exchange). So it cannot be expected that the exchange must ask one party "permission" to transfer funds to the other party. Of course, the exchange or marketplace can encrypt the PK but since it would also need to host the decryption key somewhere on the server there's little benefit in encrypting the PK in the first place.

Is there a variation of this technique that might work even in a marketplace or exchange environment which requires that the owner (of the marketplace or exchange) maintain full control over a user's deposit?


1 Answer 1


It depends what your goal is. Normally when sites have a user's key encrypted as to be unreadable to the site, it's to have a system where users don't have to trust the site not to steal the key. In that case, then no, because the whole point of a technique like that is to have it so the service provider doesn't have control of the user's keys at all. Any workaround to that would defeat the purpose.

If your goal is to protect the keys from outside hackers, then the site can (and most do) employ cold storage or hardware security modules (basically a fancy hardware wallet) that store the keys. In this case, the site owners still have full control of the keys, and the users have to trust the site owners to be honest. However, the scope of a potential hack is limited, as the keys are stored either on dedicated hardware, or if in cold storage, large withdrawals are performed manually by site staff after review.

  • @_ieatpizza My goal is to protect the keys from outside hackers. I'm aware of the option of using "hardware security" to protect the PK but I fail to understand why a malicious user can't seize control of the server and send (unlimited) withdrawal requests to the hardware module (while pretending to be legitimate requests) and siphon all funds from the wallet without every comprising the actual PK. Does the hardware module somehow "validate" a request before "approving" it to limit scope of damage?
    – S.O.S
    Jan 29, 2021 at 18:21
  • Additionally, in the first example (encrypting the PK so users won't have to trust the site) users would still need to trust the site that they are in fact encrypting the PK. So there would still be a big element of trust between the site and user.
    – S.O.S
    Jan 29, 2021 at 18:23
  • 1
    @S.O.S For your first comment, refer to your other question: bitcoin.stackexchange.com/questions/101986 For your second comment: No, not necessarily, the sites that are encrypting the user's private key are generally doing the encryption on the user's browser in Javascript and sending only the encrypted text back to the service. Technically savvy users can review that Javascript and make sure that it's really doing what it claims to be doing.
    – ieatpizza
    Jan 29, 2021 at 21:09

Your Answer

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

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