Replaced custom safe equals function with crypto-equality