Struct secp256k1::SecretKey [−][src]
pub struct SecretKey(_);
Expand description
Secret 256-bit key used as x
in an ECDSA signature
Implementations
Formats the explicit byte value of the secret key kept inside the type as a little-endian hexadecimal string using the provided formatter.
This is the only method that outputs the actual secret key value, and, thus, should be used with extreme precaution.
Example
use secp256k1::ONE_KEY;
let key = ONE_KEY;
// Normal display hides value
assert_eq!(
"SecretKey(#2518682f7819fb2d)",
format!("{:?}", key)
);
// Here we explicitly display the secret value:
assert_eq!(
"0000000000000000000000000000000000000000000000000000000000000001",
format!("{}", key.display_secret())
);
assert_eq!(
"DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")",
format!("{:?}", key.display_secret())
);
Converts the object to a mutable raw pointer for FFI interfacing
This is supported on crate feature rand
only.
rand
only.Generates a new random secret key.
Converts a SECRET_KEY_SIZE
-byte slice to a secret key
Creates a new secret key using data from BIP-340 KeyPair
Serialize the secret key as byte value
Negates one secret key.
Adds one secret key to another, modulo the curve order. WIll return an error if the resulting key would be invalid or if the tweak was not a 32-byte length slice.
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations
Mutably borrows from an owned value. Read more