pub struct Key {
pub secret_key: Option<SecretKey>,
pub public_key: Option<PublicKey>,
pub mnemonic_phrase: Option<String>,
pub private_key: String,
pub private_key_hex: String,
pub short_address: Id,
pub eth_address: String,
}
Fields
secret_key: Option<SecretKey>
public_key: Option<PublicKey>
mnemonic_phrase: Option<String>
Mnemonic phrase (optional).
private_key: String
AVAX wallet compatible private key. NEVER save mainnet-funded wallet keys here.
private_key_hex: String
Used for importing keys in MetaMask and subnet-cli. ref. https://github.com/ava-labs/subnet-cli/blob/5b69345a3fba534fb6969002f41c8d3e69026fed/internal/key/key.go#L238-L258 NEVER save mainnet-funded wallet keys here.
short_address: Id
ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/hashing#PubkeyBytesToAddress
eth_address: String
ref. https://pkg.go.dev/github.com/ethereum/go-ethereum/common#Address
Implementations
sourceimpl Key
impl Key
sourcepub fn from_private_key<S>(encoded_priv_key: S) -> Result<Self> where
S: Into<String>,
pub fn from_private_key<S>(encoded_priv_key: S) -> Result<Self> where
S: Into<String>,
Loads the specified Secp256k1 key with CB58 encoding. Takes the “private_key” field in the “Key” struct.
sourcepub fn from_private_key_raw<S>(raw: S) -> Result<Self> where
S: AsRef<[u8]>,
pub fn from_private_key_raw<S>(raw: S) -> Result<Self> where
S: AsRef<[u8]>,
Loads the specified Secp256k1 key with CB58 encoding. Takes the “private_key” field in the “Key” struct.
sourcepub fn from_private_key_eth<S>(encoded_priv_key: S) -> Result<Self> where
S: AsRef<[u8]>,
pub fn from_private_key_eth<S>(encoded_priv_key: S) -> Result<Self> where
S: AsRef<[u8]>,
Loads the specified Secp256k1 key with hex encoding. Takes the “private_key” field in the “Key” struct.
pub fn address(&self, chain_id_alias: &str, network_id: u32) -> Result<String>
pub fn short_address_bytes(&self) -> Result<Vec<u8>>
pub fn private_key_info_entry(
&self,
network_id: u32
) -> Result<PrivateKeyInfoEntry>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl ReadOnly for Key
impl ReadOnly for Key
ref. https://doc.rust-lang.org/book/ch10-02-traits.html
sourcefn get_address(&self, chain_id_alias: &str, network_id: u32) -> Result<String>
fn get_address(&self, chain_id_alias: &str, network_id: u32) -> Result<String>
Implements “crypto.PublicKeySECP256K1R.Address()” and “formatting.FormatAddress”. “human readable part” (hrp) must be valid output from “constants.GetHRP(networkID)”. ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/constants Read more
fn get_short_address(&self) -> Id
fn get_eth_address(&self) -> String
sourceimpl SignOnly for Key
impl SignOnly for Key
sourcefn sign_ecdsa_recoverable(&self, msg: &[u8]) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn sign_ecdsa_recoverable(&self, msg: &[u8]) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Signs the message with the ECDSA secret key and appends the recovery code to the signature. ref. https://github.com/rust-bitcoin/rust-secp256k1/blob/master/src/ecdsa/recovery.rs ref. https://docs.rs/secp256k1/latest/secp256k1/struct.SecretKey.html#method.sign_ecdsa ref. https://docs.rs/secp256k1/latest/secp256k1/struct.Message.html ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/crypto#PrivateKeyED25519.SignHash Read more
impl Eq for Key
impl StructuralEq for Key
impl StructuralPartialEq for Key
Auto Trait Implementations
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.