Skip to content

Add beamish-2#895

Closed
jadnohra wants to merge 2 commits into08-29-beamishfrom
09-01-beamish-2
Closed

Add beamish-2#895
jadnohra wants to merge 2 commits into08-29-beamishfrom
09-01-beamish-2

Conversation

@jadnohra
Copy link
Copy Markdown
Contributor

@jadnohra jadnohra commented Sep 1, 2025

No description provided.

Copy link
Copy Markdown
Contributor Author

jadnohra commented Sep 1, 2025

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.
Learn more


How to use the Graphite Merge Queue

Add 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.

@jadnohra jadnohra mentioned this pull request Sep 1, 2025
Comment thread crates/beamish/examples/keccak.rs Outdated
Comment on lines +587 to +606
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);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Removing both the variable and the assertion since the bounds checks with assert!(old_index < 25) and assert!(new_index < 25) are already validating the core functionality, or

  2. Adding actual validation logic that sets indices_correct = false when a specific condition fails, making the final assertion meaningful.

This would improve the test's effectiveness at catching potential issues with the permutation implementation.

Suggested change
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

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@jadnohra jadnohra force-pushed the 09-01-beamish-2 branch 5 times, most recently from 947ae6b to 8c83d8b Compare September 2, 2025 09:41
@jadnohra jadnohra mentioned this pull request Sep 2, 2025
@jadnohra jadnohra force-pushed the 09-01-beamish-2 branch 10 times, most recently from 36961d5 to 5a3133e Compare September 3, 2025 09:42
This was referenced Sep 3, 2025
@jadnohra jadnohra closed this Sep 7, 2025
@jimpo jimpo deleted the 09-01-beamish-2 branch November 21, 2025 20:57
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

Successfully merging this pull request may close these issues.

1 participant