Bitcoin Core has secure_allocator
, which allocates inside special “secure” (non-swappable) memory pages, which may be limited in availability. Currently, every CKey
object uses 32 such secure bytes, even when the CKey
object contains the (invalid) value zero.
Change this to not use memory when the CKey
is invalid. This is particularly relevant for BIP324Cipher
which briefly holds a CKey
, but after receiving the remote’s public key and initializing the encryption ciphers, the key is wiped. In case secure memory usage is in high demand, it’d be silly to waste it on P2P encryption keys instead of wallet keys.