Abstract:We compute the exact entropy of one-eighth and one-quarter BPS black holes in N = 8 and N = 4 string theory respectively. This includes all the N = 4 CHL models in both K3 and T 4 compactifications. The main result is a measure for the finite dimensional integral that one obtains after localization of supergravity on AdS 2 × S 2 . This measure is determined entirely by an anomaly in supersymmetric Chern-Simons theory on local AdS 3 and takes into account the contribution from all the supergravity multiplets. In Chern-Simons theory on compact manifolds, this is the anomaly that computes a certain one-loop dependence on the volume of the manifold. For one-eighth BPS black holes, our results are a first principles derivation of a measure proposed in arXiv:1111.1161, while in the case of one-quarter BPS black holes our result computes exactly all the perturbative or area corrections. Moreover, we argue that instantonic contributions can be incorporated and give evidence by computing the measure, which matches precisely the microscopics. Along with this, we find a unitary condition that truncates the answer to a finite sum of instantons in perfect agreement with a microscopic formula. Our results therefore solve a number of puzzles related to localization in supergravity and constitute a larger number of examples where holography can be shown to hold exactly.