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

SMHasher Sparse Test Failure #146

Closed
SchrodingerZhu opened this issue Nov 12, 2022 · 2 comments
Closed

SMHasher Sparse Test Failure #146

SchrodingerZhu opened this issue Nov 12, 2022 · 2 comments

Comments

@SchrodingerZhu
Copy link

SchrodingerZhu commented Nov 12, 2022

I am not an expert of SMHasher --- is this test suite stable? I found the issue when experimenting with the VAES patch, I remember it did pass all the tests but I re-run it several times and it gave a failure on Sparse now.

So I re-test it again with the master branch, I can still get the failure (BTW, I think the output is reasonable: I am not sure why SMHasher thought there was a failure) and the distribution is not the same as the results in the repo:

[schrodinger@schrodinger-superserver build]$ ./SMHasher --test Sparse ahash64
--- Testing ahash64 "ahash 64bit" GOOD

[[[ Keyset 'Sparse' Tests ]]]

Keyset 'Sparse' - 16-bit keys with up to 9 bits set - 50643 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected          0.3, actual      2 (6.70x) (2) !!!!!
Testing collisions (high 19-25 bits) - Worst is 19 bits: 2317/2368 (0.98x)
Testing collisions (low  32-bit) - Expected          0.3, actual      0 (0.00x)
Testing collisions (low  19-25 bits) - Worst is 25 bits: 45/38 (1.18x)
Testing distribution - Worst bias is the 13-bit window at bit 56 - 0.519%

Keyset 'Sparse' - 24-bit keys with up to 8 bits set - 1271626 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected        188.2, actual    176 (0.94x)
Testing collisions (high 24-35 bits) - Worst is 33 bits: 97/94 (1.03x)
Testing collisions (low  32-bit) - Expected        188.2, actual    190 (1.01x) (2)
Testing collisions (low  24-35 bits) - Worst is 34 bits: 52/47 (1.10x)
Testing distribution - Worst bias is the 17-bit window at bit 26 - 0.076%

Keyset 'Sparse' - 32-bit keys with up to 7 bits set - 4514873 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected       2372.2, actual   2418 (1.02x) (46)
Testing collisions (high 25-38 bits) - Worst is 37 bits: 89/74 (1.20x)
Testing collisions (low  32-bit) - Expected       2372.2, actual   2321 (0.98x)
Testing collisions (low  25-38 bits) - Worst is 38 bits: 47/37 (1.27x)
Testing distribution - Worst bias is the 19-bit window at bit 28 - 0.033%

Keyset 'Sparse' - 40-bit keys with up to 6 bits set - 4598479 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected       2460.8, actual   2496 (1.01x) (36)
Testing collisions (high 25-38 bits) - Worst is 36 bits: 166/153 (1.08x)
Testing collisions (low  32-bit) - Expected       2460.8, actual   2597 (1.06x) (137)
Testing collisions (low  25-38 bits) - Worst is 38 bits: 47/38 (1.22x)
Testing distribution - Worst bias is the 19-bit window at bit  2 - 0.061%

Keyset 'Sparse' - 48-bit keys with up to 6 bits set - 14196869 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected      23437.8, actual  23312 (0.99x) (-125)
Testing collisions (high 27-42 bits) - Worst is 41 bits: 48/45 (1.05x)
Testing collisions (low  32-bit) - Expected      23437.8, actual  23623 (1.01x) (186)
Testing collisions (low  27-42 bits) - Worst is 35 bits: 3028/2932 (1.03x)
Testing distribution - Worst bias is the 20-bit window at bit 25 - 0.021%

Keyset 'Sparse' - 56-bit keys with up to 5 bits set - 4216423 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected       2069.0, actual   2087 (1.01x) (19)
Testing collisions (high 25-38 bits) - Worst is 32 bits: 2087/2068 (1.01x)
Testing collisions (low  32-bit) - Expected       2069.0, actual   2171 (1.05x) (103)
Testing collisions (low  25-38 bits) - Worst is 36 bits: 149/129 (1.15x)
Testing distribution - Worst bias is the 19-bit window at bit 52 - 0.054%

Keyset 'Sparse' - 64-bit keys with up to 5 bits set - 8303633 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected       8021.7, actual   7959 (0.99x) (-62)
Testing collisions (high 26-40 bits) - Worst is 40 bits: 33/31 (1.05x)
Testing collisions (low  32-bit) - Expected       8021.7, actual   8031 (1.00x) (10)
Testing collisions (low  26-40 bits) - Worst is 40 bits: 36/31 (1.15x)
Testing distribution - Worst bias is the 20-bit window at bit 52 - 0.044%

Keyset 'Sparse' - 72-bit keys with up to 5 bits set - 15082603 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected      26451.8, actual  26517 (1.00x) (66)
Testing collisions (high 27-42 bits) - Worst is 38 bits: 429/413 (1.04x)
Testing collisions (low  32-bit) - Expected      26451.8, actual  26388 (1.00x) (-63)
Testing collisions (low  27-42 bits) - Worst is 42 bits: 30/25 (1.16x)
Testing distribution - Worst bias is the 20-bit window at bit 20 - 0.028%

Keyset 'Sparse' - 96-bit keys with up to 4 bits set - 3469497 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected       1401.0, actual   1394 (1.00x) (-6)
Testing collisions (high 25-38 bits) - Worst is 38 bits: 28/21 (1.28x)
Testing collisions (low  32-bit) - Expected       1401.0, actual   1402 (1.00x) (2)
Testing collisions (low  25-38 bits) - Worst is 38 bits: 23/21 (1.05x)
Testing distribution - Worst bias is the 19-bit window at bit 50 - 0.051%

Keyset 'Sparse' - 160-bit keys with up to 4 bits set - 26977161 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected      84546.1, actual  84600 (1.00x) (54)
Testing collisions (high 28-44 bits) - Worst is 38 bits: 1355/1323 (1.02x)
Testing collisions (low  32-bit) - Expected      84546.1, actual  84609 (1.00x) (63)
Testing collisions (low  28-44 bits) - Worst is 41 bits: 170/165 (1.03x)
Testing distribution - Worst bias is the 20-bit window at bit  1 - 0.011%

Keyset 'Sparse' - 256-bit keys with up to 3 bits set - 2796417 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected        910.2, actual    891 (0.98x)
Testing collisions (high 25-37 bits) - Worst is 37 bits: 34/28 (1.20x)
Testing collisions (low  32-bit) - Expected        910.2, actual    823 (0.90x)
Testing collisions (low  25-37 bits) - Worst is 37 bits: 36/28 (1.27x)
Testing distribution - Worst bias is the 19-bit window at bit 32 - 0.065%

Keyset 'Sparse' - 512-bit keys with up to 3 bits set - 22370049 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected      58155.4, actual  58078 (1.00x) (-77)
Testing collisions (high 28-43 bits) - Worst is 42 bits: 63/56 (1.11x)
Testing collisions (low  32-bit) - Expected      58155.4, actual  58143 (1.00x) (-12)
Testing collisions (low  28-43 bits) - Worst is 32 bits: 58143/58155 (1.00x)
Testing distribution - Worst bias is the 20-bit window at bit 51 - 0.016%

Keyset 'Sparse' - 1024-bit keys with up to 2 bits set - 524801 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected         32.1, actual     31 (0.97x)
Testing collisions (high 22-32 bits) - Worst is 23 bits: 16089/16079 (1.00x)
Testing collisions (low  32-bit) - Expected         32.1, actual     38 (1.19x) (6)
Testing collisions (low  22-32 bits) - Worst is 32 bits: 38/32 (1.19x)
Testing distribution - Worst bias is the 16-bit window at bit 14 - 0.147%

Keyset 'Sparse' - 2048-bit keys with up to 2 bits set - 2098177 keys
Testing collisions ( 64-bit) - Expected    0.0, actual      0 (0.00x)
Testing collisions (high 32-bit) - Expected        512.4, actual    516 (1.01x) (4)
Testing collisions (high 24-36 bits) - Worst is 36 bits: 37/32 (1.16x)
Testing collisions (low  32-bit) - Expected        512.4, actual    524 (1.02x) (12)
Testing collisions (low  24-36 bits) - Worst is 34 bits: 156/128 (1.22x)
Testing distribution - Worst bias is the 18-bit window at bit 47 - 0.080%

*********FAIL*********


Input vcode 0x00000001, Output vcode 0x00000001, Result vcode 0x00000001
Verification value is 0x00000001 - Testing took 33.405503 seconds
@tkaitchuck
Copy link
Owner

The test which is failing here is with inputs of 16 bits in length with 9 bits being 1s. (I am not sure why such short input would even be using the vectorized path). Never the less 32 or the 64bits are colliding. I suspect that the issue is one too few aes rounds is being run, and last input is only half defused

@tkaitchuck
Copy link
Owner

Resolved in 0.8.4

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

2 participants