pub struct SecretKey(/* private fields */);Expand description
A secret key.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn random_with_rng(rng: &mut (impl CryptoRng + RngCore)) -> Self
pub fn random_with_rng(rng: &mut (impl CryptoRng + RngCore)) -> Self
Creates a secret key using the given RNG.
Sourcepub fn random() -> Self
Available on crate feature default-rng only.
pub fn random() -> Self
default-rng only.Creates a secret key using the default RNG.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Returns a public key corresponding to this secret key.
Sourcepub fn to_be_bytes(
&self,
) -> SecretBox<GenericArray<u8, FieldBytesSize<Secp256k1>>>
pub fn to_be_bytes( &self, ) -> SecretBox<GenericArray<u8, FieldBytesSize<Secp256k1>>>
Serializes the secret key as a scalar in the big-endian representation.
Sourcepub fn try_from_be_bytes(
bytes: &SecretBox<GenericArray<u8, FieldBytesSize<Secp256k1>>>,
) -> Result<Self, String>
pub fn try_from_be_bytes( bytes: &SecretBox<GenericArray<u8, FieldBytesSize<Secp256k1>>>, ) -> Result<Self, String>
Deserializes the secret key from a scalar in the big-endian representation.
Trait Implementations§
impl Eq for SecretKey
impl StructuralPartialEq for SecretKey
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more