-
Notifications
You must be signed in to change notification settings - Fork 61
SM3中的FF2和GG2函数
GG2等价公式初次见于Intel® Integrated Performance Primitives Cryptography
特别是GG2,其等价公式相比原来的公式,因其简单,具有一点点性能优势(不明显),也可以省一个寄存器,还有就是ANDN指令属于BMI1,有些老机器不支持。
原公式:
MOVL f, y3; \
ANDL e, y3; \ // y3 = e AND f
ANDNL g, e, y1; \ // y1 = NOT(e) AND g
ORL y3, y1; \ // y1 = (e AND f) OR (NOT(e) AND g)
等价公式:
MOVL f, y1; \
XORL g, y1; \
ANDL e, y1; \
XORL g, y1; \ // y1 = GG2(e, f, g)
X | Y | Z | ||||
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 | 0 | 1 | 1 |
0 | 1 | 0 | 0 | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 1 | 1 | 1 |
1 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 1 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 1 | 1 | 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 |
Ask help https://math.stackexchange.com/questions/4775054/how-to-prove-below-two-logic-formulas
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
相关知识:
$A \bigoplus B = (\lnot A \land B) \lor (A \land \lnot B) $ - Boolean algebra
- 布尔代数运算律