Proximal Oracles for Optimization and Sampling