New primitives for convex optimization and graph algorithms