mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-21 17:56:19 +08:00
sm9/bn256: arm64 gfp2MulU
This commit is contained in:
parent
ecf14648e9
commit
c62d6daf74
@ -8,29 +8,10 @@ package bn256
|
|||||||
//go:noescape
|
//go:noescape
|
||||||
func gfp2Mul(c, a, b *gfP2)
|
func gfp2Mul(c, a, b *gfP2)
|
||||||
|
|
||||||
func gfp2MulU(c, a, b *gfP2) {
|
// gfP2 multiplication. c = a*b*u
|
||||||
tmp := &gfP2{}
|
//
|
||||||
tx := &tmp.x
|
//go:noescape
|
||||||
ty := &tmp.y
|
func gfp2MulU(c, a, b *gfP2)
|
||||||
v0, v1 := &gfP{}, &gfP{}
|
|
||||||
|
|
||||||
gfpMul(v0, &a.y, &b.y)
|
|
||||||
gfpMul(v1, &a.x, &b.x)
|
|
||||||
|
|
||||||
gfpAdd(tx, &a.x, &a.y)
|
|
||||||
gfpAdd(ty, &b.x, &b.y)
|
|
||||||
|
|
||||||
gfpMul(ty, tx, ty)
|
|
||||||
gfpSub(ty, ty, v0)
|
|
||||||
gfpSub(ty, ty, v1)
|
|
||||||
gfpDouble(ty, ty)
|
|
||||||
gfpNeg(ty, ty)
|
|
||||||
|
|
||||||
gfpSub(tx, v0, v1)
|
|
||||||
gfpSub(tx, tx, v1)
|
|
||||||
|
|
||||||
gfp2Copy(c, tmp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func gfp2Square(c, a *gfP2) {
|
func gfp2Square(c, a *gfP2) {
|
||||||
tmp := &gfP2{}
|
tmp := &gfP2{}
|
||||||
|
@ -515,8 +515,8 @@ TEXT ·gfp2Mul(SB),NOSPLIT,$104-24
|
|||||||
LDx (y1in)
|
LDx (y1in)
|
||||||
LDy (y2in)
|
LDy (y2in)
|
||||||
CALL gfpMulInternal(SB)
|
CALL gfpMulInternal(SB)
|
||||||
|
|
||||||
STy (tmp0)
|
STy (tmp0)
|
||||||
|
|
||||||
LDx (x1in)
|
LDx (x1in)
|
||||||
LDy (x2in)
|
LDy (x2in)
|
||||||
CALL gfpMulInternal(SB)
|
CALL gfpMulInternal(SB)
|
||||||
@ -538,7 +538,7 @@ TEXT ·gfp2Mul(SB),NOSPLIT,$104-24
|
|||||||
x2y
|
x2y
|
||||||
LDx (tmp1)
|
LDx (tmp1)
|
||||||
CALL gfpSubInternal(SB)
|
CALL gfpSubInternal(SB)
|
||||||
MOVD res+0(FP), res_ptr // not use hlp1 any more
|
MOVD res+0(FP), res_ptr // not use hlp1 any more
|
||||||
STx (x3out)
|
STx (x3out)
|
||||||
|
|
||||||
LDy (tmp1)
|
LDy (tmp1)
|
||||||
@ -548,3 +548,56 @@ TEXT ·gfp2Mul(SB),NOSPLIT,$104-24
|
|||||||
STx (y3out)
|
STx (y3out)
|
||||||
|
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
// func gfp2MulU(c, a, b *gfP2)
|
||||||
|
TEXT ·gfp2MulU(SB),NOSPLIT,$104-24
|
||||||
|
MOVD in1+8(FP), a_ptr
|
||||||
|
MOVD in2+16(FP), b_ptr
|
||||||
|
|
||||||
|
MOVD ·np+0x00(SB), hlp1
|
||||||
|
LDP ·p2+0x00(SB), (const0, const1)
|
||||||
|
LDP ·p2+0x10(SB), (const2, const3)
|
||||||
|
|
||||||
|
LDx (y1in)
|
||||||
|
LDy (y2in)
|
||||||
|
CALL gfpMulInternal(SB)
|
||||||
|
STy (tmp0)
|
||||||
|
|
||||||
|
LDx (x1in)
|
||||||
|
LDy (x2in)
|
||||||
|
CALL gfpMulInternal(SB)
|
||||||
|
STy (tmp1)
|
||||||
|
|
||||||
|
LDx (x1in)
|
||||||
|
LDy (y1in)
|
||||||
|
gfpAddInline
|
||||||
|
STx (tmp2)
|
||||||
|
|
||||||
|
LDx (x2in)
|
||||||
|
LDy (y2in)
|
||||||
|
gfpAddInline
|
||||||
|
LDy (tmp2)
|
||||||
|
CALL gfpMulInternal(SB)
|
||||||
|
|
||||||
|
LDx (tmp0)
|
||||||
|
CALL gfpSubInternal(SB)
|
||||||
|
x2y
|
||||||
|
LDx (tmp1)
|
||||||
|
CALL gfpSubInternal(SB)
|
||||||
|
x2y
|
||||||
|
gfpMulBy2Inline
|
||||||
|
MOVD $0, y0
|
||||||
|
MOVD $0, y1
|
||||||
|
MOVD $0, y2
|
||||||
|
MOVD $0, y3
|
||||||
|
CALL gfpSubInternal(SB)
|
||||||
|
MOVD res+0(FP), res_ptr // not use hlp1 any more
|
||||||
|
STx (y3out)
|
||||||
|
|
||||||
|
LDy (tmp1)
|
||||||
|
gfpMulBy2Inline
|
||||||
|
LDy (tmp0)
|
||||||
|
CALL gfpSubInternal(SB)
|
||||||
|
STx (x3out)
|
||||||
|
|
||||||
|
RET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user