Quantum expression for the electrical conductivity of massless quark matter and of the hadron resonance gas in the presence of a magnetic field