| ... | @@ -316,56 +316,6 @@ fn addLanesAll( | ... | @@ -316,56 +316,6 @@ fn addLanesAll( |
| 316 | } | 316 | } |
| 317 | } | 317 | } |
| 318 | | 318 | |
| 319 | /// Apply Keccak-p[1600,12] to a single state (u64 lane representation) | | |
| 320 | fn keccakPLanes(lanes: *[25]u64) void { | | |
| 321 | @setEvalBranchQuota(10000); | | |
| 322 | | | |
| 323 | // Apply 12 rounds | | |
| 324 | inline for (RC) |rc| { | | |
| 325 | // θ | | |
| 326 | var C: [5]u64 = undefined; | | |
| 327 | inline for (0..5) |x| { | | |
| 328 | C[x] = lanes[x] ^ lanes[x + 5] ^ lanes[x + 10] ^ lanes[x + 15] ^ lanes[x + 20]; | | |
| 329 | } | | |
| 330 | var D: [5]u64 = undefined; | | |
| 331 | inline for (0..5) |x| { | | |
| 332 | D[x] = C[(x + 4) % 5] ^ std.math.rotl(u64, C[(x + 1) % 5], 1); | | |
| 333 | } | | |
| 334 | inline for (0..5) |x| { | | |
| 335 | inline for (0..5) |y| { | | |
| 336 | lanes[x + 5 * y] ^= D[x]; | | |
| 337 | } | | |
| 338 | } | | |
| 339 | | | |
| 340 | // ρ and π | | |
| 341 | var current = lanes[1]; | | |
| 342 | var px: usize = 1; | | |
| 343 | var py: usize = 0; | | |
| 344 | inline for (0..24) |t| { | | |
| 345 | const next_y = (2 * px + 3 * py) % 5; | | |
| 346 | const next_idx = py + 5 * next_y; | | |
| 347 | const temp = lanes[next_idx]; | | |
| 348 | const rot_amount = ((t + 1) * (t + 2) / 2) % 64; | | |
| 349 | lanes[next_idx] = std.math.rotl(u64, current, @as(u6, @intCast(rot_amount))); | | |
| 350 | current = temp; | | |
| 351 | px = py; | | |
| 352 | py = next_y; | | |
| 353 | } | | |
| 354 | | | |
| 355 | // χ | | |
| 356 | inline for (0..5) |y| { | | |
| 357 | const idx = 5 * y; | | |
| 358 | const T = [5]u64{ lanes[idx], lanes[idx + 1], lanes[idx + 2], lanes[idx + 3], lanes[idx + 4] }; | | |
| 359 | inline for (0..5) |x| { | | |
| 360 | lanes[idx + x] = T[x] ^ (~T[(x + 1) % 5] & T[(x + 2) % 5]); | | |
| 361 | } | | |
| 362 | } | | |
| 363 | | | |
| 364 | // ι | | |
| 365 | lanes[0] ^= rc; | | |
| 366 | } | | |
| 367 | } | | |
| 368 | | | |
| 369 | /// Generic non-allocating TurboSHAKE: write output to provided buffer | 319 | /// Generic non-allocating TurboSHAKE: write output to provided buffer |
| 370 | fn turboShakeMultiSliceToBuffer( | 320 | fn turboShakeMultiSliceToBuffer( |
| 371 | comptime rate: usize, | 321 | comptime rate: usize, |