ietf-wg-uuidrev / rfc4122bis

revision to RFC4122
Other
57 stars 11 forks source link

Typo in UUIDv7 test vector? #17

Closed oittaa closed 1 year ago

oittaa commented 1 year ago

https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#appendix-C.6

There might be a typo in final UUIDv7 test vector.

   -------------------------------
   field      bits    value
   -------------------------------
   unix_ts_ms   48    0x17F22E279B0
   ver           4    0x7
   rand_a       12    0xCC3
   var           2    b10
   rand_b       62    b01, 0x8C4DC0C0C07398F
   -------------------------------
   total       128
   -------------------------------
   final: 017F22E2-79B0-7CC3-98C4-DC0C0C07398F

I think it actually yields 017F22E2-79B0-7CC3-88C4-DC0C0C07398F.

Here's how I generated it simply from Python command line.

hex(0x8C4DC0C0C07398F | 2 << 62 | 0xCC3 << 62 + 2 | 0x7 << 62 + 2 + 12 | 0x17F22E279B0 << 62 + 2 + 12 + 4)
'0x17f22e279b07cc388c4dc0c0c07398f'

For example the version 6 works as expected and matches the result 1EC9414C-232A-6B00-B3C8-9E6BDECED846.

   -----------------------------------------------
   field                 bits    value
   -----------------------------------------------
   time_high              32     0x1EC9414C
   time_mid               16     0x232A
   time_low_and_version   16     0x6B00
   clk_seq_hi_res          8     0xB3
   clock_seq_low           8     0xC8
   node                   48     0x9E6BDECED846
   -----------------------------------------------
   total                 128
   -----------------------------------------------
   final_hex: 1EC9414C-232A-6B00-B3C8-9E6BDECED846
hex(0x9E6BDECED846 | 0xC8 << 48 | 0xB3 << 48 + 8 | 0x6B00 << 48 + 8 + 8 | 0x232A << 48 + 8 + 8 + 16 | 0x1EC9414C << 48 + 8 + 8 + 16 + 16)
'0x1ec9414c232a6b00b3c89e6bdeced846'
oittaa commented 1 year ago

Oh sorry, I didn't notice b01 part for some reason. The following works as expected.

>>> hex(0x8C4DC0C0C07398F | 1 << 60 | 2 << 62 | 0xCC3 << 62 + 2 | 0x7 << 62 + 2 + 12 | 0x17F22E279B0 << 62 + 2 + 12 + 4)
'0x17f22e279b07cc398c4dc0c0c07398f'