Skip to content

fix(key-wallet): keep chain codes and mnemonic words out of Debug output - #1265

Merged
xdustinface merged 1 commit into
devfrom
pasta/redact-key-debug
Nov 1, 2026
Merged

xdustinface merged 1 commit into
devfrom
pasta/redact-key-debug

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Debug output of some key-wallet private key types prints what they hold. The Debug of ExtendedPrivKey, ExtendedBLSPrivKey and ExtendedEd25519PrivKey prints the chain code. RootExtendedPrivKey derives Debug, so it prints its chain code too (its private key already shows as EcdsaSecretKey(..)). Mnemonic derives Debug through bip39::Mnemonic. With bip39 2.2.0, which bip39 = "2.2.0" still allows, that lists the word indices, and those spell out the phrase (later bip39 versions print only the language). A logged {:?} of any of them, or of a Wallet that holds them, exposes that data.

This change:

  • drops the chain code from the Debug of ExtendedPrivKey, ExtendedBLSPrivKey and ExtendedEd25519PrivKey; they keep network, depth, parent fingerprint and child number;
  • gives RootExtendedPrivKey a Debug that prints RootExtendedPrivKey { .. };
  • gives Mnemonic its own Debug that prints only the language and word count, whichever bip39 version is resolved.

Seed and EcdsaSecretKey already redact theirs.

Tested by new tests in key-wallet/tests/key_debug_tests.rs. They check that {:?} and {:#?} show neither the chain code nor the private key (as hex or as a byte array) and no phrase word or word index. All five fail without the change. With bip39 2.2.1 or later, the Mnemonic test fails only on its exact-output assertion, since that bip39 already omits the indices.

🤖 Generated with Claude Code

PR Hygiene · aa254cc

  • Bots — coderabbitai ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • files with no dedicated owner (CHANGELOG.md) — approved by xdustinface
    • key-wallet (key-wallet/src/bip32.rs, key-wallet/src/derivation_bls_bip32.rs, key-wallet/src/derivation_slip10.rs and 3 more) — approved by xdustinface

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

Summary by CodeRabbit

  • Bug Fixes
    • Debug output for extended private keys no longer includes chain codes or private-key material. Root extended private keys now display only a generic placeholder.
    • Mnemonic debug output shows only the language and word count, rather than the phrase.
    • Note: Mnemonics created with bip39 2.2.0 may still expose word indices in debug output.

The Debug of ExtendedPrivKey, ExtendedBLSPrivKey and
ExtendedEd25519PrivKey printed the chain code, and RootExtendedPrivKey's
derived Debug printed its chain code. Mnemonic's derived Debug went
through bip39::Mnemonic, which with bip39 2.2.0 (still allowed by the
version requirement) lists the word indices that spell out the phrase.
A logged `{:?}` of any of them, or of a Wallet holding them, showed that
data. The extended private keys now omit the chain code,
RootExtendedPrivKey prints `RootExtendedPrivKey { .. }`, and Mnemonic
prints its language and word count whatever bip39 version is resolved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 1, 2026
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 39384d0 and aa254cc.

Files selected for processing: 7
  • CHANGELOG.md
  • key-wallet/src/bip32.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/mnemonic.rs
  • key-wallet/src/wallet/root_extended_keys.rs
  • key-wallet/tests/key_debug_tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Debug output for extended private keys, mnemonics, and root extended private keys now omits secret material. Tests check the formatted output, and the changelog records the changes.

Changes: Secret-Safe Debug Output

Layer / File(s) Summary
Redact secret material from debug output
key-wallet/src/bip32.rs, key-wallet/src/derivation_bls_bip32.rs, key-wallet/src/derivation_slip10.rs, key-wallet/src/mnemonic.rs, key-wallet/src/wallet/root_extended_keys.rs, key-wallet/tests/key_debug_tests.rs, CHANGELOG.md
Extended private-key debug output omits chain codes. Mnemonic output shows the language and word count, and root extended private-key output uses a fixed redacted representation. Tests check that secret representations do not appear in debug output. The changelog records these changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to aa254

The change provides the intended secret-safe Debug output, with no concrete merge-blocking issue identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing chain codes and mnemonic words from appearing in key-wallet Debug output.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 1, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

/self-reviewed

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.69%. Comparing base (c374c77) to head (aa254cc).
⚠️ Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1265      +/-   ##
==========================================
+ Coverage   80.50%   80.69%   +0.18%     
==========================================
  Files         291      291              
  Lines       77463    77743     +280     
==========================================
+ Hits        62364    62736     +372     
+ Misses      15099    15007      -92     
Flag Coverage Δ
core 78.30% <ø> (+0.09%) ⬆️
ffi 58.20% <ø> (+1.20%) ⬆️
rpc 52.05% <ø> (ø)
spv 93.71% <ø> (ø)
wallet 82.86% <100.00%> (+0.28%) ⬆️
Files with missing lines Coverage Δ
key-wallet/src/bip32.rs 85.40% <ø> (+0.95%) ⬆️
key-wallet/src/derivation_bls_bip32.rs 95.59% <100.00%> (+0.99%) ⬆️
key-wallet/src/derivation_slip10.rs 54.29% <100.00%> (+1.97%) ⬆️
key-wallet/src/mnemonic.rs 98.50% <100.00%> (+0.01%) ⬆️
key-wallet/src/wallet/root_extended_keys.rs 69.39% <100.00%> (+0.33%) ⬆️

... and 7 files with indirect coverage changes

@xdustinface
xdustinface merged commit 339faea into dev Nov 1, 2026
42 of 43 checks passed
@xdustinface
xdustinface deleted the pasta/redact-key-debug branch November 1, 2026 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants