Optimal Recovery of Mahalanobis Distance in High Dimension