pub struct CosmosPrivateKey(/* private fields */);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 for CosmosPrivateKey
impl PartialEq for CosmosPrivateKey
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 StructuralPartialEq for CosmosPrivateKey
Auto Trait Implementations§
impl Freeze for CosmosPrivateKey
impl RefUnwindSafe for CosmosPrivateKey
impl Send for CosmosPrivateKey
impl Sync for CosmosPrivateKey
impl Unpin for CosmosPrivateKey
impl UnwindSafe for CosmosPrivateKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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