  We use optimal mass transport to provide a new proof and a dual formula to
the Moser-Onofri inequality on $\s^2$ in the same spirit as the approach of
Cordero-Erausquin, Nazaret and Villani to the Sobolev inequality and of
Agueh-Ghoussoub-Kang to more general settings. There are however many hurdles
to overcome once a stereographic projection on $\R^2$ is performed: Functions
are not necessarily of compact support, hence boundary terms need to be
evaluated. Moreover, the corresponding dual free energy of the reference
probability density $\mu_2(x)=\frac{1}{\pi(1+|x|^2)^2}$ is not finite on the
whole space, which requires the introduction of a renormalized free energy into
the dual formula. We also extend this duality to higher dimensions and
establish an extension of the Onofri inequality to spheres $\s^n$ with $n\geq
2$. What is remarkable is that the corresponding free energy is again given by
$F(\rho)=-n\rho^{1-\frac{1}{n}}$, which means that both the {\it prescribed
scalar curvature problem} and the {\it prescribed Gaussian curvature problem}
lead essentially to the same dual problem whose extremals are stationary
solutions of the fast diffusion equations.
