Browse Source

Added PQ-debug

master
Igor Zhukov 10 years ago
parent
commit
d150de0bc5
  1. 9
      app/js/lib/bin_utils.js
  2. 8
      app/js/lib/mtproto.js

9
app/js/lib/bin_utils.js

@ -281,12 +281,11 @@ function pqPrimeFactorization (pqBytes) {
var what = new BigInteger(pqBytes), var what = new BigInteger(pqBytes),
result = false; result = false;
console.log('PQ start', pqBytes, what.bitLength()); console.log('PQ start', pqBytes, what.toString(16), what.bitLength());
try { try {
result = pqPrimeLeemon(str2bigInt(what.toString(16), 16, Math.ceil(64 / bpe) + 1)) result = pqPrimeLeemon(str2bigInt(what.toString(16), 16, Math.ceil(64 / bpe) + 1))
} catch (e) { } catch (e) {
console.error(e);
console.error('Pq leemon Exception', e); console.error('Pq leemon Exception', e);
} }
@ -366,7 +365,7 @@ function pqPrimeBigInteger (what) {
Q = f; Q = f;
} }
return [bytesFromBigInt(P), bytesFromBigInt(Q)]; return [bytesFromBigInt(P), bytesFromBigInt(Q), it];
} }
function gcdLong(a, b) { function gcdLong(a, b) {
@ -440,7 +439,7 @@ function pqPrimeLong(what) {
Q = f; 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)); // console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10));
return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q)]; return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it];
} }

8
app/js/lib/mtproto.js

@ -256,27 +256,27 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
throw new Error('No public key found'); 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*/) { if (!!window.Worker/* && false*/) {
var worker = new Worker('js/lib/pq_worker.js'); var worker = new Worker('js/lib/pq_worker.js');
worker.onmessage = function (e) { worker.onmessage = function (e) {
auth.p = e.data[0]; auth.p = e.data[0];
auth.q = e.data[1]; auth.q = e.data[1];
console.log(dT(), 'PQ factorization done'); console.log(dT(), 'PQ factorization done', e.data[2]);
mtpSendReqDhParams(auth); mtpSendReqDhParams(auth);
}; };
worker.onerror = function(error) { worker.onerror = function(error) {
console.log('Worker error', error, error.stack); console.log('Worker error', error, error.stack);
deferred.reject(error); deferred.reject(error);
}; };
worker.postMessage(auth.pq) worker.postMessage(auth.pq);
} else { } else {
var pAndQ = pqPrimeFactorization(auth.pq); var pAndQ = pqPrimeFactorization(auth.pq);
auth.p = pAndQ[0]; auth.p = pAndQ[0];
auth.q = pAndQ[1]; auth.q = pAndQ[1];
console.log(dT(), 'PQ factorization done'); console.log(dT(), 'PQ factorization done', pAndQ[2]);
mtpSendReqDhParams(auth); mtpSendReqDhParams(auth);
} }
}, function (error) { }, function (error) {

Loading…
Cancel
Save