// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; /** * @title AccountHashing * @notice Utilities for hashing account identifiers with salts to protect PII */ library AccountHashing { /** * @notice Generates a hashed account reference ID * @param rail The payment rail identifier (e.g., "FEDWIRE", "SEPA") * @param countryCode The country code (e.g., "US", "DE") * @param accountIdentifier The account identifier (IBAN, ABA, etc.) - should be hashed off-chain * @param salt A unique salt for this account * @return accountRefId The hashed account reference ID */ function hashAccountRef( bytes32 rail, bytes32 countryCode, bytes32 accountIdentifier, bytes32 salt ) internal pure returns (bytes32 accountRefId) { return keccak256(abi.encodePacked(rail, countryCode, accountIdentifier, salt)); } /** * @notice Generates a hashed wallet reference ID * @param chainId The chain ID where the wallet exists * @param walletAddress The wallet address * @param providerId The provider identifier (e.g., "METAMASK", "FIREBLOCKS") * @return walletRefId The hashed wallet reference ID */ function hashWalletRef( uint256 chainId, address walletAddress, bytes32 providerId ) internal pure returns (bytes32 walletRefId) { return keccak256(abi.encodePacked(chainId, walletAddress, providerId)); } /** * @notice Generates an ICAN (Internal Canonical Account Number) reference ID * @param namespace The internal namespace identifier * @param accountId The internal account ID * @return icanRefId The ICAN reference ID */ function hashICANRef(bytes32 namespace, bytes32 accountId) internal pure returns (bytes32 icanRefId) { return keccak256(abi.encodePacked(namespace, accountId)); } }