Ejemplo n.º 1
0
        private static TLPQInnerData GetInnerData(TLInt dcId, TLResPQ resPQ, TLInt256 newNonce, out TimeSpan calcTime, out WindowsPhone.Tuple <ulong, ulong> pqPair)
        {
            var pq = BitConverter.ToUInt64(resPQ.PQ.Data.Reverse().ToArray(), 0);

            TLUtils.WriteLine("pq: " + pq);

            var pqCalcTime = Stopwatch.StartNew();

            try
            {
                pqPair = Utils.GetFastPQ(pq);
                pqCalcTime.Stop();
                calcTime = pqCalcTime.Elapsed;
                TLUtils.WriteLineAtBegin("Pq Fast calculation time: " + pqCalcTime.Elapsed);
                TLUtils.WriteLine("p: " + pqPair.Item1);
                TLUtils.WriteLine("q: " + pqPair.Item2);
            }
            catch (Exception e)
            {
                pqCalcTime = Stopwatch.StartNew();
                pqPair     = Utils.GetPQPollard(pq);
                pqCalcTime.Stop();
                calcTime = pqCalcTime.Elapsed;
                TLUtils.WriteLineAtBegin("Pq Pollard calculation time: " + pqCalcTime.Elapsed);
                TLUtils.WriteLine("p: " + pqPair.Item1);
                TLUtils.WriteLine("q: " + pqPair.Item2);
            }

            var p = TLString.FromUInt64(pqPair.Item1);
            var q = TLString.FromUInt64(pqPair.Item2);

            var innerData1 = new TLPQInnerDataDC
            {
                NewNonce    = newNonce,
                Nonce       = resPQ.Nonce,
                P           = p,
                Q           = q,
                PQ          = resPQ.PQ,
                ServerNonce = resPQ.ServerNonce,
                DCId        = dcId
            };

            return(innerData1);
        }