Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show byte arrays as a hex string in Debug impls, not an expanded array #127

Open
teor2345 opened this issue Jun 20, 2023 · 2 comments
Open

Comments

@teor2345
Copy link

When a debug-format x25519::PublicKey, I get some very long output (see below). But it would be much easier to read and copy shorter hex-encoded output.

Expected output:

ephemeral_key: PublicKey(
    MontgomeryPoint("ed...")
)

Actual output:

ephemeral_key: PublicKey(
    MontgomeryPoint(
        [
            237,
            202,
            200,
            4,
            252,
            109,
            173,
            91,
            83,
            6,
            112,
            86,
            76,
            54,
            29,
            134,
            199,
            218,
            161,
            12,
            26,
            129,
            61,
            228,
            212,
            40,
            55,
            96,
            130,
            233,
            89,
            70,
        ],
    ),
),
@rozbb
Copy link
Collaborator

rozbb commented Jun 21, 2023

Hmm, so PublicKey wraps MontgomeryPoint which wraps [u8; 32] and all of them autoderive Debug.

What happens if you do println!("{:x?}", my_pubkey)

@teor2345
Copy link
Author

teor2345 commented Jul 3, 2023

Hmm, so PublicKey wraps MontgomeryPoint which wraps [u8; 32] and all of them autoderive Debug.

What happens if you do println!("{:x?}", my_pubkey)

The "actual output" in the ticket is what happens when I debug-print a key.

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

No branches or pull requests

2 participants