A Performance-Guided Algorithm for Efficiently Generating Massive S-Boxes Using WGAN-GP
-
摘要: 高效生成具备强密码学特性的S盒始终是分组密码设计的核心挑战。本文提出一种基于梯度惩罚Wasserstein生成对抗网络(WGAN-GP)的大规模S盒高效智能生成算法,设计了融合不可微密码学属性的多目标优化策略,构建了高效的性能评估机制。首先通过对AES S盒施加随机仿射变换,生成具备优异密码学特性的大规模数据集,经归一化后输入判别器;生成器以随机噪声为输入,经神经网络输出伪造S盒送入判别器,由判别器计算两类样本的Wasserstein距离;将生成器输出经后处理得到合法S盒,通过GPU加速的性能评估模块快速计算非线性度(NL)与差分均匀度(DU)并转化为密码学损失。模型通过最大化生成样本在判别器的得分,最小化Wasserstein距离,驱动生成具备更优密码学性能的S盒。训练完成后加载最优生成器模型生成海量S盒候选,按预设阈值(NL>100,DU≤10)筛选,最终对前
1000 个候选样本执行CPU精确计算。实验表明:该算法仅需382分钟即可生成1000 万个S盒,单盒平均生成耗时0.0023 秒;若不采用估计策略,同等规模生成需6520 分钟,效率提升94.2%。筛选后的前1000 个S盒平均NL达104.88,最高值107.5,全部超过100;平均DU为9.50,最低值为8,性能达到或超过现有动态S盒生成算法水平。此外,该算法有效缓解了现有GAN生成离散S盒时存在的训练不稳定、模式崩溃、不可微密码属性难以融入优化目标等问题。Abstract:Objective In modern block ciphers, the substitution box (S-box) is the only nonlinear component, and its cryptographic properties directly determine the resistance of a cryptosystem against linear and differential cryptanalysis. Hence, the efficient generation of S-boxes with strong cryptographic strength remains a central challenge, in which a trade-off among cryptographic quality, generation quantity, and generation efficiency has to be achieved. Conventional methods are classified into algebraic construction, chaos-based construction, and heuristic search. Algebraic methods yield S-boxes with excellent and predictable properties, but their design procedure is complicated and the number and diversity of the generated S-boxes are severely limited. Chaos-based methods produce numerous samples rapidly, yet their nonlinearity is usually inferior and the strict avalanche criterion (SAC) and the bit independence criterion (BIC) are difficult to satisfy simultaneously. Heuristic search methods, including simulated annealing, particle swarm optimization (PSO), and hill climbing, obtain high-performance S-boxes at excessive computational cost, so real-time dynamic application is not supported. Recently, artificial intelligence has opened a new path. Meta-heuristic algorithms still rely on iterative search, reinforcement learning (RL) optimizes masking efficiency rather than direct cryptographic metrics, and generative adversarial network (GAN) based methods, despite incorporating cryptographic properties into the loss of the Wasserstein GAN with gradient penalty (WGAN-GP), achieve a maximum nonlinearity of only about 104. Moreover, the computational overhead of metric evaluation remains the core bottleneck, and training instability, mode collapse, and the difficulty of integrating non-differentiable cryptographic properties into the optimization objective have not been resolved. To address these issues, a performance-guided intelligent S-box generation algorithm based on WGAN-GP is proposed, by which stable training is inherited, non-differentiable cryptographic metrics are directly embedded into the optimization objective, and massive, efficient, and high-strength S-box supply is realized for dynamic cipher systems. Methods The framework follows the logic of "data driving, adversarial learning, performance guidance, and batch generation" and consists of three cooperating modules. In the dataset preparation module, a large-scale dataset is constructed by applying random affine transformations to the standard AES S-box, for which random 8x8 invertible matrices and random 8-bit constant vectors are generated over GF(2) and used to pre- and post-process the original S-box; after normalization, the resulting variants are fed into the discriminator as real samples ( Fig. 1 ). In the adversarial training module, a 256-dimensional noise vector is mapped by the generator to a 256-dimensional floating-point vector through fully connected layers with batch normalization and LeakyReLU, while the discriminator outputs a real-valued score through fully connected layers with LayerNorm, LeakyReLU, and Dropout (Fig. 2 ). The Wasserstein distance is combined with a gradient penalty that enforces Lipschitz continuity by encouraging the gradient norm at sampled points to approach 1, and the penalty weight is set to 10. The adversarial loss of the generator is the negative expectation of the discriminator score. The nonlinearity (NL) of an S-box is defined as the mean of the nonlinearities of its coordinate Boolean functions computed by the Walsh-Hadamard transform (WHT), and the differential uniformity (DU) is the maximum value in the difference distribution table (DDT). The cryptographic loss is the mean squared error between the estimated metrics and the ideal targets, normalized by the maximum nonlinearity of 112 and by 252, the range above the ideal differential uniformity of 4 that corresponds to almost perfect nonlinear (APN) functions; the total loss is a weighted sum with weights of 0.8 and 1.5. During the first 30 warm-up epochs, only the adversarial loss is used, after which the cryptographic loss is smoothly introduced. A post-processing step based on the argsort operation converts the continuous output into a permutation of the integers from 0 to 255, by which bijectivity is guaranteed; the resulting continuous-discrete gap is alleviated by the gradient penalty and by the cryptographic losses computed directly on discrete S-boxes. A GPU-accelerated parallel estimation method based on PyTorch tensor operations is developed to incorporate non-differentiable metrics into training: for NL, an eighth-order Hadamard matrix is precomputed,1024 rows are randomly sampled, and all WHT coefficients are computed concurrently by torch.einsum; for DU, the DDT is constructed by broadcasting, advanced indexing, and torch.scatter_add, and its maximum is taken as the estimate. Python loops are eliminated in both procedures. After training, a two-stage strategy is adopted, in which ten million candidates are generated and rapidly screened by the GPU estimator against thresholds of NL greater than 100 and DU no more than 10, and the exact metrics of the top1000 elite candidates are then computed by a NumPy-based CPU function (Fig. 3 ).Results and Discussions The effectiveness of the algorithm is verified in terms of efficiency, quality, and structural diversity. During training, the loss curves converge smoothly without the severe oscillation common in conventional GAN training, and the estimated cryptographic metrics increase steadily once the performance guidance mechanism takes effect after the warm-up period ( Fig. 4 ). In terms of efficiency, only 382 minutes are required to generate ten million S-boxes, with an average of0.0023 seconds per S-box, whereas6520 minutes are needed without the estimation strategy, so an improvement of 94.2% is achieved (Table 1 ). Scalability is verified on three GPU platforms, on which the per-S-box times are0.0023 ,0.0011 , and0.0004 seconds and the total times are 382, 142, and 67 minutes, confirming that the efficiency originates from the algorithm rather than the hardware (Table 1 ). In terms of quality, the top1000 candidates achieve an average NL of 104.88 with a maximum of 107.5 close to the theoretical maximum of 112, while all values are no less than 100; the mean per-S-box minimum nonlinearity is 102.10 with the worst case of 100.0, the average DU is 9.50 with a minimum of 8, the average SAC deviation is0.0085 , the average BIC-SAC is0.4979 , and the average BIC-nonlinearity is 102.26, indicating excellent diffusion and output bit independence (Table 2 ). The frequency distributions show that a large number of S-boxes are concentrated in high-performance regions, which verifies both effectiveness and mode coverage (Fig. 5 ). Bijectivity is satisfied by all ten million S-boxes, and the estimator is validated on1000 samples, for which the NL error is below 0.5% and the DU estimate matches the exact value for 98% of the samples (Table 2 ). The continuous-discrete gap is examined, and the estimated NL of 104.7 differs from the exact value of 104.88 by only 0.17% while the estimated DU of 9.6 differs from the exact value of 9.50 by only 1.04%, so no inconsistency between training and inference is observed (Fig. 4 ). Unlike AES affine-equivalent S-boxes whose DU is always 4 and whose NL is always 112, the generated S-boxes exhibit an average DU of 9.50 with a minimum of 8 and an average NL of 104.88 with a minimum of 100.0, and their Walsh spectral statistics confirm that genuine exploration rather than memorization is performed by the model (Table 3 ). Existing methods fall into an objective-oriented paradigm and a data-driven paradigm, whose merits cannot be judged solely by identical metrics; the value of this work lies in the massive supply scale and the order-of-magnitude gain in efficiency obtained at the cost of only a minor concession in individual metrics (Table 2 ).Conclusions A performance-guided WGAN-GP framework for massive S-box generation is proposed, by which stable generation is realized, non-differentiable cryptographic properties are directly embedded into the optimization objective, and the bottleneck of metric evaluation is overcome by a GPU-accelerated estimation strategy that improves generation efficiency by 94.2%. A dynamic supply scheme compatible with standard key update protocols is also presented. Ten million S-boxes are generated within 382 minutes with an average of 0.0023 seconds per S-box, and the top1000 exactly evaluated S-boxes achieve an average NL of 104.88 with a maximum of 107.5 and an average DU of 9.50 with a minimum of 8, meeting or exceeding the level of existing dynamic S-box generation algorithms. Meanwhile, training instability, mode collapse, and the difficulty of integrating non-differentiable properties are effectively alleviated. The potential of deep generative learning for cryptography is demonstrated, and the algorithm can be extended to other cryptographic primitives, with applications in lightweight cipher design for the Internet of Things and mobile platforms and in high-security systems where S-boxes are frequently updated to resist side-channel attacks.-
Key words:
- S-box /
- WGAN-GP /
- Nonlinearity /
- Differential Uniformity /
- Estimation Strategy
-
表 1 实验配置关键参数
参数名 取值 Adam优化器学习率 5e-5 总训练轮次 300 训练批次大小 128 噪声向量维度 256 梯度惩罚权重 10 预热期轮次 30 NL损失权重$ {\lambda }_{\text{nl}} $ 0.8 DU损失权重$ {\lambda }_{\text{du}} $ 1.5 NL筛选阈值 >100 DU筛选阈值 ≤10 生成S盒总数 10,000,000 精确评估的S盒数量 1,000 NL估计采样数 1,024 DU估计采样数 1,000 注:$ {\lambda }_{\text{nl}},{\lambda }_{\text{du}} $通过网格搜索确定,以平衡密码性能与训练稳定性。 表 2 生成S盒性能分析
指标名称 平均值 最优值 最差值 平均NL 104.88 107.5 102.2 最小NL 102.10 104.0 100.0 DU 9.50 8 10 SAC偏移 0.0085 0.0005 0.0150 BIC-NL 102.26 103.2 100.5 BIC-SAC 0.4979 0.4983 0.4965 注:最小NL为单个S盒8个输出位的最低非线性度;最差值为前 1000 个样本的最小值。表 3 生成S盒Walsh谱值分析
Walsh谱最大值 AES S盒Walsh谱值 生成S盒Walsh谱值 一千个S盒中最小值 32 44 一千个S盒中最大值 32 76 一千个S盒中平均值 32 54.6 表 4 本算法与其他生成模型及相关工作的性能对比
算法 平均NL 最高NL 最小NL 平均DU 最小DU 平均SAC 平均BIC-NL 效率(个/秒) AES[5] 112 112 112 4 4 0.4949 112 -- 本文算法 104.88 107.5 100.0 9.50 8 0.5005 103.2 436.3 WGAN[26] 103.89 106.5 98.5 10 10 0.5105 102.32 25.56 GAN[22] 102 104.5 96.0 10 10 0.4880 98 23.8 GA[14] 106 108 102 10 8 0.5040 101 0.26 PSO[10] 103.4 106.5 99.0 10 10 0.4990 102.07 19.2 混沌[7]法 103.2 105.25 98.0 10.3 12 0.5070 102.72 22.3 注:最小NL指生成S盒8个输出位的最小非线性度;AES作为理论上界基准,不纳入效率对比。 -
[1] IBRAHIM S and ABBAS A M. A novel optimization method for constructing cryptographically strong dynamic S-boxes[J]. IEEE Access, 2020, 8: 225004–225017. doi: 10.1109/ACCESS.2020.3045260. [2] ISA H, SYED JUNID S A A, Z'ABA M R, et al. Enhancement of non-permutation binomial power functions to construct cryptographically strong S-boxes[J]. Mathematics, 2023, 11(2): 446. doi: 10.3390/math11020446. [3] SOVYN Y, KHOMA V, and PODPORA M. Bitsliced implementation of non-algebraic 8×8 cryptographic S-boxes using ×86–64 processor SIMD instructions[J]. IEEE Transactions on Information Forensics and Security, 2023, 18: 491–500. doi: 10.1109/tifs.2022.3223782. [4] ALAMSYAH. Improving the quality of AES S-box by modifications irreducible polynomial and affine matrix[C]. Proceedings of the 5th International Conference on Informatics and Computing, Gorontalo, Indonesia, 2020: 1–6. doi: 10.1109/ICIC50835.2020.9288567. [5] ALAMSYAH, SETIAWAN A, PUTRA A T, et al. AES S-box modification uses affine matrices exploration for increased S-box strength[J]. Nonlinear Dynamics, 2025, 113(4): 3869–3890. doi: 10.1007/s11071-024-10414-3. [6] HUSSAIN M, BASHIR Z, and MALIK M G A. A dynamic S-box algorithm based on special supersingular elliptic curve[J]. Integration, 2025, 101: 102340. doi: 10.1016/j.vlsi.2024.102340. [7] 李莹. 新型数字域混沌系统的设计及其在S盒构造中的应用研究[D]. [硕士论文], 广东工业大学, 2025. doi: 10.27029/d.cnki.ggdgu.2025.000130.LI Ying. A study on the design of new digital domain chaotic system and its application in S-box construction[D]. [Master dissertation], Guangdong University of Technology, 2025. doi: 10.27029/d.cnki.ggdgu.2025.000130. [8] DUONG P P, NGUYEN H M, DAO B A, et al. S-boxes with optimal strict avalanche criterion using chaotic map[C]. Proceedings of the 9th International Conference on Integrated Circuits, Hanoi, Vietnam, 2024: 85–90. doi: 10.1109/ICDV61346.2024.10616714. [9] KUZNETSOV A, POLUYANENKO N, FRONTONI E, et al. Optimized simulated annealing for efficient generation of highly nonlinear S-boxes[J]. Soft Computing, 2024, 28(5): 3905–3920. doi: 10.1007/s00500-023-09334-y. [10] 陆雅雯, 李正权, 谭立容, 等. 基于遗传粒子群算法的超混沌S盒设计[J]. 江苏大学学报: 自然科学版, 2024, 45(6): 701–708. doi: 10.3969/j.issn.1671-7775.2024.06.011.LU Yawen, LI Zhengquan, TAN Lirong, et al. Hyperchaotic S-box design based on genetic particle swarm algorithm[J]. Journal of Jiangsu University: Natural Science Edition, 2024, 45(6): 701–708. doi: 10.3969/j.issn.1671-7775.2024.06.011. [11] ALHADAWI H S, MAJID M A, LAMBIĆ D, et al. A novel method of s-box design based on discrete chaotic maps and cuckoo search algorithm[J]. Multimedia Tools and Applications, 2021, 80(5): 7333–7350. doi: 10.1007/s11042-020-10048-8. [12] 关杰, 黄俊君. Keccak类S盒的线性性质研究[J]. 电子与信息学报, 2020, 42(7): 1790–1795. doi: 10.11999/JEIT190570.GUAN Jie and HUANG Junjun. Research on linear properties of Keccak-like S-box[J]. Journal of Electronics & Information Technology, 2020, 42(7): 1790–1795. doi: 10.11999/JEIT190570. [13] 冯子曦, 刘玉鹏, 窦国威, 等. 低深度轻量化S盒的优化实现[J]. 电子与信息学报, 2026, 48(4): 1623–1632. doi: 10.11999/JEIT250690.FENG Zixi, LIU Yupeng, DOU Guowei, et al. Optimized implementation of low-depth lightweight S-boxes[J]. Journal of Electronics & Information Technology, 2026, 48(4): 1623–1632. doi: 10.11999/JEIT250690. [14] 黄昭文. 密码S盒的智能搜索与优化方法研究[D]. [硕士论文], 桂林电子科技大学, 2025. doi: 10.27049/d.cnki.ggldc.2025.000936.HUANG Zhaowen. Research on intelligent search and optimization methods for cipher S-boxes[D]. [Master dissertation], Guilin University of Electronic Technology, 2025. doi: 10.27049/d.cnki.ggldc.2025.000936. [15] 陆雅雯, 李正权, 谭立容, 等. 基于遗传粒子群算法的超混沌S盒设计[J]. 江苏大学学报: 自然科学版, 2024, 45(6): 701–708. doi: 10.3969/j.issn.1671-7775.2024.06.011.LU Yawen, LI Zhengquan, TAN Lirong, et al. Hyperchaotic S-box design based on genetic particle swarm algorithm[J]. Journal of Jiangsu University: Natural Science Edition, 2024, 45(6): 701–708. (查阅网上资料, 本条文献与第10条文献重复, 请确认) doi: 10.3969/j.issn.1671-7775.2024.06.011. [16] 程琴琴. 基于智能计算的S盒构造与分析[D]. [硕士学位论文], 电子科技大学, 2023. doi: 10.27005/d.cnki.gdzku.2023.002426.CHENG Qinqin. Construction and analysis of S-box based on intelligent computing[D]. [Master dissertation], University of Electronic Science and Technology of China, 2023. doi: 10.27005/d.cnki.gdzku.2023.002426. [17] KANG Man and WANG Mingsheng. New genetic operators for developing S-boxes with low boomerang uniformity[J]. IEEE Access, 2022, 10: 10898–10906. doi: 10.1109/ACCESS.2022.3144458. [18] ARTUĞER F. A new S-box generator algorithm based on 3D chaotic maps and whale optimization algorithm[J]. Wireless Personal Communications, 2023, 131(2): 835–853. doi: 10.1007/s11277-023-10456-7. [19] LAWAH A I, IBRAHIM A A, SALIH S Q, et al. Grey wolf optimizer and discrete chaotic map for substitution boxes design and optimization[J]. IEEE Access, 2023, 11: 42416–42430. doi: 10.1109/ACCESS.2023.3266290. [20] XUE Mingfu, CHEN Kewei, ZHANG L Y, et al. An active authorization control method for deep reinforcement learning model based on GANs and adaptive trigger[J]. IEEE Transactions on Information Forensics and Security, 2025, 20: 5789–5801. doi: 10.1109/tifs.2025.3567915. [21] KIM G, KIM H, HEO Y, et al. Generating cryptographic S-boxes using the reinforcement learning[J]. IEEE Access, 2021, 9: 83092–83104. doi: 10.1109/ACCESS.2021.3085861. [22] ZHANG Runlian, SHU Rui, WEI Yongzhuang, et al. A novel S-box generation methodology based on the optimized GAN model[J]. Computers, Materials & Continua, 2023, 76(2): 1911–1927. doi: 10.32604/cmc.2023.041187. [23] PANTAZIS Y, PAUL D, FASOULAKIS M, et al. Cumulant GAN[J]. IEEE Transactions on Neural Networks and Learning Systems, 2023, 34(11): 9439–9450. doi: 10.1109/TNNLS.2022.3161127. [24] 黄琳玹, 何明浩, 郁春来, 等. 融合时序条件生成对抗网络的小样本雷达对抗侦察数据增强[J]. 电子与信息学报, 2025, 47(10): 3723–3734. doi: 10.11999/JEIT250280.HUANG Linxuan, HE Minghao, YU Chunlai, et al. Data enhancement for few-shot radar countermeasure reconnaissance via temporal-conditional generative adversarial networks[J]. Journal of Electronics & Information Technology, 2025, 47(10): 3723–3734. doi: 10.11999/JEIT250280. [25] BU Xiangya, WU Qiuwei, ZHOU Bin, et al. Hybrid short-term load forecasting using CGAN with CNN and semi-supervised regression[J]. Applied Energy, 2023, 338: 120920. doi: 10.1016/j.apenergy.2023.120920. [26] 舒瑞. 基于生成对抗网络模型的S盒构造方法[D]. [硕士论文], 桂林电子科技大学, 2023. doi: 10.27049/d.cnki.ggldc.2023.001394.SHU Rui. S-box construction and analysis based on intelligent search algorithm[D]. [Master dissertation], Guilin University of Electronic Technology, 2023. doi: 10.27049/d.cnki.ggldc.2023.001394. [27] DEDEOGLU M, LIN Sen, ZHANG Zhaofeng, et al. Continual learning of generative models with limited data: From Wasserstein-1 barycenter to adaptive coalescence[J]. IEEE Transactions on Neural Networks and Learning Systems, 2024, 35(9): 12042–12056. doi: 10.1109/tnnls.2023.3251096. [28] DING Hongwei, SUN Yu, HUANG Nana, et al. TMG-GAN: Generative adversarial networks-based imbalanced learning for network intrusion detection[J]. IEEE Transactions on Information Forensics and Security, 2024, 19: 1156–1167. doi: 10.1109/tifs.2023.3331240. [29] WANG Yaming, PENG Xiangyang, HUANG Wenqing, et al. Self-supervised non-rigid structure from motion with improved training of Wasserstein GANs[J]. IET Computer Vision, 2023, 17(4): 404–414. doi: 10.1049/cvi2.12175. [30] MSOLLI A, HAGUI I, and HELALI A. Dynamic S-boxes generation for IoT security enhancement: A genetic algorithm approach[J]. Ain Shams Engineering Journal, 2024, 15(11): 103049. doi: 10.1016/j.asej.2024.103049. [31] LIU Qi, LI Yanjie, SHI Xiongtao, et al. Distributional policy gradient with distributional value function[J]. IEEE Transactions on Neural Networks and Learning Systems, 2025, 36(4): 6556–6568. doi: 10.1109/TNNLS.2024.3386225. [32] PARK S and SHIN Y G. A novel generator with auxiliary branch for improving GAN performance[J]. IEEE Transactions on Neural Networks and Learning Systems, 2025, 36(3): 5818–5825. doi: 10.1109/TNNLS.2024.3361087. [33] HWANG H S, KIM Y, and SEOK J. Generative adversarial soft actor-critic[J]. IEEE Transactions on Neural Networks and Learning Systems, 2025, 36(7): 11917–11927. doi: 10.1109/TNNLS.2024.3493113. [34] LIU Hongying, GE Zhijin, ZHOU Zhenyu, et al. Gradient correction for white-box adversarial attacks[J]. IEEE Transactions on Neural Networks and Learning Systems, 2024, 35(12): 18419–18430. doi: 10.1109/TNNLS.2023.3315414. [35] CHEN Hong, FU Youcheng, JIANG Xue, et al. Gradient learning with the mode-induced loss: Consistency analysis and applications[J]. IEEE Transactions on Neural Networks and Learning Systems, 2024, 35(7): 9686–9699. doi: 10.1109/tnnls.2023.3236345. [36] JARALI V, MESNAGER S, POOJARY P, et al. On generalizations of differential uniform permutations over finite fields based on 2-to-1 mappings[J]. Applicable Algebra in Engineering, Communication and Computing, 2026, 37(4): 921–935. doi: 10.1007/s00200-025-00691-9. [37] SANCHIRICO M J, JIAO Xun, and NATARAJ C. AMITE: A novel polynomial expansion for analyzing neural network nonlinearities[J]. IEEE Transactions on Neural Networks and Learning Systems, 2023, 34(9): 5732–5744. doi: 10.1109/tnnls.2021.3130904. [38] NYBERG K. Modifications of bijective S-Boxes with linear structures[J]. Cryptography and Communications, 2023, 15(3): 617–625. doi: 10.1007/s12095-023-00631-9. [39] 唐啸霖, 冯燕, 李明达, 等. 秘密共享: 高阶掩码S盒和有限域安全乘法设计[J]. 电子与信息学报, 2024, 46(8): 3400–3409. doi: 10.11999/JEIT231272.TANG Xiaolin, FENG Yan, LI Mingda, et al. Secret sharing: Design of higher-order masking S-box and secure multiplication in Galois field[J]. Journal of Electronics & Information Technology, 2024, 46(8): 3400–3409. doi: 10.11999/JEIT231272. -
下载: