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.

    Type Reviewers
    Concept ACK furszy

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    No conflicts as of last run.

  8. DrahtBot added the label Wallet on Dec 1, 2024
  9. furszy commented at 6:04 pm on December 27, 2024: member
    Concept ACK, nice code dedup.

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: 2025-01-21 06:12 UTC

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