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

Is the pattern for "hex encoded 256 bit unsigned integer" correct? #556

Open
fvictorio opened this issue Jun 13, 2024 · 0 comments
Open

Comments

@fvictorio
Copy link

The pattern for hex encoded 256 bit unsigned integer doesn't look correct to me:

^0x([1-9a-f]+[0-9a-f]{0,31})|0$

I think there are two problems here. The first one is that the + there means that one million 1s would be a valid value, which is obviously incorrect.

And if the + is removed, there's still a problem, because then the string has a length of at most 32 hex characters, but for a 32-byte value the max length should be 64 hex characters.

I think the right pattern should be:

^0x([1-9a-f][0-9a-f]{0,63})|0$

I don't know why the test for this works fine though. I haven't checked how these tests are executed, and if they validate the patterns somehow.

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