mirror of
https://github.com/emmansun/gmsm.git
synced 2025-05-10 11:06:18 +08:00
Page:
SM2性能优化(续)
Pages
Armv8.2 SM3和SM4
Efficient Software Implementations of ZUC
GCM for SM4
Golang ppc64x asm Reference
Golang s390x asm Reference
High‐Throughput Elliptic Curve Cryptography using AVX2 Vector Instructions
High‐assurance field inversion for curve‐based cryptography
Home
Intel CPU supports SM3 SM4
PQC: ML‐DSA
PQC: ML‐KEM
PQC: SLH‐DSA
SM2 WWMM (2)
SM2 WWMM
SM2加解密性能
SM2性能优化
SM2性能优化(续)
SM3中的FF2和GG2函数
SM3性能优化
SM4 with AESENCLAST
SM4 with GFNI
SM4性能优化
SM9实现及优化
go crypto and BoringCrypto
is my code constant time?
sbox generation
stealth addresses (隐身地址)
关于CTR模式
关于证书和TLS支持
实现Kyber所需的多项式和线性代数知识
实现ML‐DSA所需的多项式和线性代数知识
无进位乘法和GHASH
门限签名
Clone
Table of Contents
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
这篇文章接续SM2实现及优化,着重当前实现,我说过目前纯golang实现通过fiat-crypto生成代码,大家可以参考POC项目sm2fiat。
纯Go实现
- 通过fiat-crypto生成SM2曲线参数P的域运算(使用Montgomery算法),主要是加、减、乘、平方。
- 通过addchain生成优化的求逆运算。
- 通过代码模板,生成SM2曲线点运算,主要是点加、倍点和点标量乘法,其中点加是完全加法,意思是就算两个点相同,也能得到正确结果,具体请参考Complete addition formulas for prime order elliptic curves, §A.2。这里也用代码模板,一是因为本来就要通过addchain生成优化的生成求平方跟算法,另外一个也就是和Go语言保持一致(Go语言因为有多条曲线,所以用代码模板,保持代码的一致性和正确性)。
通过代码生成方式,保证算法实现的正确性、一致性。有尝试自己编写SM2曲线纯Go语言优化实现的同学应该体会很深。
amd64 arm64架构实现
总体而言,和以前实现相比,变化不大。
- 基点标量乘法查找表生成,没有重新写生成方法,延用以前的实现,可以参考gen_p256_table.go。
- 调整了点标量乘法的窗口大小,具体请参考sm2 point scalar multiple ASM implementation issue: final p256PointAddAsm's input maybe equal
amd64架构优化
- 使用MULX优化, 可以参考这个提交
a0c4a389b8
- AVX2优化,这里只是SELECT、MOVE等优化,不涉及计算。
arm64架构优化
- 使用NEON指令实现SELECT、MOVE操作,请参考https://github.com/emmansun/gmsm/discussions/134
SM2签名、加解密等算法优化
- 改用
bigmod
代替big.Int
,请参考use bigmod and sm2ec instead of math/big and crypto/elliptic等。 - 优化签名算法,减少求逆操作。请参考https://github.com/emmansun/gmsm/issues/190
- 优化加解密性能