update the algorithm for obtaining the chatKey