Create binary represented state array (as the initial input to the sponge function (f)) from any length character array (N) with width (b=1600), digest length (d=224) and lane size (w=64) using SHA-3 Standard:
https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
Convert character array to binary representation using UTF-8 value of each character. Output state array will be a matrix with size (5,5,64). Padding in accordance with the standard is required. XOR of the rate bits (r) with the padded message stream is required (see figure 7, page 18). Just the first 1600 bit input to the first function (f) represented as a state array (see section 3.1.2) is required for the output.
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers3
Suggested Problems
-
Back to basics 19 - character types
271 Solvers
-
76 Solvers
-
485 Solvers
-
610 Solvers
-
Find my daddy long leg (No 's')
2716 Solvers
More from this Author61
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
this looks like a very cool problem, perhaps a bit of a summary description of the standard (c.f. 27-page doc) may help make it a bit more enticing for curious but non-crypto-oriented people like myself?
Added some references to the problem description.
I worked many hours on this problem and then eventually gave up and cheated. This challenge isn’t about writing lots of code, it’s about getting the conventions exactly right. Pay close attention to how bits are ordered within each byte (MSB vs. LSB), how the 1600‑bit state is divided into 25 lanes of 64 bits, and how MATLAB’s reshape and transpose affect the mapping. The padding rule (“pad10*1” with the domain suffix) must be applied at the bit level so the final 1 lands in the correct place. If your output looks close but not exact, instrument the first few slices and the last slice — those usually reveal whether your bit order, lane order, or padding is off. Once those three align, everything else falls into place.
Think in bits, not bytes: The harness is checking individual bits, so be very clear about whether you’re treating bytes as MSB‑first or LSB‑first. A single flipped convention will cascade into dozens of mismatches.
Lane mapping matters: The 1600‑bit state is arranged as 25 lanes of 64 bits. Pay attention to how those lanes are ordered (column‑major vs row‑major) and how MATLAB’s reshape fills arrays.
Reshape is your friend: Instead of manually looping over x, y, and z, consider how a clever combination of reshape and transpose can map a flat bitstream into the 5×5×64 state. The harness itself uses reshape tricks, so aligning with that logic is key.
Padding is subtle: The “pad10*1” rule plus the domain separation suffix must be applied at the bit level. Double‑check that the final 1 lands in the correct slice.
Instrument (debugging tools) early: Print out the first few slices (1–4) and the last slice (64). If those line up, the rest usually will too.
Don’t over‑correct: If Case 1 passes but Case 2 fails (or vice versa), resist the urge to swap axes or flip conventions back and forth. The harness is consistent — the trick is to find the one mapping that satisfies both.