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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//! Extendable Output Functions (XOF) for variable-length cryptographic output.
//!
//! 用于可变长度密码输出的可扩展输出函数 (XOF)。
//!
//! ## Overview | 概述
//!
//! Extendable Output Functions (XOFs) are cryptographic functions that can produce
//! output of any desired length. Unlike traditional hash functions with fixed output
//! sizes, XOFs can generate arbitrarily long pseudorandom sequences from input data.
//!
//! 可扩展输出函数 (XOF) 是可以产生任何所需长度输出的密码函数。
//! 与具有固定输出大小的传统哈希函数不同,XOF 可以从输入数据生成任意长的伪随机序列。
//!
//! ## Use Cases | 使用场景
//!
//! - **Key Derivation**: Generate keys of specific lengths
//! - **Random Number Generation**: Produce cryptographically secure random data
//! - **Stream Ciphers**: Create keystreams for encryption
//! - **Mask Generation**: Generate masks for cryptographic protocols
//! - **Domain Separation**: Create distinct outputs for different contexts
//!
//! - **密钥派生**: 生成特定长度的密钥
//! - **随机数生成**: 产生密码学安全的随机数据
//! - **流密码**: 为加密创建密钥流
//! - **掩码生成**: 为密码协议生成掩码
//! - **域分离**: 为不同上下文创建不同的输出
//!
//! ## SHAKE Algorithm Family | SHAKE 算法族
//!
//! SHAKE functions are based on the Keccak sponge construction (same as SHA-3)
//! but with extendable output capability:
//!
//! SHAKE 函数基于 Keccak 海绵构造(与 SHA-3 相同),但具有可扩展输出能力:
//!
//! | Algorithm | Security Level | Rate | Capacity | Use Case |
//! |-----------|----------------|------|----------|----------|
//! | SHAKE-128 | 128-bit | 1344 bits | 256 bits | General purpose |
//! | SHAKE-256 | 256-bit | 1088 bits | 512 bits | High security |
//!
//! ## Security Properties | 安全属性
//!
//! - **Pseudorandomness**: Output is indistinguishable from random
//! - **Collision Resistance**: Infeasible to find two inputs with same output
//! - **Preimage Resistance**: Given output, infeasible to find input
//! - **Domain Separation**: Different contexts produce independent outputs
//!
//! - **伪随机性**: 输出与随机数据无法区分
//! - **抗碰撞性**: 找到具有相同输出的两个输入在计算上不可行
//! - **原像抗性**: 给定输出,找到输入在计算上不可行
//! - **域分离**: 不同上下文产生独立的输出
use crate;
/// Extendable Output Function algorithm enumeration.
///
/// 可扩展输出函数算法枚举。
///
/// ## Algorithm Selection | 算法选择
///
/// Choose based on your security requirements:
/// - **SHAKE-128**: For general-purpose applications requiring 128-bit security
/// - **SHAKE-256**: For high-security applications requiring 256-bit security
///
/// 根据您的安全要求选择:
/// - **SHAKE-128**: 用于需要 128 位安全性的通用应用
/// - **SHAKE-256**: 用于需要 256 位安全性的高安全性应用
/// SHAKE algorithm variants with different security levels.
///
/// 具有不同安全级别的 SHAKE 算法变体。
///
/// ## Performance vs Security | 性能与安全性
///
/// SHAKE-128 offers better performance while SHAKE-256 provides higher security.
/// Both are suitable for most applications, with the choice depending on
/// specific security requirements.
///
/// SHAKE-128 提供更好的性能,而 SHAKE-256 提供更高的安全性。
/// 两者都适用于大多数应用,选择取决于特定的安全要求。
/// Builder for constructing XOF algorithm instances.
///
/// 用于构建 XOF 算法实例的构建器。
///
/// ## Usage Pattern | 使用模式
///
/// ```rust
/// use seal_crypto_wrapper::algorithms::xof::XofAlgorithm;
///
/// // For general-purpose applications
/// let shake128 = XofAlgorithm::build().shake128();
///
/// // For high-security applications
/// let shake256 = XofAlgorithm::build().shake256();
/// ```
///
/// ## Performance Considerations | 性能考虑
///
/// SHAKE-128 is faster due to its higher rate (more data processed per round),
/// while SHAKE-256 provides higher security at the cost of some performance.
///
/// SHAKE-128 由于其更高的速率(每轮处理更多数据)而更快,
/// 而 SHAKE-256 以一些性能为代价提供更高的安全性。
;
use crateXofWrapper;