It is possible that I haven't studied your code thoroughly, but it appears that you don't perform "Preferred Serialization" or "Deterministic Encoding". This may be a future request since it is currently in the IETF for standardization:
https://datatracker.ietf.org/doc/draft-ietf-cbor-cde/
It's funny you should mention this. I just ran into this problem using SwiftCBOR - it was inconsistently serializing maps which was causing problems with a message signing protocol.
Hello, You mention using https://cbor.me as a reference.
It is possible that I haven't studied your code thoroughly, but it appears that you don't perform "Preferred Serialization" or "Deterministic Encoding". This may be a future request since it is currently in the IETF for standardization: https://datatracker.ietf.org/doc/draft-ietf-cbor-cde/
I have implemented this for JavaScript: https://github.com/cyberphone/CBOR.js#cborjs