Next stage of new protocol implementation

Here are two self-contained parts to add to the new protocol implementation, ready for review. [Lots more](https://github.com/special/ricochet/compare/protocol) is written, it just needs the last bits of polish before it's submitted.

The previous PR led to decisions to use smart pointers much more frequently, and to replace error messages in protocol with better enums. Neither of those changes is visible yet here.