From d150de0bc512fe03430e32959391fea3cd76878b Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 4 Jul 2014 17:27:59 +0400 Subject: [PATCH] Added PQ-debug --- app/js/lib/bin_utils.js | 9 ++++----- app/js/lib/mtproto.js | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/js/lib/bin_utils.js b/app/js/lib/bin_utils.js index 1778657b..56dbecc7 100644 --- a/app/js/lib/bin_utils.js +++ b/app/js/lib/bin_utils.js @@ -281,12 +281,11 @@ function pqPrimeFactorization (pqBytes) { var what = new BigInteger(pqBytes), result = false; - console.log('PQ start', pqBytes, what.bitLength()); + console.log('PQ start', pqBytes, what.toString(16), what.bitLength()); try { result = pqPrimeLeemon(str2bigInt(what.toString(16), 16, Math.ceil(64 / bpe) + 1)) } catch (e) { - console.error(e); console.error('Pq leemon Exception', e); } @@ -366,7 +365,7 @@ function pqPrimeBigInteger (what) { Q = f; } - return [bytesFromBigInt(P), bytesFromBigInt(Q)]; + return [bytesFromBigInt(P), bytesFromBigInt(Q), it]; } function gcdLong(a, b) { @@ -440,7 +439,7 @@ function pqPrimeLong(what) { Q = f; } - return [bytesFromHex(P.toString(16)), bytesFromHex(Q.toString(16))]; + return [bytesFromHex(P.toString(16)), bytesFromHex(Q.toString(16)), it]; } @@ -515,5 +514,5 @@ function pqPrimeLeemon (what) { // console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10)); - return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q)]; + return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it]; } \ No newline at end of file diff --git a/app/js/lib/mtproto.js b/app/js/lib/mtproto.js index a473c68a..dc0ad2da 100644 --- a/app/js/lib/mtproto.js +++ b/app/js/lib/mtproto.js @@ -256,27 +256,27 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) throw new Error('No public key found'); } - console.log(dT(), 'PQ factorization start'); + console.log(dT(), 'PQ factorization start', auth.pq); if (!!window.Worker/* && false*/) { var worker = new Worker('js/lib/pq_worker.js'); worker.onmessage = function (e) { auth.p = e.data[0]; auth.q = e.data[1]; - console.log(dT(), 'PQ factorization done'); + console.log(dT(), 'PQ factorization done', e.data[2]); mtpSendReqDhParams(auth); }; worker.onerror = function(error) { console.log('Worker error', error, error.stack); deferred.reject(error); }; - worker.postMessage(auth.pq) + worker.postMessage(auth.pq); } else { var pAndQ = pqPrimeFactorization(auth.pq); auth.p = pAndQ[0]; auth.q = pAndQ[1]; - console.log(dT(), 'PQ factorization done'); + console.log(dT(), 'PQ factorization done', pAndQ[2]); mtpSendReqDhParams(auth); } }, function (error) {