(Nearly) Optimal Algorithms for Private Online Learning in Full-information and Bandit Settings