pub fn sha256_ripemd160<B>(b: B) -> Result<Vec<u8>>where
    B: AsRef<[u8]>,
Expand description

Converts bytes to the short address bytes (20-byte). e.g., “hashing.PubkeyBytesToAddress” and “ids.ToShortID” ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/utils/hashing#PubkeyBytesToAddress

Examples found in repository?
src/key/secp256k1/public_key.rs (line 111)
109
110
111
112
    pub fn to_short_bytes(&self) -> io::Result<Vec<u8>> {
        let compressed = self.to_compressed_bytes();
        hash::sha256_ripemd160(&compressed)
    }
More examples
Hide additional examples
src/ids/node.rs (line 81)
77
78
79
80
81
82
83
84
    pub fn from_cert_der_bytes<S>(cert_bytes: S) -> io::Result<Self>
    where
        S: AsRef<[u8]>,
    {
        let short_address = hash::sha256_ripemd160(cert_bytes)?;
        let node_id = Self::from_slice(&short_address);
        Ok(node_id)
    }
src/ids/short.rs (line 61)
57
58
59
60
61
62
63
64
65
66
67
    pub fn from_public_key_bytes<S>(pub_key_bytes: S) -> io::Result<Self>
    where
        S: AsRef<[u8]>,
    {
        let hashed = hash::sha256_ripemd160(pub_key_bytes)?;

        // "ids.Id.String"
        // ref. https://pkg.go.dev/github.com/ava-labs/avalanchego/ids#Id.String
        let encoded = formatting::encode_cb58_with_checksum_string(&hashed);
        Self::from_str(&encoded)
    }