Proving $\forall B \in \mathbb{k}^{n\times n} | AB=BA \iff A = cI_n$? I was requested to prove the following:

Let $A \in \mathbb{k}^{n \times n}$ be a matrix over the field $\mathbb{k}$. Then $\forall B \in \mathbb{k}^{n\times n} | AB=BA \iff A = cI_n$ for some $c \in \mathbb{k}$. In other words, show $A$ is conmutative for $\cdot$ with respect to all $B$ iff $A$ is a scaled identity matrix.

I was able to prove $A = cI_n \implies AB=BA$ (for all $B$). This comes rather naturally from observing that
$$\forall i, j \in \mathbb{N} : a_{ij} = \begin{cases}
   c & i = j \\
    0 & i \neq j
\end{cases}$$
Then, by definition,
\begin{align*}
    (AB)_{ij} &= \sum_{k=1}^n a_{ik}b_{kj} \\
    (BA)_{ij} &= \sum_{k = 1}^n b_{ik}a_{kj}
\end{align*}
with
\begin{align}
    \sum_{k=1}^n a_{ik}b_{kj} &= a_{i1}b_{1j} + \cdots + a_{ij}b_{jj} + a_{ii}b_{ij} + \cdots + a_{in}b_{ni} \\
    &= a_{ii}b_{ij}
\end{align}
\begin{align}
    \sum_{k=1}^n b_{ik}a_{kj} &= b_{i1}a_{1j} + \cdots + b_{ij}a_{jj} + b_{ii}a_{ij} + \cdots + b_{in}a_{ni} \\
    &= b_{ij}a_{jj}
\end{align}
because every term where $k \neq i$ has $a_{ik} = 0$, and $k=i$ on a single term of the sum.
Then, from our initial observation (and the fact that $\mathbb{k}$ is a field), it follows that $(AB)_{ij} = cb_{ij} = b_{ij}c = (BA)_{ij}$, which means $AB = BA$.
However, proving $AB=BA$ for all $B$ implies $A = cI_n$ is not equally simple. I tried to use the fact that the first demonstration is equivalent to
\begin{equation}
    (cI_n)B=c(I_nB) = (cB)I_n
\end{equation}
to advance in the proof, with little success. I was then given the following hint:

Notice that if $AB=BA$ for all $B$, then in particular it is conmutative with some $B$ containing a single $1$ and the rest of the values all $0$. Try for the case where $n=2$.

However, I could not derive from this anything related to $A$ being a scaled identity matrix. Any help will be appreciated.
 A: Consider the matrix $E^{(i,j)}$, which is zero everywhere except the $i$-$j$'th spot in the matrix, i.e.,
$$
(E^{(i,j)})_{nm} = \delta_{in}\delta_{jm}\,.
$$
Since $A$ commutes with everything, it definitely commutes with this matrix.  Use this fact to compute the matrix elements of the product of $A$ and an $E$ in both directions.

 That is, \begin{align}(AE^{(i,j)})_{nm}=\sum_kA_{nk}(E^{(i,j)})_{km}=\sum_kA_{nk}\delta_{ik}\delta_{jm}=A_{ni}\delta_{jm}\,.\end{align} Similarly, \begin{align} (E^{(i,j)}A)_{nm}=\sum_k(E^{(i,j)})_{nk}A_{km}=\sum_k\delta_{in}\delta_{jk}A_{km}=\delta_{in}A_{jm}\,.\end{align}

Use the fact that they are equal to establish that $A$ is diagonal:

These two expressions must then be equal, yielding\begin{align}A_{jm}\delta_{in} = A_{ni}\delta_{jm}\,.\end{align} Now, fix $i\neq n$ independently of $j$ and $m$. Then we can see that $A_{jm}$ must be proportional to $\delta_{jm}$. That is to say, $A$ is clearly diagonal.

Finally, then, we can establish that all the diagonal elements are the same:

At this point, we now know that $A_{mm}\delta_{in} = A_{nn}\delta_{jm}$.  Fixing $i$ not equal to $n$ and $j$ not equal to $m$ allows you to establish that $A_{mm} = A_{nn}$.

Once we know that the matrix is diagonal and that the elements along the diagonal are all the same, then $A=cI$ for some $c$.
A: Let $B$ be the matrix with $B_{ij}=1$ and $0$ elsewhere. $(AB)_{kl}=\sum_{m}A_{km}B_{ml}$. This vanishes when $l\ne j$ as $B_{ml}=0$ in this case. When $l=j$ we get $(AB)_{kj}=\sum_{m}A_{km}B_{mj}=A_{ki}$. Now we multiply in the other order: $(BA)_{kl}=\sum_{m}B_{km}A_{ml}$. This vanishes when $k\ne i$ as $B_{km}=0$ in this case. When $k=i$ $(BA)_{il}=\sum_{m}B_{im}A_{ml}=A_{jl}$. Now these two are in fact equal as $AB=BA$. So $A_{ii}=A_{jj}$, and $A_{ik}=0$ if $i\ne k$.
