Refactor to use external ring/ring-codec library