Struct CosmosPrivateKey

Source
pub struct CosmosPrivateKey(/* private fields */);
Expand description

This structure represents a private key of a Cosmos Network.

Implementations§

Source§

impl CosmosPrivateKey

Source

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

Source§

fn clone(&self) -> CosmosPrivateKey

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 Debug for CosmosPrivateKey

Source§

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

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

impl FromStr for CosmosPrivateKey

Source§

type Err = PrivateKeyError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for CosmosPrivateKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CosmosPrivateKey

Source§

fn eq(&self, other: &CosmosPrivateKey) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PrivateKey for CosmosPrivateKey

Source§

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>

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>

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>

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>

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>

Signs a transaction that contains at least one message using a single private key.

Source§

impl Copy for CosmosPrivateKey

Source§

impl Eq for CosmosPrivateKey

Source§

impl StructuralPartialEq for CosmosPrivateKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts 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 more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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 T
where 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.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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