uuid6go-proto
uuid6go-proto copied to clipboard
Possible bug in the absoluteIndexer() function
I suspect that there is a one-bit position error when storing bits in the resulting array, in case of skipping version and variant. I was generating uuid with 24 bit subseconds precision. In the function "func (u *UUIDv7Generator) Next() (uuid UUIDv7)" (file bit_setter.go).
Right before the "retval, u.currentPosition = retval.stack(u.currentPosition, precisitonBytes, u.SubsecondPrecisionLength)" line, I replaced the last 3 values of precisitonBytes slice to 0xff 0xff 0xff.
Before calling the function, the value retval was: 06 16 c2 64 60 00 00 00 00 00 00 00 00 00 00 00 After: 06 16 c2 64 6f fe 1f fe 40 00 00 00 00 00 00 00
In binary (before/after): 00000110 00010110 11000010 01100100 01100000 00000000 00000000 00000000 00000000 00000110 00010110 11000010 01100100 01101111 11111110 00011111 11111110 01000000 The place where version and variant should be located, if I understand the standard correctly (indicated with ones): 00000000 00000000 00000000 00000000 00000000 00000000 11110000 00000000 11000000 Where did your algorithm leave gaps: 00000000 00000000 00000000 00000000 00000000 00000001 11100000 00000001 10000000
Right before "//Adding version data [0111 = 7]" section of code the retval value was: 06 12 c2 64 6f fe 1f fe 40 00 01 01 00 20 9e 43 After: 06 12 c2 64 6f fe 7f fe 80 00 01 01 00 20 9e 43
As you can see the 0x40 value (part of subseconds precision) was overwritten by 0x80. The version value byte is not corrupted due to a matching overwritten bit.