pub struct PrivateKey(/* private fields */);Expand description
An EdDSA secret key.
Implementations§
Source§impl PrivateKey
impl PrivateKey
pub fn new() -> Self
Sourcepub fn generate(password: &str) -> (Self, String)
pub fn generate(password: &str) -> (Self, String)
Generate a PrivateKey with a BIP-39 mnemonic using a cryptographically
secure random number generator.
The password is required with the mnemonic to reproduce the secret key.
Sourcepub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, HederaError>
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self, HederaError>
Construct a PrivateKey from a slice of bytes.
Bytes are expected to be either a raw key or encoded in ASN.1.
Sourcepub fn from_mnemonic(
mnemonic: &str,
password: &str,
) -> Result<Self, HederaError>
pub fn from_mnemonic( mnemonic: &str, password: &str, ) -> Result<Self, HederaError>
Re-construct a PrivateKey from the supplied mnemonic and password.
pub fn as_bytes_vec(&self) -> Vec<u8> ⓘ
Sourcepub fn to_encoded_bytes(&self) -> Vec<u8> ⓘ
pub fn to_encoded_bytes(&self) -> Vec<u8> ⓘ
Format a PrivateKey as a vec of bytes in ASN.1 format.
Sourcepub fn sign(&self, message: impl AsRef<[u8]>) -> Signature
pub fn sign(&self, message: impl AsRef<[u8]>) -> Signature
Sign a message with this PrivateKey.
pub async fn sign_transaction( &self, transaction: &mut Transaction, ) -> Result<(), HederaError>
Trait Implementations§
Source§impl Clone for PrivateKey
impl Clone for PrivateKey
Source§impl Debug for PrivateKey
impl Debug for PrivateKey
Source§impl Display for PrivateKey
Format a PrivateKey as a hex representation of its bytes in ASN.1 format.
impl Display for PrivateKey
Format a PrivateKey as a hex representation of its bytes in ASN.1 format.
Source§impl From<PrivateKey> for Key
impl From<PrivateKey> for Key
Source§fn from(pk: PrivateKey) -> Key
fn from(pk: PrivateKey) -> Key
Converts to this type from the input type.
Source§impl FromStr for PrivateKey
Construct a PrivateKey from a hex representation of a raw or ASN.1 encoded
key.
impl FromStr for PrivateKey
Construct a PrivateKey from a hex representation of a raw or ASN.1 encoded
key.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request