安全加固:常量时间改进与侧信道缓解
- SM2: 常量时间标量乘法、点验证和域运算 - SM3: 常量时间填充和长度处理 - SM4: bitslice S-box 实现,避免缓存时序攻击 - SM4 模式: 常量时间 CBC 填充和标签比较 - SM9: 常量时间 Fp12 求逆和哈希到标量 - 添加 zeroize 用于私钥清理 - 改进错误处理,使用常量时间比较
This commit is contained in:
@@ -489,7 +489,8 @@ pub fn fp12_to_bytes(a: &Fp12) -> [u8; 384] {
|
||||
/// - a: yP 系数 -> c0.c0(1 slot,在 eval_line_at_p 中乘以 yP)
|
||||
/// - b: 常数项 -> c0.c1(v slot)
|
||||
/// - c: xP 系数 -> c1.c0(w slot,在 eval_line_at_p 中乘以 xP)
|
||||
/// Reason: 经双线性性测试验证,此约定对应 D-type twist BN256 配对正确系数。
|
||||
///
|
||||
/// Reason: 经双线性性测试验证,此约定对应 D-type twist BN256 配对正确系数。
|
||||
/// double step: a=Z₁²·u, b=-2Y₁Z₁, c=3X₁²
|
||||
/// add step: a=r·x2, b=-(r·x1+h·y1), c=h·y2
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@@ -509,7 +510,7 @@ pub struct LineEval {
|
||||
/// - a 系数(yP 项)→ c0.c0 (1 slot)
|
||||
/// - b 系数(常数项)→ c1.c1 (vw slot)
|
||||
/// - c 系数(xP 项)→ c1.c2 (v²w slot)
|
||||
/// a、c 已经在 eval_line_at_p 中分别乘以 yP 和 xP。
|
||||
/// a、c 已经在 eval_line_at_p 中分别乘以 yP 和 xP。
|
||||
pub fn fp12_mul_by_line(f: &Fp12, l: &LineEval) -> Fp12 {
|
||||
let line_fp12 = Fp12 {
|
||||
c0: Fp6 {
|
||||
|
||||
Reference in New Issue
Block a user