This breaks out the key generation stuff into a separate type. It's cleaner on its own, and it prepares for future stuff.