diff --git a/src/key.rs b/src/key.rs index 85482e05f..e66817306 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1718,6 +1718,31 @@ mod test { "0100000000000000020000000000000003000000000000000400000000000000" ); } + #[test] + fn test_display_obfuscation() { + #[rustfmt::skip] + static SK_BYTES: [u8; 32] = [ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, + ]; + + let sk = SecretKey::from_slice(&SK_BYTES).expect("sk"); + + #[cfg(feature = "std")] + { + let got = format!("{:?}", sk); + let want = "SecretKey(#2f4d520bd6874292)"; + assert_eq!(got, want); + } + #[cfg(all(not(feature = "std"), feature = "hashes"))] + { + let got = format!("{:?}", sk); + let want = "SecretKey(#de5a451f70110720)"; + assert_eq!(got, want); + } + } #[test] #[cfg(feature = "alloc")]