From 6dc7e624d31280cf9b67ec41be0968ff3e0c0551 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 4 Aug 2016 11:25:38 +0100 Subject: [PATCH] Fix device key signing Calculate the signature *before* we add the `signatures` key. --- lib/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index eefe5c6f9..2e1f5e4c5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -349,12 +349,12 @@ function _uploadDeviceKeys(client) { device_id: deviceId, keys: client._deviceKeys, user_id: userId, - signatures: {}, }; + var sig = client._olmDevice.sign(anotherjson.stringify(deviceKeys)); + deviceKeys.signatures = {}; deviceKeys.signatures[userId] = {}; - deviceKeys.signatures[userId]["ed25519:" + deviceId] = - client._olmDevice.sign(anotherjson.stringify(deviceKeys)); + deviceKeys.signatures[userId]["ed25519:" + deviceId] = sig; return client.uploadKeysRequest({ device_keys: deviceKeys,