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,

source

pub fn sign<T: AsRef<[u8]>>( &self, object: &T ) -> Signature<T, <A as AsymmetricKey>::PubAlg>

source§

impl<A: AsymmetricKey> SigningKey<A>

source

pub fn into_secret_key(self) -> SecretKey<A>

source

pub fn generate<RNG>(rng: RNG) -> Selfwhere RNG: RngCore + CryptoRng,

generate a new signing key

source

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,

source

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());
source

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>

source§

fn as_ref(&self) -> &SecretKey<A>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<A: AsymmetricKey> Clone for SigningKey<A>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: AsymmetricKey> Debug for SigningKey<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<A: AsymmetricKey> From<SecretKey<A>> for SigningKey<A>

source§

fn from(key: SecretKey<A>) -> Self

Converts to this type from the input type.
source§

impl<A: AsymmetricKey> From<SigningKey<A>> for SecretKey<A>

source§

fn from(key: SigningKey<A>) -> Self

Converts to this type from the input type.
source§

impl<A> Serialize for SigningKey<A>where A: AsymmetricKey, SecretKey<A>: Bech32,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,