Struct avalanche_types::key::secp256k1::public_key::Key
source · pub struct Key(pub PublicKey);
Expand description
Represents “k256::PublicKey” and “k256::ecdsa::VerifyingKey”.
Tuple Fields
0: PublicKey
Implementations
sourceimpl Key
impl Key
sourcepub fn from_sec1_bytes(b: &[u8]) -> Result<Self>
pub fn from_sec1_bytes(b: &[u8]) -> Result<Self>
Decodes compressed or uncompressed public key bytes with Elliptic-Curve-Point-to-Octet-String encoding described in SEC 1: Elliptic Curve Cryptography (Version 2.0) section 2.3.3 (page 10). ref. http://www.secg.org/sec1-v2.pdf
sourcepub fn from_public_key_der(b: &[u8]) -> Result<Self>
pub fn from_public_key_der(b: &[u8]) -> Result<Self>
Decodes ASN.1 DER-encoded public key bytes.
sourcepub fn from_signature(digest: &[u8], sig: &[u8]) -> Result<Self>
pub fn from_signature(digest: &[u8], sig: &[u8]) -> Result<Self>
Loads the public key from a message and its recoverable signature. ref. “fx.SECPFactory.RecoverHashPublicKey”
pub fn to_verifying_key(&self) -> VerifyingKey
sourcepub fn verify(&self, digest: &[u8], sig: &[u8]) -> Result<bool>
pub fn verify(&self, digest: &[u8], sig: &[u8]) -> Result<bool>
Verifies the message and the validity of its signature with recoverable code.
sourcepub fn to_compressed_bytes(&self) -> [u8; 33]
pub fn to_compressed_bytes(&self) -> [u8; 33]
Converts the public key to compressed bytes.
sourcepub fn to_uncompressed_bytes(&self) -> [u8; 65]
pub fn to_uncompressed_bytes(&self) -> [u8; 65]
Converts the public key to uncompressed bytes.
sourcepub fn to_short_id(&self) -> Result<Id>
pub fn to_short_id(&self) -> Result<Id>
“hashing.PubkeyBytesToAddress” ref. “pk.PublicKey().Address().Bytes()” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/hashing#PubkeyBytesToAddress
sourcepub fn to_short_bytes(&self) -> Result<Vec<u8>>
pub fn to_short_bytes(&self) -> Result<Vec<u8>>
“hashing.PubkeyBytesToAddress” and “ids.ToShortID” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/hashing#PubkeyBytesToAddress
pub fn to_h160(&self) -> H160
pub fn hrp_address(&self, network_id: u32, chain_id_alias: &str) -> Result<String>
sourcepub fn eth_address(&self) -> String
pub fn eth_address(&self) -> String
Encodes the public key in ETH address format. ref. https://pkg.go.dev/github.com/ethereum/go-ethereum/crypto#PubkeyToAddress ref. https://pkg.go.dev/github.com/ethereum/go-ethereum/common#Address.Hex
Trait Implementations
sourceimpl Display for Key
impl Display for Key
ref. https://doc.rust-lang.org/std/string/trait.ToString.html ref. https://doc.rust-lang.org/std/fmt/trait.Display.html Use “Self.to_string()” to directly invoke this
sourceimpl From<Key> for VerifyingKey
impl From<Key> for VerifyingKey
sourceimpl From<VerifyingKey> for Key
impl From<VerifyingKey> for Key
sourcefn from(vkey: VerifyingKey) -> Self
fn from(vkey: VerifyingKey) -> Self
sourceimpl ReadOnly for Key
impl ReadOnly for Key
ref. https://doc.rust-lang.org/book/ch10-02-traits.html
sourcefn hrp_address(&self, network_id: u32, chain_id_alias: &str) -> Result<String>
fn hrp_address(&self, network_id: u32, chain_id_alias: &str) -> Result<String>
fn short_address(&self) -> Result<Id>
fn short_address_bytes(&self) -> Result<Vec<u8>>
fn eth_address(&self) -> String
fn h160_address(&self) -> H160
impl Copy for Key
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<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,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.