  The gauge invariance of the Aharonov-Bohm (AB) effect with a quantum
treatment for the electromagnetic field is demonstrated. We provide an exact
solution for the electromagnetic ground energy due to the interaction of the
quantum electromagnetic field with the classical charges and currents that act
as sources of the potentials in a classical description, in the Lorenz gauge.
Then, we use first-order perturbation theory to compute an extra change on the
electromagnetic ground energy due to the presence of a quantum charged particle
with known wave function in the system. This energy in general depends on the
quantum particle path in an interferometer, what results in an AB phase
difference between the paths. The gauge invariance of this AB phase difference
is then shown for the magnetic, electric, and the recently proposed
electrodynamic versions of the AB effect. However, the AB phase difference
could depend on the gauge for nonclosed paths, what reinforces the view that it
only can be measured in closed paths.
