Extract opaque_keys into a separate library

[LMS-2571]