Struct deep_space::private_key::CosmosPrivateKey
source · pub struct CosmosPrivateKey(_);Expand description
This structure represents a private key of a Cosmos Network.
Implementations§
source§impl CosmosPrivateKey
impl CosmosPrivateKey
sourcepub fn to_public_key(
&self,
prefix: &str
) -> Result<CosmosPublicKey, PrivateKeyError>
pub fn to_public_key( &self, prefix: &str ) -> Result<CosmosPublicKey, PrivateKeyError>
Obtain a public key for a given private key
Trait Implementations§
source§impl Clone for CosmosPrivateKey
impl Clone for CosmosPrivateKey
source§fn clone(&self) -> CosmosPrivateKey
fn clone(&self) -> CosmosPrivateKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for CosmosPrivateKey
impl Debug for CosmosPrivateKey
source§impl FromStr for CosmosPrivateKey
impl FromStr for CosmosPrivateKey
source§impl Hash for CosmosPrivateKey
impl Hash for CosmosPrivateKey
source§impl PartialEq<CosmosPrivateKey> for CosmosPrivateKey
impl PartialEq<CosmosPrivateKey> for CosmosPrivateKey
source§fn eq(&self, other: &CosmosPrivateKey) -> bool
fn eq(&self, other: &CosmosPrivateKey) -> bool
self and other values to be equal, and is used
by ==.source§impl PrivateKey for CosmosPrivateKey
impl PrivateKey for CosmosPrivateKey
source§fn from_secret(secret: &[u8]) -> CosmosPrivateKey
fn from_secret(secret: &[u8]) -> CosmosPrivateKey
Create a private key using an arbitrary slice of bytes. This function is not resistant to side channel attacks and may reveal your secret and private key. It is on the other hand more compact than the bip32+bip39 logic.
source§fn from_phrase(
phrase: &str,
passphrase: &str
) -> Result<CosmosPrivateKey, PrivateKeyError>
fn from_phrase( phrase: &str, passphrase: &str ) -> Result<CosmosPrivateKey, PrivateKeyError>
This function will take the key_import phrase provided by CosmosCLI and import that key. How this is done behind the scenes is quite complex. The actual seed bytes from the key_import are used to derive the root of a Bip32 HD wallet. From that root Cosmos keys are derived on the path m/44’/118’/0’/0/a where a=0 is the most common value used. Most Cosmos wallets do not even expose a=1..n much less the rest of the potential key space. This function returns m/44’/118’/0’/0/0 because that’s going to be the key you want essentially all the time. If you need a different path use from_hd_wallet_path()
source§fn from_hd_wallet_path(
hd_path: &str,
phrase: &str,
passphrase: &str
) -> Result<CosmosPrivateKey, PrivateKeyError>
fn from_hd_wallet_path( hd_path: &str, phrase: &str, passphrase: &str ) -> Result<CosmosPrivateKey, PrivateKeyError>
Derives a private key from a mnemonic phrase and passphrase, using a BIP-44 HDPath The actual seed bytes are derived from the mnemonic phrase, which are then used to derive the root of a Bip32 HD wallet. From that application private keys are derived on the given hd_path (e.g. Cosmos’ m/44’/118’/0’/0/a where a=0 is the most common value used). Most Cosmos wallets do not even expose a=1..n much less the rest of the potential key space.
source§fn to_address(&self, prefix: &str) -> Result<Address, PrivateKeyError>
fn to_address(&self, prefix: &str) -> Result<Address, PrivateKeyError>
Obtain an Address for a given private key, skipping the intermediate public key
source§fn get_signed_tx(
&self,
messages: &[Msg],
args: MessageArgs,
memo: &str
) -> Result<Tx, PrivateKeyError>
fn get_signed_tx( &self, messages: &[Msg], args: MessageArgs, memo: &str ) -> Result<Tx, PrivateKeyError>
Signs a transaction that contains at least one message using a single private key, returns the standard Tx type, useful for simulations
source§fn sign_std_msg(
&self,
messages: &[Msg],
args: MessageArgs,
memo: &str
) -> Result<Vec<u8>, PrivateKeyError>
fn sign_std_msg( &self, messages: &[Msg], args: MessageArgs, memo: &str ) -> Result<Vec<u8>, PrivateKeyError>
Signs a transaction that contains at least one message using a single private key.
impl Copy for CosmosPrivateKey
impl Eq for CosmosPrivateKey
impl StructuralEq for CosmosPrivateKey
impl StructuralPartialEq for CosmosPrivateKey
Auto Trait Implementations§
impl RefUnwindSafe for CosmosPrivateKey
impl Send for CosmosPrivateKey
impl Sync for CosmosPrivateKey
impl Unpin for CosmosPrivateKey
impl UnwindSafe for CosmosPrivateKey
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moresource§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request