Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Sorting map keys in bstr wrapped is expected? #29

Open
kentakayama opened this issue Dec 2, 2024 · 0 comments
Open

[Question] Sorting map keys in bstr wrapped is expected? #29

kentakayama opened this issue Dec 2, 2024 · 0 comments

Comments

@kentakayama
Copy link
Contributor

With core deterministic encoding, the keys in every map MUST be sorted, but does it applied to bstr wrapped maps?
The diag2diag tool doesn't sort them, but I'm not sure whether it behavior is correct.

The keys in every map MUST be sorted in the bytewise lexicographic order of their deterministic encodings.

https://datatracker.ietf.org/doc/html/rfc8949#section-4.2.1-2.3.1

testfiles

  • test.cddl
start = bstr-wrapped-map / zero-one-map
bstr-wrapped-map = bstr .cbor zero-one-map

zero-one-map = {
    ? zero => int,
    ? one => int,
}

zero=0
one=1
  • body.diag
{e'one': 1, e'zero': 0}
  • wrapper.diag
<< ref'body.diag' >>

test commands

Keys are not sorted in bstr wrapped map even with -d option.

$ CBOR_DIAG_CDDL=test.cddl diag2diag.rb -e -d -ae -aref body.diag
{0: 0, 1: 1}
$ CBOR_DIAG_CDDL=test.cddl diag2diag.rb -e -d -ae -aref wrapper.diag
<< {1: 1, 0: 0} >>

my preference

Keys are sorted also in bstr wrapped map.

$ CBOR_DIAG_CDDL=test.cddl diag2diag.rb -e -d -ae -aref body.diag
{0: 0, 1: 1}
$ CBOR_DIAG_CDDL=test.cddl diag2diag.rb -e -d -ae -aref wrapper.diag
<< {0: 0, 1: 1} >>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant