Browse Source

Added PQ-debug

master
Igor Zhukov 11 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) { @@ -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) { @@ -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) { @@ -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) { @@ -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];
}

8
app/js/lib/mtproto.js

@ -256,27 +256,27 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -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) {

Loading…
Cancel
Save