Struct jormungandr_lib::crypto::key::SigningKey
source · pub struct SigningKey<A: AsymmetricKey>(pub(crate) SecretKey<A>);
Expand description
A cryptographic signing key (or secret key). Can be used to sign transaction, certificates or blocks.
A Signing key is always associated with its Identifier
which can be extracted from the SigningKey
.
More info at the module documentation
Tuple Fields§
§0: SecretKey<A>
Implementations§
source§impl<A: SigningAlgorithm> SigningKey<A>where
<A as AsymmetricKey>::PubAlg: VerificationAlgorithm,
impl<A: SigningAlgorithm> SigningKey<A>where <A as AsymmetricKey>::PubAlg: VerificationAlgorithm,
source§impl<A: AsymmetricKey> SigningKey<A>
impl<A: AsymmetricKey> SigningKey<A>
pub fn into_secret_key(self) -> SecretKey<A>
sourcepub fn generate<RNG>(rng: RNG) -> Selfwhere
RNG: RngCore + CryptoRng,
pub fn generate<RNG>(rng: RNG) -> Selfwhere RNG: RngCore + CryptoRng,
generate a new signing key
sourcepub fn identifier(&self) -> Identifier<<A as AsymmetricKey>::PubAlg>
pub fn identifier(&self) -> Identifier<<A as AsymmetricKey>::PubAlg>
get the identifier associated to this key.
source§impl<A> SigningKey<A>where
A: AsymmetricKey,
SecretKey<A>: Bech32,
impl<A> SigningKey<A>where A: AsymmetricKey, SecretKey<A>: Bech32,
sourcepub fn to_bech32_str(&self) -> String
pub fn to_bech32_str(&self) -> String
encode the SigningKey
into a bech32 string.
This is a human readable encoding that allows to check input validation. When displaying this signing key to the user it is preferable to provide the output of this function.
Serde implementation of SigningKey
provides the bech32 string support.
Example
let key : SigningKey<Ed25519> = SigningKey::generate(thread_rng());
println!("key: {}", key.to_bech32_str());
sourcepub fn from_bech32_str(s: &str) -> Result<Self, Error>
pub fn from_bech32_str(s: &str) -> Result<Self, Error>
try to decode the given bech32 string into a valid signing key
Trait Implementations§
source§impl<A: AsymmetricKey> AsRef<SecretKey<A>> for SigningKey<A>
impl<A: AsymmetricKey> AsRef<SecretKey<A>> for SigningKey<A>
source§impl<A: AsymmetricKey> Clone for SigningKey<A>
impl<A: AsymmetricKey> Clone for SigningKey<A>
source§impl<A: AsymmetricKey> Debug for SigningKey<A>
impl<A: AsymmetricKey> Debug for SigningKey<A>
source§impl<'de, A> Deserialize<'de> for SigningKey<A>where
A: AsymmetricKey,
SecretKey<A>: Bech32,
impl<'de, A> Deserialize<'de> for SigningKey<A>where A: AsymmetricKey, SecretKey<A>: Bech32,
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<A: AsymmetricKey> From<SecretKey<A>> for SigningKey<A>
impl<A: AsymmetricKey> From<SecretKey<A>> for SigningKey<A>
source§impl<A: AsymmetricKey> From<SigningKey<A>> for SecretKey<A>
impl<A: AsymmetricKey> From<SigningKey<A>> for SecretKey<A>
source§fn from(key: SigningKey<A>) -> Self
fn from(key: SigningKey<A>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<A> RefUnwindSafe for SigningKey<A>where <A as AsymmetricKey>::Secret: RefUnwindSafe,
impl<A> Send for SigningKey<A>where <A as AsymmetricKey>::Secret: Send,
impl<A> Sync for SigningKey<A>where <A as AsymmetricKey>::Secret: Sync,
impl<A> Unpin for SigningKey<A>where <A as AsymmetricKey>::Secret: Unpin,
impl<A> UnwindSafe for SigningKey<A>where <A as AsymmetricKey>::Secret: UnwindSafe,
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