Cobalt-porphyrin catalyzed electrochemical reduction of carbon dioxide in water. 2. Mechanism from first principles.