Subject: [Cbor] Interactions of packed CBOR and tags

From: Jim Schaad <[email-masked]>
Date: Thu, 27 Aug 2020 14:00:48 -0700

While building a test library of strings for evaluating my algorithm, I
ended up with a question of how tags interact with the idea of CBOR packing.
Specifically, if I use a standard date/time string with tag 0, should that
text string be considered as a candidate for packing?

0("1970-01-01T00:00Z") could potentially be compressed to 0(simple(3))

The problem is that this is no longer a valid CBOR encoding so it would not
seem to be a legal thing to do.

Question:  Must packed CBOR be valid CBOR or does that requirement only
apply to unpacked CBOR?

Jim

---

From: Carsten Bormann <[email-masked]>
Date: Thu, 27 Aug 2020 23:32:19 +0200

> On 2020-08-27, at 23:00, Jim Schaad <[email-masked]> wrote:
> 

Great question.

The cop-out could be: either.
Since CBOR-valid packed CBOR is a subset of (just well-formed) packed CBOR, it could be a parameter given to the compressor whether that is allowed to use compression opportunities like the above or not.

What are the benefits/drawbacks:

* (just well-formed) packed CBOR may lead to trouble with a generic decoder that cannot handle (present to the application) invalid constructs like 0(simple(3)).
The application can decide whether it wants to live with this limitation or not.

* the structural coherence of the packed structure (that this draft is about) will be expressed as a validity constraint.  It is a bit weird to then relax validity of what goes in there, but not entirely without precedent (e.g., tag 24, even though there is a more explicit firewall here).

* not using those compression opportunities can be wasteful, not just for the example given above (tag 0), but also for tags like 32.

I think I would emphasize the (just well-formed) packed CBOR, but still introduce CBOR-valid packed CBOR as a selectable additional constraint for applications that need to work with pre-packed (designed before packed was invented) generic decoders.

Do we need to encode this selection?  (E.g., via different top-level tags.)  Probably not.

Grüße, Carsten

---

From: Jim Schaad <[email-masked]>
Date: Thu, 27 Aug 2020 16:26:14 -0700

-----Original Message-----
From: Carsten Bormann <[email-masked]> 
Sent: Thursday, August 27, 2020 2:32 PM
To: Jim Schaad <[email-masked]>
Cc: [email-masked]; [email-masked]
Subject: Re: [Cbor] Interactions of packed CBOR and tags

> While building a test library of strings for evaluating my algorithm, 
> I ended up with a question of how tags interact with the idea of CBOR packing.
> Specifically, if I use a standard date/time string with tag 0, should 
> that text string be considered as a candidate for packing?
> 
> The problem is that this is no longer a valid CBOR encoding so it 
> would not seem to be a legal thing to do.
> 
> Question:  Must packed CBOR be valid CBOR or does that requirement 
> only apply to unpacked CBOR?

Great question.

[JLS] Yes I agree that only requiring that the result be well-formed makes the most sense.  It probably makes sense to discuss the implications in the document.  A more interesting case might be tag 26 which could have duplicate or prefix lines of text coming up frequently.

I think it might make sense to reference tag 25 and say that this does the same thing only much better.
[/JLS]

[JLS] I don't think that there needs to be different top-level tags.  

Jim

Grüße, Carsten