diff --git a/keyserver/src/user/login.js b/keyserver/src/user/login.js
--- a/keyserver/src/user/login.js
+++ b/keyserver/src/user/login.js
@@ -6,7 +6,6 @@
 import { getOneTimeKeyValuesFromBlob } from 'lib/shared/crypto-utils.js';
 import { getCommConfig } from 'lib/utils/comm-config.js';
 import { ServerError } from 'lib/utils/errors.js';
-import { values } from 'lib/utils/objects.js';
 
 import {
   saveIdentityInfo,
@@ -15,7 +14,10 @@
 } from './identity.js';
 import { getMessageForException } from '../responders/utils.js';
 import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';
-import { validateAccountPrekey } from '../utils/olm-utils.js';
+import {
+  getAccountPrekeysSet,
+  validateAccountPrekey,
+} from '../utils/olm-utils.js';
 
 type UserCredentials = { +username: string, +password: string };
 
@@ -30,9 +32,7 @@
   const identityKeys = account.identity_keys();
 
   validateAccountPrekey(account);
-  const prekeyMap = JSON.parse(account.prekey()).curve25519;
-  const [prekey] = values(prekeyMap);
-  const prekeySignature = account.prekey_signature();
+  const { prekey, prekeySignature } = getAccountPrekeysSet(account);
 
   if (!prekeySignature || !prekey) {
     throw new ServerError('invalid_prekey');
diff --git a/keyserver/src/utils/olm-utils.js b/keyserver/src/utils/olm-utils.js
--- a/keyserver/src/utils/olm-utils.js
+++ b/keyserver/src/utils/olm-utils.js
@@ -12,6 +12,7 @@
 import { getOneTimeKeyValuesFromBlob } from 'lib/shared/crypto-utils.js';
 import { olmEncryptedMessageTypes } from 'lib/types/crypto-types.js';
 import { ServerError } from 'lib/utils/errors.js';
+import { values } from 'lib/utils/objects.js';
 
 import {
   fetchCallUpdateOlmAccount,
@@ -186,6 +187,16 @@
   return JSON.parse(accountInfo.account.identity_keys()).ed25519;
 }
 
+function getAccountPrekeysSet(account: OlmAccount): {
+  +prekey: string,
+  +prekeySignature: ?string,
+} {
+  const prekeyMap = JSON.parse(account.prekey()).curve25519;
+  const [prekey] = values(prekeyMap);
+  const prekeySignature = account.prekey_signature();
+  return { prekey, prekeySignature };
+}
+
 export {
   createPickledOlmAccount,
   createPickledOlmSession,
@@ -195,4 +206,5 @@
   validateAccountPrekey,
   uploadNewOneTimeKeys,
   getContentSigningKey,
+  getAccountPrekeysSet,
 };