github.com/consensys/gnark-crypto@v0.14.0/field/generator/internal/templates/element/ops_asm.go (about) 1 package element 2 3 // OpsAMD64 is included with AMD64 builds (regardless of architecture or if F.ASM is set) 4 const OpsAMD64 = ` 5 6 {{if .ASM}} 7 8 //go:noescape 9 func MulBy3(x *{{.ElementName}}) 10 11 //go:noescape 12 func MulBy5(x *{{.ElementName}}) 13 14 //go:noescape 15 func MulBy13(x *{{.ElementName}}) 16 17 //go:noescape 18 func mul(res,x,y *{{.ElementName}}) 19 20 //go:noescape 21 func fromMont(res *{{.ElementName}}) 22 23 //go:noescape 24 func reduce(res *{{.ElementName}}) 25 26 // Butterfly sets 27 // a = a + b (mod q) 28 // b = a - b (mod q) 29 //go:noescape 30 func Butterfly(a, b *{{.ElementName}}) 31 32 33 34 // Mul z = x * y (mod q) 35 // 36 // x and y must be less than q 37 func (z *{{.ElementName}}) Mul(x, y *{{.ElementName}}) *{{.ElementName}} { 38 {{ mul_doc $.NoCarry }} 39 mul(z, x, y) 40 return z 41 } 42 43 // Square z = x * x (mod q) 44 // 45 // x must be less than q 46 func (z *{{.ElementName}}) Square(x *{{.ElementName}}) *{{.ElementName}} { 47 // see Mul for doc. 48 mul(z, x, x) 49 return z 50 } 51 52 {{end}} 53 54 55 56 `