currently there is a API in api written in PHP accepting JSON and returning JSON.
this is used by iOS to perform key_generation, send_message, view_public_key, save_public_key, etc.
there's no reason to duplicate the effort in utils.php. it would make more sense to just use this API.