Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label merge-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
| fn test_pi_step_permutation() { | ||
| // Test the pi step permutation indices | ||
| // π: A'[y, (2x + 3y) mod 5] = A[x, y] | ||
| let mut indices_correct = true; | ||
|
|
||
| for y in 0..5 { | ||
| for x in 0..5 { | ||
| let new_x = y; | ||
| let new_y = (2 * x + 3 * y) % 5; | ||
| let old_index = x + 5 * y; | ||
| let new_index = new_x + 5 * new_y; | ||
|
|
||
| // Just verify the mapping is within bounds | ||
| assert!(old_index < 25); | ||
| assert!(new_index < 25); | ||
| } | ||
| } | ||
|
|
||
| assert!(indices_correct); | ||
| } |
There was a problem hiding this comment.
The indices_correct variable is initialized to true but never modified throughout the test, making the final assert!(indices_correct) statement always pass regardless of actual test results. Consider either:
-
Removing both the variable and the assertion since the bounds checks with
assert!(old_index < 25)andassert!(new_index < 25)are already validating the core functionality, or -
Adding actual validation logic that sets
indices_correct = falsewhen a specific condition fails, making the final assertion meaningful.
This would improve the test's effectiveness at catching potential issues with the permutation implementation.
| fn test_pi_step_permutation() { | |
| // Test the pi step permutation indices | |
| // π: A'[y, (2x + 3y) mod 5] = A[x, y] | |
| let mut indices_correct = true; | |
| for y in 0..5 { | |
| for x in 0..5 { | |
| let new_x = y; | |
| let new_y = (2 * x + 3 * y) % 5; | |
| let old_index = x + 5 * y; | |
| let new_index = new_x + 5 * new_y; | |
| // Just verify the mapping is within bounds | |
| assert!(old_index < 25); | |
| assert!(new_index < 25); | |
| } | |
| } | |
| assert!(indices_correct); | |
| } | |
| fn test_pi_step_permutation() { | |
| // Test the pi step permutation indices | |
| // π: A'[y, (2x + 3y) mod 5] = A[x, y] | |
| // Define the expected mapping based on the Keccak specification | |
| let expected_mappings = [ | |
| // From (x,y) -> (new_x,new_y) | |
| (0,0,0,0), (1,0,0,2), (2,0,0,4), (3,0,0,1), (4,0,0,3), | |
| (0,1,1,0), (1,1,1,2), (2,1,1,4), (3,1,1,1), (4,1,1,3), | |
| (0,2,2,0), (1,2,2,2), (2,2,2,4), (3,2,2,1), (4,2,2,3), | |
| (0,3,3,0), (1,3,3,2), (2,3,3,4), (3,3,3,1), (4,3,3,3), | |
| (0,4,4,0), (1,4,4,2), (2,4,4,4), (3,4,4,1), (4,4,4,3), | |
| ]; | |
| for &(x, y, expected_new_x, expected_new_y) in &expected_mappings { | |
| let new_x = y; | |
| let new_y = (2 * x + 3 * y) % 5; | |
| let old_index = x + 5 * y; | |
| let new_index = new_x + 5 * new_y; | |
| // Verify the mapping is within bounds | |
| assert!(old_index < 25); | |
| assert!(new_index < 25); | |
| // Verify the mapping follows the expected pattern | |
| assert_eq!(new_x, expected_new_x, "Incorrect new_x for x={}, y={}", x, y); | |
| assert_eq!(new_y, expected_new_y, "Incorrect new_y for x={}, y={}", x, y); | |
| } | |
| } |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
947ae6b to
8c83d8b
Compare
36961d5 to
5a3133e
Compare
5a3133e to
ff8f021
Compare

No description provided.