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

Possible bug in the absoluteIndexer() function #11

Open
pda0 opened this issue Oct 17, 2021 · 0 comments
Open

Possible bug in the absoluteIndexer() function #11

pda0 opened this issue Oct 17, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@pda0
Copy link

pda0 commented Oct 17, 2021

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.

@nurked nurked self-assigned this Oct 19, 2021
@nurked nurked added the bug Something isn't working label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants