PERF: Reduce the size of private identities

PERF: Reduce the size of private identities

diff --git a/assets/javascripts/lib/protocol_v1.js.es6 b/assets/javascripts/lib/protocol_v1.js.es6
index 503ba38..ddc5e0b 100644
--- a/assets/javascripts/lib/protocol_v1.js.es6
+++ b/assets/javascripts/lib/protocol_v1.js.es6
@@ -87,36 +87,26 @@ export function generateIdentity() {
 }
 
 export function exportIdentity(identity, passphrase) {
-  const identityPromise = Ember.RSVP.Promise.all([
+  const publicPromise = Ember.RSVP.Promise.all([
     window.crypto.subtle.exportKey("jwk", identity.encryptPublic),
+    window.crypto.subtle.exportKey("jwk", identity.signPublic)
+  ])
+    .then(([encryptPublic, signPublic]) => ({ encryptPublic, signPublic }))
+    .then(exported =>
+      bufferToBase64(textEncoder.encode(JSON.stringify(exported)))
+    );
+
+  let privatePromise = Ember.RSVP.Promise.all([
     window.crypto.subtle.exportKey("jwk", identity.encryptPrivate),
-    window.crypto.subtle.exportKey("jwk", identity.signPublic),
     window.crypto.subtle.exportKey("jwk", identity.signPrivate)
-  ]).then(([encryptPublic, encryptPrivate, signPublic, signPrivate]) => ({
-    encryptPublic,
-    encryptPrivate,
-    signPublic,
-    signPrivate
-  }));
-
-  const publicPromise = identityPromise.then(exported =>
-    bufferToBase64(
-      textEncoder.encode(
-        JSON.stringify({
-          encryptPublic: exported.encryptPublic,
-          signPublic: exported.signPublic
-        })
-      )
-    )
-  );
+  ]).then(([encryptPrivate, signPrivate]) => ({ encryptPrivate, signPrivate }));
 
-  let privatePromise;
   if (passphrase) {
     const salt = window.crypto.getRandomValues(new Uint8Array(16));
     const iv = window.crypto.getRandomValues(new Uint8Array(12));
     privatePromise = Ember.RSVP.Promise.all([
       getPassphraseKey(passphrase, salt),
-      identityPromise
+      privatePromise
     ])
       .then(([key, exported]) =>
         window.crypto.subtle.encrypt(
@@ -130,7 +120,7 @@ export function exportIdentity(identity, passphrase) {
           bufferToBase64(salt) + bufferToBase64(iv) + bufferToBase64(exported)
       );
   } else {
-    privatePromise = identityPromise.then(exported =>
+    privatePromise = privatePromise.then(exported =>
       bufferToBase64(textEncoder.encode(JSON.stringify(exported)))
     );
   }
@@ -167,7 +157,7 @@ export function importIdentity(identity, passphrase, extractable) {
     return Ember.RSVP.Promise.all([
       window.crypto.subtle.importKey(
         "jwk",
-        identity.encryptPublic,
+        identity.encryptPrivate || identity.encryptPublic,
         { name: "RSA-OAEP", hash: { name: "SHA-256" } },
         !!extractable,
         ["encrypt", "wrapKey"]
@@ -183,7 +173,7 @@ export function importIdentity(identity, passphrase, extractable) {
         : undefined,
       window.crypto.subtle.importKey(
         "jwk",
-        identity.signPublic,
+        identity.signPrivate || identity.signPublic,
         { name: "RSA-PSS", hash: { name: "SHA-256" } },
         !!extractable,
         ["verify"]

GitHub sha: 838d440a

Revert "PERF: Reduce the size of private identities"