decrypt

Function decrypt 

Source
pub fn decrypt<const W: usize, const H: usize>(
    input: EncryptedData<W, H>,
) -> Result<DecryptedData, GridError>
Expand description

Decrypts a WHY2-encrypted data into raw i64 values.

This function reverses the full WHY2 encryption pipeline using CTR mode:

$$ P_i = C_i \oplus E_K(\text{Nonce} + i) $$

where $E_K$ is the WHY2 block cipher and $i$ is the block counter.

  • Generates round keys from the master key
  • Applies CTR mode decryption (XOR with keystream blocks)

§Parameters

  • input: An EncryptedData struct containing the encrypted grids and key grid.

  • Ok(DecryptedData) struct containing:

    • output: A vector of decrypted i64 values
    • key: The original key Grid flattened into a vector
  • Err(String) if Grid area is 1