Updated pattern search function to use private key