# Why is $e_HKGe_H$ isomorphic to the algebra of functions $G\to K$ constant on $(H,H)$-double cosets?

Suppose $H$ is a subgroup of a group $G$, $K$ a field, $|H|$ is invertible in $K$, and $e_H=|H|^{-1}\sum_{h\in H}h\in KG$.

Why is the Hecke algebra $e_HKGe_H$ isomorphic to the algebra of functions $G\to K$ constant on $(H,H)$-double cosets? I know that $KG$ with the usual multiplication is isomorphic to the algebra of functions $G\to K$ under convolution, where the coefficient of an element $g$ in the formal sum in $KG$ is viewed as the value of a function $G\to K$ on that element $g$.

An arbitrary element of $e_HKGe_H$ has form $\sum_{g\in G}a_ge_Hge_H$. If I were to expand this sum, it would be enough to check that elements in the same double cosets have the same coefficients, but it seems difficult to keep track of the coefficients, since a term may be repeated upon expanding.

Conversely, if we have a formal sum where elements in the same $(H,H)$-double cosets have the same coefficient, how can we show it is in $e_HKGe_H$? I thought if $g_1,\dots,g_n$ is a set of $(H,H)$-double coset representatives, then we can write the formal sum as $$a_1\sum_{x\in Hg_1H}x+a_2\sum_{x\in Hg_2H}x+\cdots+a_n\sum_{x\in Hg_nH}x.$$

But it's not clear to me this is expressible as a sum in $e_HKGe_H$. A sum $\sum_{x\in Hg_1H}x$ looks like it's closely related to $e_Hg_1e_H$, but some terms are overcounted.

Let $$A=\sum_{g\in G}a_g g$$ be a typical element of $KG$. I claim that $A\in e_H(KG)e_H$ iff $hA=A=Ah$ for all $h\in H$. This follows from the fact that $he_H=e_H=e_Hh$ for all $h\in H$. In detail if $hA=A$ for all $h\in H$ then adding and averaging gives $e_HA=A$; likewise if $Ah=A$ for all $h\in H$ then $Ae_H=A$ so if both hold then $A=e_HAe_H$. Conversely if $A=e_HBe_H$ then $hA=he_HBe_H=e_HBe_H=A$ etc.
Now $hA=A$ for all $h\in H$ means $a_{hg}=a_g$ for all $h\in H$ and $g\in G$. Likewise Now $Ah=A$ for all $h\in H$ means $a_{gh}=a_g$ for all $h\in H$ and $g\in G$. Thus $A\in e_H(KG)e_H$ iff $g\mapsto a_g$ is constant on all double cosets $HgH$.
The group algebra $KG$ is the same as $\text{Map}(G,K)$ under convolution where $A$ corresponds to the map $g\mapsto a_g$. Then $A\in e_H(KG)e_H$ iff the map $g\mapsto a_g$ is constant on double cosets.