refactor(key-wallet): derive Zeroize on WalletType and wipe on drop#780
Conversation
📝 WalkthroughWalkthroughThis PR adds explicit zeroization support to two sensitive cryptographic types in the wallet module. ChangesSensitive Data Zeroization Pattern
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
key-wallet/src/wallet/root_extended_keys.rs (1)
25-30: ⚡ Quick winEnable
secp256k1/zeroizefeature for stronger memory zeroing guarantees.The
non_secure_erase()method lacks guarantees against compiler optimizations. Thesecp256k1crate'szeroizefeature implements theZeroizetrait with proper memory barriers. Add"zeroize"to the features list inkey-wallet/Cargo.toml(line 37), then useself.root_private_key.zeroize()instead.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@key-wallet/src/wallet/root_extended_keys.rs` around lines 25 - 30, Enable the secp256k1 crate's "zeroize" feature in Cargo.toml and replace the insecure erasure call in RootExtendedPrivKey::zeroize with the proper Zeroize method: add "zeroize" to the features list for the secp256k1 dependency so the crate implements Zeroize, then change the implementation on RootExtendedPrivKey to call self.root_private_key.zeroize() (and keep self.root_chain_code.zeroize()) to ensure secure memory zeroing; update any imports if needed to satisfy the Zeroize trait usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@key-wallet/src/wallet/root_extended_keys.rs`:
- Around line 25-30: Enable the secp256k1 crate's "zeroize" feature in
Cargo.toml and replace the insecure erasure call in RootExtendedPrivKey::zeroize
with the proper Zeroize method: add "zeroize" to the features list for the
secp256k1 dependency so the crate implements Zeroize, then change the
implementation on RootExtendedPrivKey to call self.root_private_key.zeroize()
(and keep self.root_chain_code.zeroize()) to ensure secure memory zeroing;
update any imports if needed to satisfy the Zeroize trait usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 121f37fc-2a0f-46b7-b424-7443ea89d0e4
📒 Files selected for processing (2)
key-wallet/src/wallet/mod.rskey-wallet/src/wallet/root_extended_keys.rs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #780 +/- ##
==========================================
- Coverage 72.45% 72.21% -0.25%
==========================================
Files 321 321
Lines 70350 70329 -21
==========================================
- Hits 50974 50787 -187
- Misses 19376 19542 +166
|
Zeroize on WalletType and wipe on drop
Summary by CodeRabbit