wallet: refactor: various master key encryption cleanups #31398

pull theStack wants to merge 5 commits into bitcoin:master from theStack:202411-wallet-encryption_cleanups changing 2 files +76 −65
  1. theStack commented at 3:54 am on December 1, 2024: contributor
    This PR contains various cleanups around the wallet’s master key encryption logic. The default/minimum key derivation rounds magic number of 25000 is hoisted into a constant (member of CMasterKey) and two new functions EncryptMasterKey/DecryptMasterKey are introduced in order to deduplicate code for the derivation round determination and master key en/decryption. Also, mentions of the never-implemented derivation method scrypt are removed from the wallet crypter header and both plain and encrypted master key instances are renamed to adapt to moderning coding style (hopefully improving readability).
  2. wallet: doc: remove mentions of unavailable scrypt derivation method
    These comments are there since wallet encryption was first introduced
    (see commit 4e87d341f75f13bbd7d108c31c03886fbc4df56f, PR #352), but scrypt
    was actually never implemented as a derivation method.
    a6af5b45a1
  3. wallet: refactor: introduce `CMasterKey::DEFAULT_DERIVE_ITERATIONS` constant
    This gets rid of the magic number used in both the `CMasterKey` ctor
    and the wallet encryption / passphrase change methods.
    22e9869524
  4. wallet: refactor: dedup master key encryption / derivation rounds setting de9b54780b
  5. wallet: refactor: dedup master key decryption ba9f582332
  6. scripted-diff: wallet: rename plain and encrypted master key variables
    -BEGIN VERIFY SCRIPT-
    sed -i s/_vMasterKey/plain_master_key/g ./src/wallet/wallet.cpp
    sed -i s/kMasterKey/master_key/g ./src/wallet/wallet.cpp
    sed -i "s/const MasterKeyMap::value_type& pMasterKey/const auto\& \[_, master_key\]/g" ./src/wallet/wallet.cpp
    sed -i s/pMasterKey\.second/master_key/g ./src/wallet/wallet.cpp
    sed -i "s/MasterKeyMap::value_type& pMasterKey/auto\& \[master_key_id, master_key\]/g" ./src/wallet/wallet.cpp
    sed -i s/pMasterKey\.first/master_key_id/g ./src/wallet/wallet.cpp
    -END VERIFY SCRIPT-
    bda3a48190
  7. DrahtBot commented at 3:54 am on December 1, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31398.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
    • #28710 (Remove the legacy wallet and BDB dependency by achow101)

    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.

  8. DrahtBot added the label Wallet on Dec 1, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me