         return _.mapValues(credentialsByType, (credential, typeKey) =>
           credentialType = CredentialType[typeKey]
           uint8Key       = credential
-          return deserializeKey({ credentialType, uint8Key, @searchKeySerializer })
+          return deserializeKey({ credentialType, uint8Key, @cryptoServiceLoader })
         )
 
     hasInitialized: ->

      @cryptoKeyStorageApi = new CryptoKeyStorageApi()
      @searchKeyGenerator  = new SearchKeyGenerator()
      @searchKeySerializer = new SearchKeySerializer()

    # initializes keys if needed.
    ensureCredentialsInitialized: ( notifier = -> ) ->

      setter    : (api) -> api.setClientHashFunction
      stage     : AuthenticationStage.CLIENT_HASH_GEN
      encrypt   : false
      id        : 'CLIENT_HASH_FUNCTION'
    }
  }

  serializeKey = ({ credentialType, uint8Key, cryptoServiceLoader }) ->
    if _.isEmpty(uint8Key)
      return uint8Key
    else if credentialType.encrypt
      cryptoServiceLoader.getObjectCryptoService(credentialType.id, { expectMiss : true })
      .then (cryptoService) =>
        return cryptoService.encryptUint8Array(uint8Key)
    else
      return uint8Key

  deserializeKey = ({ credentialType, uint8Key, cryptoServiceLoader }) ->
    if _.isEmpty(uint8Key)
      return uint8Key
    else if credentialType.encrypt
      cryptoServiceLoader.getObjectCryptoService(credentialType.id, { expectMiss : true })
      .then (cryptoService) =>
        return cryptoService.decryptToUint8Array(BlockCiphertext(uint8Key))
    else
      return uint8Key

