Struct cml_crypto::PrivateKey
source · pub struct PrivateKey(/* private fields */);Implementations§
source§impl PrivateKey
impl PrivateKey
pub fn to_public(&self) -> PublicKey
pub fn generate_ed25519() -> PrivateKey
pub fn generate_ed25519extended() -> PrivateKey
sourcepub fn from_bech32(bech32_str: &str) -> Result<PrivateKey, CryptoError>
pub fn from_bech32(bech32_str: &str) -> Result<PrivateKey, CryptoError>
Get private key from its bech32 representation
use cml_crypto::PrivateKey;
let key = PrivateKey::from_bech32("ed25519_sk1ahfetf02qwwg4dkq7mgp4a25lx5vh9920cr5wnxmpzz9906qvm8qwvlts0").unwrap();For an extended 25519 key
use cml_crypto::PrivateKey;
let key = PrivateKey::from_bech32("ed25519e_sk1gqwl4szuwwh6d0yk3nsqcc6xxc3fpvjlevgwvt60df59v8zd8f8prazt8ln3lmz096ux3xvhhvm3ca9wj2yctdh3pnw0szrma07rt5gl748fp").unwrap();pub fn to_bech32(&self) -> String
pub fn from_extended_bytes(bytes: &[u8]) -> Result<PrivateKey, CryptoError>
pub fn from_normal_bytes(bytes: &[u8]) -> Result<PrivateKey, CryptoError>
pub fn sign(&self, message: &[u8]) -> Ed25519Signature
Trait Implementations§
source§impl From<EitherEd25519SecretKey> for PrivateKey
impl From<EitherEd25519SecretKey> for PrivateKey
source§fn from(secret_key: EitherEd25519SecretKey) -> PrivateKey
fn from(secret_key: EitherEd25519SecretKey) -> PrivateKey
Converts to this type from the input type.
source§impl RawBytesEncoding for PrivateKey
impl RawBytesEncoding for PrivateKey
fn to_raw_bytes(&self) -> &[u8] ⓘ
fn from_raw_bytes(bytes: &[u8]) -> Result<Self, CryptoError>
fn to_raw_hex(&self) -> String
fn from_raw_hex(hex_str: &str) -> Result<Self, CryptoError>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
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