diff --git a/libloki/crypto.js b/libloki/crypto.js index 436f8d9ea..dfaaf78e4 100644 --- a/libloki/crypto.js +++ b/libloki/crypto.js @@ -49,7 +49,7 @@ async encrypt(plaintext) { const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); if (!myKeyPair) { - throw new Error("Failed to get keypair for encryption"); + throw new Error('Failed to get keypair for encryption'); } const myPrivateKey = myKeyPair.privKey; const symmetricKey = libsignal.Curve.calculateAgreement( @@ -67,7 +67,7 @@ async decrypt(ivAndCiphertext) { const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); if (!myKeyPair) { - throw new Error("Failed to get keypair for decryption"); + throw new Error('Failed to get keypair for decryption'); } const myPrivateKey = myKeyPair.privKey; const symmetricKey = libsignal.Curve.calculateAgreement( @@ -176,7 +176,7 @@ const myKeyPair = await textsecure.storage.protocol.getIdentityKeyPair(); if (!myKeyPair) { - throw new Error("Failed to get keypair for pairing signature generation"); + throw new Error('Failed to get keypair for pairing signature generation'); } const signature = await libsignal.Curve.async.calculateSignature( myKeyPair.privKey, @@ -300,10 +300,11 @@ const serverPubKey = new Uint8Array( dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer() ); - const { privKey } = await textsecure.storage.protocol.getIdentityKeyPair(); - if (!privKey) { - throw new Error("Failed to get keypair for token decryption"); + const keyPair = await textsecure.storage.protocol.getIdentityKeyPair(); + if (!keyPair) { + throw new Error('Failed to get keypair for token decryption'); } + const { privKey } = keyPair; const symmetricKey = libsignal.Curve.calculateAgreement( serverPubKey, privKey