simplify key generation and remember user's additional keys
This commit is contained in:
parent
621476424d
commit
75786ff9ff
@ -254,32 +254,25 @@ define([
|
|||||||
// 16 bytes for a deterministic channel key
|
// 16 bytes for a deterministic channel key
|
||||||
var channelSeed = dispense(16);
|
var channelSeed = dispense(16);
|
||||||
// 32 bytes for a curve key
|
// 32 bytes for a curve key
|
||||||
var curveSeed = dispense(32);
|
var curveSeed = opt.curveSeed = dispense(32);
|
||||||
// 32 more for a signing key
|
// 32 more for a signing key
|
||||||
var edSeed = dispense(32);
|
var edSeed = opt.edSeed = dispense(32);
|
||||||
|
|
||||||
var keys = opt.keys = Crypto.createEditCryptor(null, encryptionSeed);
|
|
||||||
|
|
||||||
// 24 bytes of base64
|
|
||||||
keys.editKeyStr = keys.editKeyStr.replace(/\//g, '-');
|
|
||||||
|
|
||||||
// 32 bytes of hex
|
// 32 bytes of hex
|
||||||
opt.channel = Cryptpad.uint8ArrayToHex(channelSeed);
|
var channelKey = opt.channel = Cryptpad.uint8ArrayToHex(channelSeed);
|
||||||
|
|
||||||
var channelHex = opt.channel;
|
// a bit of a dirty hack to get the same output as we are used to
|
||||||
|
var keys = opt.keys = Crypto.createEditCryptor(null, encryptionSeed);
|
||||||
|
|
||||||
if (channelHex.length !== 32) { throw new Error('invalid channel id'); }
|
var editHash = opt.editHash = Cryptpad.getEditHashFromKeys(channelKey, keys);
|
||||||
|
var secret = Cryptpad.getSecrets(editHash);
|
||||||
var channel64 = opt.channel64 = Cryptpad.hexToBase64(channelHex);
|
|
||||||
|
|
||||||
opt.editHash = Cryptpad.getEditHashFromKeys(channelHex, keys.editKeyStr);
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
websocketURL: Cryptpad.getWebsocketURL(),
|
websocketURL: Cryptpad.getWebsocketURL(),
|
||||||
channel: channelHex,
|
channel: channelKey,
|
||||||
data: {},
|
data: {},
|
||||||
validateKey: keys.validateKey, // derived validation key
|
validateKey: secret.keys.validateKeys, // derived validation key
|
||||||
crypto: Crypto.createEncryptor(opt.keys),
|
crypto: Crypto.createEncryptor(secret.keys),
|
||||||
};
|
};
|
||||||
|
|
||||||
var rt = APP.rt = Listmap.create(config);
|
var rt = APP.rt = Listmap.create(config);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user