Signing data structures the wrong way

https://blog.foks.pub/posts/domain-separation-in-idl/

Signing data structures the right way | The FOKS Blog

When my data structures are messages to be sent over a network, I always start with msgId and msgLen, both fixed width fields.

This solves the message differentiation problem explicitly, makes security and memory management easier, and reduces routing to:

switch(msg.msgId):