Skip to content

Instantly share code, notes, and snippets.

View s6nqou's full-sized avatar

Searoc s6nqou

View GitHub Profile
@s6nqou
s6nqou / keccak-256.wgsl
Last active December 18, 2024 05:03
Keccak-256 WebGPU Hashing
@group(0) @binding(0) var<storage, read> input: array<u32>;
@group(0) @binding(1) var<storage, read> input_size: u32;
@group(0) @binding(2) var<storage, read_write> output: array<u32, 8>;
const digest_byte_size: u32 = 256 / 8;
const digest_u32_size = digest_byte_size / 4;
fn round(state: ptr<function, array<u32, 50>>, index: u32) {
var P: array<u32, 24> = array<u32, 24> (10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1);
var R: array<u32, 24> = array<u32, 24> (1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44);