github.com/consensys/gnark-crypto@v0.14.0/field/generator/internal/templates/element/doc.go (about)

     1  package element
     2  
     3  const Doc = `
     4  // Package {{.PackageName}} contains field arithmetic operations for modulus = 0x{{shorten .ModulusHex}}.
     5  // 
     6  // The API is similar to math/big (big.Int), but the operations are significantly faster (up to 20x for the modular multiplication on amd64, see also https://hackmd.io/@gnark/modular_multiplication)
     7  // 
     8  // The modulus is hardcoded in all the operations.
     9  // 
    10  // Field elements are represented as an array, and assumed to be in Montgomery form in all methods:
    11  // 	type {{.ElementName}} [{{.NbWords}}]uint64
    12  //
    13  // Usage
    14  //
    15  // Example API signature:
    16  // 	// Mul z = x * y (mod q)
    17  // 	func (z *Element) Mul(x, y *Element) *Element
    18  //
    19  // and can be used like so:
    20  // 	var a, b Element
    21  // 	a.SetUint64(2)
    22  // 	b.SetString("984896738")
    23  // 	a.Mul(a, b)
    24  // 	a.Sub(a, a)
    25  // 	 .Add(a, b)
    26  // 	 .Inv(a)
    27  // 	b.Exp(b, new(big.Int).SetUint64(42))
    28  //
    29  // Modulus q =
    30  //
    31  // 	q[base10] = {{.Modulus}}
    32  // 	q[base16] = 0x{{.ModulusHex}}
    33  //
    34  // Warning
    35  //
    36  // This code has not been audited and is provided as-is. In particular, there is no security guarantees such as constant time implementation or side-channel attack resistance.
    37  package {{.PackageName}}
    38  `