pub struct SecretKey(/* private fields */);
Available on crate feature
ecdsa
only.Expand description
An ECDSA secret key generated using secp256r1
curve.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn generate() -> SecretKey
Available on crate feature rand
only.
pub fn generate() -> SecretKey
rand
only.Generate a new random ECDSA secret key.
Sourcepub fn sign(&self, msg: &[u8]) -> Vec<u8>
pub fn sign(&self, msg: &[u8]) -> Vec<u8>
Sign a message with this secret key, producing a DER-encoded ECDSA signature.
Sourcepub fn to_bytes(&self) -> Vec<u8>
pub fn to_bytes(&self) -> Vec<u8>
Convert a secret key into a byte buffer containing raw scalar of the key.
Sourcepub fn try_from_bytes(buf: impl AsRef<[u8]>) -> Result<SecretKey, DecodingError>
pub fn try_from_bytes(buf: impl AsRef<[u8]>) -> Result<SecretKey, DecodingError>
Try to parse a secret key from a byte buffer containing raw scalar of the key.
Trait Implementations§
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