-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[POC] wallet: Enable non-electronic (paper-based) wallet backup with codex32 #33043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33043. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. LLM Linter (✨ experimental)Possible typos and grammar issues:
drahtbot_id_4_m |
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
If I understand you correctly, the intent is that an attacker needs the wallet passphrase in addition to the seed. But the seed is the seed -- once an attacker has it, it's game over. He doesn't need the passphrase or any other part of the wallet to sweep coins. codex32 itself does not have any notion of passphrases or encryption. |
Yes, you're right. I thought the passphrase deterministically modified the seed to create the BIP 32 Extended Key, but that's not the case. Line 3542 in 73e754b
So the passphrase doesn't provide any additional security in this case. |
This could still be implemented—even as part of this PR. The wallet generates the seed, stores it, and then derives the BIP32 master key by deterministically combining the seed with the user-provided passphrase. This approach allows users to back up the raw seed while still requiring the passphrase for wallet recovery. Or am I missing something ? |
The emphasis of this PR is on backup functionality: a backup feature isn’t very useful unless you can also restore the wallet reliably. By contrast, the other PRs aim only to import a Codex32 secret—presumably from Core Lightning into Bitcoin Core—and each uses a different method. |
It might be useful to open an issue to discuss paper backups in general. I think conceptually the are three different things to backup, and each has different requirements and frequencies:
This division borrows heavily from the motivation section of: https://delvingbitcoin.org/t/a-simple-backup-scheme-for-wallet-accounts/1607 It seems to me that codex32 only plays a role in (1). And so importing it should be done with It may be nice to have a more user friendly way to do all or some of (1), (2) and (3). But that I would probably write a markdown document or a Python script. Outside of this project I could imagine a nice tool that calls various RPC methods and generates a pretty PDF, though I would not recommend that for (1). |
🐙 This pull request conflicts with the target branch and needs rebase. |
Not part of the BIP-0093 spec. If a passphrase is used it becomes a nested 2 of 2(passphrase, codex32 secret) causing funds loss if the passphrase is forgotten. Which is more likely than lost shares if the passphrase offers enough entropy to be secure (4+ In my project BAILS: I derive one codex32 share from a memorized passphrase using Argon2id to create a hybrid brain wallet shamir secret sharing scheme that is resilient against memory loss if n > t + 1. A passphrase on the secret is how SLIP-39 does it, similar to what you proposed. |
It would be a usability and compatibility improvement to begin exporting
The 4 character identifier when exporting Rationale: This default assists users in locating the correct codex32 backup for their wallets, should be distinct for every master seed users may need to disambiguate and, as it is widely stored, improves overall error correction. |
This PR introduces support for exporting and restoring wallet seeds using the codex32 format, enabling non-electronic (paper-based) wallet backups.
To accomplish this, the patch ports the
codex32.{c,h}
implementation from Core Lightning to C++, integrating it with Bitcoin Core's libraries. Corresponding unit tests for codex32 encoding and decoding are also included.Because Bitcoin Core wallets currently do not store the seed material by default, this PR adds support for doing so, along with a new wallet flag to explicitly indicate when this feature is enabled.
Two new RPCs are introduced:
exposesecret
: exports the wallet seed in codex32 format.recoverwalletfromseed
: restores a wallet from a codex32-encoded seed.A functional test included in the last commit demonstrates the full backup and restore flow. Currently, only the default derivation path is supported.
This PR is intended as a proposal for feedback—to assess whether this functionality is desirable, and to explore how it might evolve further.