From d232a5a83ef63adbd190999e839889d7bf69df2b Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 29 Dec 2016 17:51:58 +0100 Subject: [PATCH] Revert "simplify key generation and remember user's additional keys" This reverts commit 75786ff9ffc5d059444645dfb6987a2b5e92c03a. --- www/user/main.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/www/user/main.js b/www/user/main.js index febf1ed07..9c04f8864 100644 --- a/www/user/main.js +++ b/www/user/main.js @@ -254,25 +254,32 @@ define([ // 16 bytes for a deterministic channel key var channelSeed = dispense(16); // 32 bytes for a curve key - var curveSeed = opt.curveSeed = dispense(32); + var curveSeed = dispense(32); // 32 more for a signing key - var edSeed = opt.edSeed = dispense(32); + var edSeed = dispense(32); - // 32 bytes of hex - var channelKey = opt.channel = Cryptpad.uint8ArrayToHex(channelSeed); - - // a bit of a dirty hack to get the same output as we are used to var keys = opt.keys = Crypto.createEditCryptor(null, encryptionSeed); - var editHash = opt.editHash = Cryptpad.getEditHashFromKeys(channelKey, keys); - var secret = Cryptpad.getSecrets(editHash); + // 24 bytes of base64 + keys.editKeyStr = keys.editKeyStr.replace(/\//g, '-'); + + // 32 bytes of hex + opt.channel = Cryptpad.uint8ArrayToHex(channelSeed); + + var channelHex = opt.channel; + + if (channelHex.length !== 32) { throw new Error('invalid channel id'); } + + var channel64 = opt.channel64 = Cryptpad.hexToBase64(channelHex); + + opt.editHash = Cryptpad.getEditHashFromKeys(channelHex, keys.editKeyStr); var config = { websocketURL: Cryptpad.getWebsocketURL(), - channel: channelKey, + channel: channelHex, data: {}, - validateKey: secret.keys.validateKeys, // derived validation key - crypto: Crypto.createEncryptor(secret.keys), + validateKey: keys.validateKey, // derived validation key + crypto: Crypto.createEncryptor(opt.keys), }; var rt = APP.rt = Listmap.create(config);