Use a worker to facilitate key generation
This commit is contained in:
parent
f465bdddbf
commit
7d0aeac8cb
5 changed files with 14 additions and 18 deletions
|
@ -139,7 +139,7 @@ module.exports = function(grunt) {
|
||||||
},
|
},
|
||||||
jscs: {
|
jscs: {
|
||||||
all: {
|
all: {
|
||||||
src: ['js/**/*.js', '!js/libtextsecure.js', '!js/components.js', 'test/**/*.js']
|
src: ['js/**/*.js', '!js/libtextsecure.js', '!js/libaxolotl-worker.js', '!js/components.js', 'test/**/*.js']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -37828,14 +37828,11 @@ axolotlInternal.RecipientRecord = function() {
|
||||||
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
||||||
return axolotlInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
return axolotlInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
||||||
},
|
},
|
||||||
generateKeys: function(count, progressCallback) {
|
startWorker: function() {
|
||||||
if (textsecure.worker_path) {
|
axolotlInstance.startWorker('/js/libaxolotl-worker.js');
|
||||||
axolotlInstance.startWorker(textsecure.worker_path);
|
},
|
||||||
}
|
stopWorker: function() {
|
||||||
return generateKeys(count, progressCallback).then(function(result) {
|
axolotlInstance.stopWorker();
|
||||||
axolotlInstance.stopWorker();
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
createIdentityKeyRecvSocket: function() {
|
createIdentityKeyRecvSocket: function() {
|
||||||
return axolotlInstance.createIdentityKeyRecvSocket();
|
return axolotlInstance.createIdentityKeyRecvSocket();
|
||||||
|
|
|
@ -79,7 +79,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function createAccount(number, verificationCode, identityKeyPair, single_device) {
|
function createAccount(number, verificationCode, identityKeyPair, single_device) {
|
||||||
textsecure.storage.put('identityKey', identityKeyPair);
|
textsecure.storage.put('identityKey', identityKeyPair);
|
||||||
|
|
||||||
|
@ -119,6 +118,8 @@ function generateKeys(count, progressCallback) {
|
||||||
throw new Error('Invalid signedKeyId');
|
throw new Error('Invalid signedKeyId');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textsecure.protocol_wrapper.startWorker();
|
||||||
|
|
||||||
var store = textsecure.storage.axolotl;
|
var store = textsecure.storage.axolotl;
|
||||||
var identityKey = store.getMyIdentityKey();
|
var identityKey = store.getMyIdentityKey();
|
||||||
var result = { preKeys: [], identityKey: identityKey.pubKey };
|
var result = { preKeys: [], identityKey: identityKey.pubKey };
|
||||||
|
@ -152,6 +153,7 @@ function generateKeys(count, progressCallback) {
|
||||||
textsecure.storage.put('maxPreKeyId', startId + count);
|
textsecure.storage.put('maxPreKeyId', startId + count);
|
||||||
textsecure.storage.put('signedKeyId', signedKeyId + 1);
|
textsecure.storage.put('signedKeyId', signedKeyId + 1);
|
||||||
return Promise.all(promises).then(function() {
|
return Promise.all(promises).then(function() {
|
||||||
|
textsecure.protocol_wrapper.stopWorker();
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,14 +55,11 @@
|
||||||
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
encryptMessageFor: function(deviceObject, pushMessageContent) {
|
||||||
return axolotlInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
return axolotlInstance.encryptMessageFor(deviceObject, pushMessageContent);
|
||||||
},
|
},
|
||||||
generateKeys: function(count, progressCallback) {
|
startWorker: function() {
|
||||||
if (textsecure.worker_path) {
|
axolotlInstance.startWorker('/js/libaxolotl-worker.js');
|
||||||
axolotlInstance.startWorker(textsecure.worker_path);
|
},
|
||||||
}
|
stopWorker: function() {
|
||||||
return generateKeys(count, progressCallback).then(function(result) {
|
axolotlInstance.stopWorker();
|
||||||
axolotlInstance.stopWorker();
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
createIdentityKeyRecvSocket: function() {
|
createIdentityKeyRecvSocket: function() {
|
||||||
return axolotlInstance.createIdentityKeyRecvSocket();
|
return axolotlInstance.createIdentityKeyRecvSocket();
|
||||||
|
|
Loading…
Reference in a new issue