MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / to_address

Function to_address

utils/src/crypto.rs:96–99  ·  view source on GitHub ↗

Convert a public key into an address using the last 20 bytes of the hash ```rust use utils::crypto::{keypair, public_key_address}; let (private_key, public_key) = keypair(); let address = public_key_address(&public_key); ```

(item: &[u8])

Source from the content-addressed store, hash-verified

94/// let address = public_key_address(&public_key);
95/// ```
96pub fn to_address(item: &[u8]) -> H160 {
97 let hash = hash(&item[1..]);
98 Address::from_slice(&hash[12..])
99}
100
101/// Convert a public key into an address using the last 20 bytes of the hash
102///

Callers 2

public_key_addressFunction · 0.85
add_contract_accountMethod · 0.85

Calls 1

hashFunction · 0.85

Tested by

no test coverage detected