The chemistry of multiply deuterated species in cold, dense interstellar cores