Traditional derivation of photon momentum $p=h/\lambda$ is suspect? Taking that the energy of a photon is $E = hf$, plugging into the energy-momentum relation yields
$$(hf)^2 = (mc^2)^2 + (pc)^2\\
p = \frac{h}{\lambda}
$$
Was this operation valid? 
I ask because $E = hf$ is also the energy of a particle with mass (which we take to be a quantum of some matter wave of frequency $f$ and wavelength $\lambda$). $h/\lambda$ is the momentum of each quanta of the matter wave (these are the de Broglie equations). Yet if you try plugging in $hf$ of particle with mass into the above energy-momentum equation, you wont get the usual $p = h/\lambda$ since the mass is nonzero.  
Therefore, was finding $p = h/\lambda$ for the photon even valid if it's not valid for matter quanta? If it's not valid, was the result just a coincidence? 
 A: @Coopercape is almost right, but it all works so it that de Broglie's relation with $E$ dependent on $f$ and $p$ on $\lambda$ is still right. The $m$ in the equation is in fact the rest mass, so that $f\lambda$ is not $c$ for matter waves, or any waves other than those from massless particles. I'll explain a bit more below. 
The relationship $E^2 = (pc)^2 + (mc^2)^2$, which is fully valid in special relativity gives the energy as the sum of a kinetic energy ($=pc$) and the rest mass energy ($mc^2$ with $m$ being the particle's rest mass). Notice that in relativity (actually both special and general) the rest mass term includes the particle's potential energy due to internal forces. 
You can write the equation in terms of $f$ and wavelength $\lambda$ as 
$$(hf)^2 = (hc/\lambda)^2 + (mc^2)^2$$
with $E = hf$ and $p= h/\lambda$.
This actually holds for all particles and systems, in special relativity. In general relativity you have to insert the other off-diagonal metric terms and it's a little more complex but still straightforward. 
Notice that f is no longer equal to $c/\lambda$, unless the rest mass $m$ is zero. The relationship of $f$ and $\lambda$ depends on $m$, i.e., the mass of the particle. Only for $m=0$ is $f\lambda=c$. The relationship between f and $\lambda$ in general is called the dispersion relation. With $\omega = 2\pi f$, and k = $2\pi$/$\lambda$ one gets a simple relation if one sets natural units with $2\pi h$ = c = 1, 
$$\omega^2 = k^2 + m^2$$
with $m$ still the rest mass. This is called the wave's dispersion relations.
It is well understood in physics. 
See the Wikipedia article in the section Matter Waves. https://en.m.wikipedia.org/wiki/Energy_momentum_relation
See also about dispersion relations in general at https://en.m.wikipedia.org/wiki/Dispersion_relation
A: Unfortunately this only works for particles moving at light speed. The equation$$E = hf$$is correct however the energy this gives is the Kinetic Energy. The relationship between the energy given from $E^2 = (m_0c^2)^2 +(pc)^2$ and the energy given from $KE = hf$ is that $$KE = mc^2 - m_0c^2$$where $m_0$ is the rest mass. As particles such as photons can be said to have $0$ rest mass, this can be reduced to $$KE = mc^2 = pc = E$$and as such the two energies are equal, allowing the substitution to take place.
For particles that do have a rest mass you will find that this doesn't work. Hope this helps :)
