fix: Redact pnet pre-shared key Debug output#6490
Open
milaforge wants to merge 3 commits into
Open
Conversation
0fa9016 to
8c52925
Compare
jxs
reviewed
Jun 18, 2026
jxs
left a comment
Member
There was a problem hiding this comment.
Hi, and thanks! Left a comment otherwise LGTM
Comment on lines
+87
to
+88
| pub fn to_key_file(self) -> String { | ||
| format!("/key/swarm/psk/1.0.0/\n/base16/\n{}\n", to_hex(&self.0)) |
Member
There was a problem hiding this comment.
why do we require this? This doesn't look like canonical
Author
There was a problem hiding this comment.
Good point. to_key_file() intentionally matches the existing Display serialization; it is not meant to introduce a second key-file format.
I updated it to:
- delegate through
Display, - changed the signature to borrow
&self, - and tightened the docs on both APIs to make clear that they emit the unredacted go-libp2p key-file format.
- I also added a regression test so if
Displayever stops being the raw key-file serializer, the test points maintainers to decoupleto_key_file()instead of silently changing export behavior.
jxs
reviewed
Jun 18, 2026
| } | ||
|
|
||
| #[test] | ||
| fn debug_formatting_does_not_leak_raw_psk() { |
Member
There was a problem hiding this comment.
I don't think these tests are required
jxs
reviewed
Jun 18, 2026
| } | ||
|
|
||
| /// Export the unredacted key in go-libp2p key file format. | ||
| pub fn to_key_file(&self) -> String { |
Co-authored-by: João Oliveira <hello@jxs.pt>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Redacts PreSharedKey Debug output, covers PnetConfig derived Debug, and adds to_key_file for explicit raw keyfile export.
Tests:
cargo test -p libp2p-pnetAI Assistance Disclosure
Tools used Codex
Attestation (required):
Notes & open questions
Change checklist