1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
This is part of WHY2
Copyright (C) 2022-2026 Václav Šmejkal
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! # REX Types
//!
//! This module defines the high-level data containers used for exchanging data
//! throughout the encryption and decryption pipeline. It includes structures for
//! holding ciphertext, keys, and nonces in a type-safe manner.
use ;
use crate::
;
/// Container for encrypted output.
///
/// This struct holds the encrypted Grid chunks, the key Grid and the IV used during encryption.
/// It is returned by [`encrypt`](crate::encrypter::encrypt) and consumed by
/// [`decrypt`](crate::decrypter::decrypt) to reverse the transformation.
///
/// # Fields
/// - `output`: A vector of encrypted [`Grid`]`<W, H>` chunks.
/// - `key`: The key [`Grid`] used for encryption and required for decryption.
/// - `nonce`: The nonce used for CTR mode.
///
/// # Security Notes
/// - The `key` field is provided as a convenience for the encrypt/decrypt round-trip.
/// It is **not** intended for serialization or transmission alongside ciphertext.
/// When persisting or transmitting encrypted data, always store the key separately
/// and reconstruct [`EncryptedData`] manually before decryption.
,
const H: usize = ,
>
/// Container for decrypted output.
///
/// This struct holds the final data and the original key used during decryption.
/// It is returned by [`decrypt`](crate::decrypter::decrypt) and may be used to reconstruct
/// the original string or binary payload.
///
/// # Fields
/// - `output`: A flat vector of decrypted `i64` values.
/// - `key`: The original key used for decryption, stored as a flat vector.
///
/// # Notes
/// - Padding is removed before populating `output`.
/// - The key is flattened for portability and auditability.