// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; library AddressUtils { // This is the hex encoding of the string 'abcdefghijklmnopqrstuvwxyz' // It is used as a constant to lookup the characters of the hex address bytes32 constant lookup = 0x3031323334353637383961626364656600000000000000000000000000000000; /** * @dev An optimised function to compute the sha3 of the lower-case * hexadecimal representation of an Ethereum address. * @param addr The address to hash * @return ret The SHA3 hash of the lower-case hexadecimal encoding of the * input address. */ function sha3HexAddress(address addr) internal pure returns (bytes32 ret) { assembly { for { let i := 40 } gt(i, 0) {} { i := sub(i, 1) mstore8(i, byte(and(addr, 0xf), lookup)) addr := div(addr, 0x10) i := sub(i, 1) mstore8(i, byte(and(addr, 0xf), lookup)) addr := div(addr, 0x10) } ret := keccak256(0, 40) } } }