This paper proposes codes that achieve the fundamental capacity limits of digital fingerprinting subject to mean-squared distortion constraints on the fingerprint embedder and the colluders. We first show that the traditional method of fingerprint decoding by thresholding correlation statistics falls short of this goal: reliable performance is impossible at code rates greater than some value C1 that is strictly less than capacity. To bridge the gap to capacity, a more powerful decoding method is needed. The maximum penalized Gaussian mutual information decoder presented here meets this requirement. Finally, a mathematical framework and a capacity expression for fingerprinting of social networks are presented.