[lib] Move id conversion functions to lib
Summary: They will be needed in the client code for state check conversion. There's one change: changed the error thrown from ServerError to just Error. On the keyserver side it's caught and rethrown as a ServerError.
Test Plan: yarn flow-all
Reviewers: kamil, tomek
Reviewed By: tomek
Subscribers: ashoat, atul
Differential Revision: https://phab.comm.dev/D7851