github.com/consensys/gnark-crypto@v0.14.0/ecc/bw6-756/fp/doc.go (about)

     1  // Copyright 2020 ConsenSys Software Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Code generated by consensys/gnark-crypto DO NOT EDIT
    16  
    17  // Package fp contains field arithmetic operations for modulus = 0xf76adb...000001.
    18  //
    19  // 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)
    20  //
    21  // The modulus is hardcoded in all the operations.
    22  //
    23  // Field elements are represented as an array, and assumed to be in Montgomery form in all methods:
    24  //
    25  //	type Element [12]uint64
    26  //
    27  // # Usage
    28  //
    29  // Example API signature:
    30  //
    31  //	// Mul z = x * y (mod q)
    32  //	func (z *Element) Mul(x, y *Element) *Element
    33  //
    34  // and can be used like so:
    35  //
    36  //	var a, b Element
    37  //	a.SetUint64(2)
    38  //	b.SetString("984896738")
    39  //	a.Mul(a, b)
    40  //	a.Sub(a, a)
    41  //	 .Add(a, b)
    42  //	 .Inv(a)
    43  //	b.Exp(b, new(big.Int).SetUint64(42))
    44  //
    45  // Modulus q =
    46  //
    47  //	q[base10] = 366325390957376286590726555727219947825377821289246188278797409783441745356050456327989347160777465284190855125642086860525706497928518803244008749360363712553766506755227344593404398783886857865261088226271336335268413437902849
    48  //	q[base16] = 0xf76adbb5bb98ae2ac127e1e3568cf5c978cd2fac2ce89fbf23221455163a6ccc6ae73c42a46d9eb02c812ea04faaa0a7eb1cb3d06e646e292cd15edb646a54302aa3c258de7ded0b685e868524ec033c7e63f868400000000000000000001
    49  //
    50  // # Warning
    51  //
    52  // 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.
    53  package fp