  The model for the generation of magnetic fields in a neutron star, based on
the magnetic field instability caused by the electroweak interaction between
electrons and nucleons, is developed. Using the methods of the quantum field
theory, the helicity flip rate of electrons in their scattering off protons in
dense matter of a neutron star is calculated. The influence of the electroweak
interaction between electrons and background nucleons on the process of the
helicity flip is studied. The kinetic equation for the evolution of the chital
imbalance is derived. The obtained results are applied for the description of
the magnetic fields evolution in magnetars.
