code: def _calc_key(auth_key, msg_key, client):
          
          x = 0 if client else 8
          sha256a = sha256(msg_key + auth_key[x: x + 36]).digest()
          sha256b = sha256(auth_key[x + 40:x + 76] + msg_key).digest()
  
          aes_key = sha256a[:8] + sha256b[8:24] + sha256a[24:32]
          aes_iv = sha256b[:8] + sha256a[8:24] + sha256b[24:32]
  
          return aes_key, aes_iv
docs: Calculate the key based on Telegram guidelines for MTProto 2,
          specifying whether it's the client or not. See
          https://core.telegram.org/mtproto/description#defining-aes-key-and-initialization-vector