⚡ Migrate to msgspec structs for faster serialization
Attaching to #3802 and #3803.
We should move away from using JSON dumps and loads in so many places.
When records get passed between different handlers, they get serialized and deserialized over and over again. And using JSON for this is notably inefficient.
I propose using a more efficient library, msgspec, for defining all the models that need serialization and validation.
Most impactful would be for how presentation exchange records get built in the proof flows, because the payloads can be so massive. But, obviously would be great for all record types. This request is mainly for exchange records, because I think it'll yield the biggest bang for buck.
msgspec has excellent benchmarks compared to other libraries - it beats orjson and Pydantic: