Spin-currents and non-abelian gauge potentials in electronic systems can be treated by spin-current-density functional theory, whose main input is the exchange-correlation (xc) energy expressed as a functional of spin-currents. Constructing a functional of spin currents that is invariant under U(1)\(\times\)SU(2) transformations is a long-standing challenge. We solve the problem by expressing the energy as a functional of a new variable we call "invariant vorticity". As an illustration we construct the xc energy functional for a two-dimensional electron gas with linear spin-orbit coupling and show that it is proportional to the fourth power of the spin current.