add port of field operations assembler from libsecp256k1

This commit is contained in:
2025-11-28 19:46:44 +00:00
parent b250fc5cf7
commit 88bc5b9a3d
19 changed files with 2895 additions and 207 deletions

23
field_amd64.go Normal file
View File

@@ -0,0 +1,23 @@
//go:build amd64
package p256k1
// fieldMulAsm multiplies two field elements using x86-64 assembly.
// This is a direct port of bitcoin-core secp256k1_fe_mul_inner.
// r, a, b are 5x52-bit limb representations.
//
//go:noescape
func fieldMulAsm(r, a, b *FieldElement)
// fieldSqrAsm squares a field element using x86-64 assembly.
// This is a direct port of bitcoin-core secp256k1_fe_sqr_inner.
// Squaring is optimized compared to multiplication.
//
//go:noescape
func fieldSqrAsm(r, a *FieldElement)
// hasFieldAsm returns true if field assembly is available.
// On amd64, this is always true.
func hasFieldAsm() bool {
return true
}