The origin of the magnetic fields in white dwarfs