bakery: implement key marshaling

We change the types of keys so that they can both use the same
marshaling and unmarshaling code.

This is an API-breaking change.