The best solution would be IMHO to look at Twig's implementation of asset, which you can find in:
in the method:
public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
which basically uses the templating.helper.assets service similar to @iamdto's answer:
$url = $this->container->get('templating.helper.assets')->getUrl($path, $packageName, $version);
Or directly use the AssetsExtension service or class respectively.
Yep, using the extension helper of the "asset" twig function is the most secure way. Thanks !!