Among animals, Homo sapiens is unique in its capacity for widespread cooperation and prosocial behavior among large and genetically heterogeneous groups of individuals. This ultra-sociality figures largely in our success as a species. It is also an enduring evolutionary mystery. There is considerable support for the hypothesis that this facility is a function of our ability to establish, and enforce through sanctions, social norms. Third-party punishment of norm violations ("I punish you because you harmed him") seems especially crucial for the evolutionary stability of cooperation and is the cornerstone of modern systems of criminal justice. In this commentary, we outline some potential cognitive and neural processes that may underlie the ability to learn norms, to follow norms and to enforce norms through third-party punishment. We propose that such processes depend on several domain-general cognitive functions that have been repurposed, through evolution's thrift, to perform these roles.