github.com/aigarnetwork/aigar@v0.0.0-20191115204914-d59a6eb70f8e/crypto/bn256/google/constants.go (about)

     1  //  Copyright 2018 The go-ethereum Authors
     2  //  Copyright 2019 The go-aigar Authors
     3  //  This file is part of the go-aigar library.
     4  //
     5  //  The go-aigar library is free software: you can redistribute it and/or modify
     6  //  it under the terms of the GNU Lesser General Public License as published by
     7  //  the Free Software Foundation, either version 3 of the License, or
     8  //  (at your option) any later version.
     9  //
    10  //  The go-aigar library is distributed in the hope that it will be useful,
    11  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  //  GNU Lesser General Public License for more details.
    14  //
    15  //  You should have received a copy of the GNU Lesser General Public License
    16  //  along with the go-aigar library. If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package bn256
    19  
    20  import (
    21  	"math/big"
    22  )
    23  
    24  func bigFromBase10(s string) *big.Int {
    25  	n, _ := new(big.Int).SetString(s, 10)
    26  	return n
    27  }
    28  
    29  // u is the BN parameter that determines the prime: 1868033³.
    30  var u = bigFromBase10("4965661367192848881")
    31  
    32  // p is a prime over which we form a basic field: 36u⁴+36u³+24u²+6u+1.
    33  var P = bigFromBase10("21888242871839275222246405745257275088696311157297823662689037894645226208583")
    34  
    35  // Order is the number of elements in both G₁ and G₂: 36u⁴+36u³+18u²+6u+1.
    36  var Order = bigFromBase10("21888242871839275222246405745257275088548364400416034343698204186575808495617")
    37  
    38  // xiToPMinus1Over6 is ξ^((p-1)/6) where ξ = i+9.
    39  var xiToPMinus1Over6 = &gfP2{bigFromBase10("16469823323077808223889137241176536799009286646108169935659301613961712198316"), bigFromBase10("8376118865763821496583973867626364092589906065868298776909617916018768340080")}
    40  
    41  // xiToPMinus1Over3 is ξ^((p-1)/3) where ξ = i+9.
    42  var xiToPMinus1Over3 = &gfP2{bigFromBase10("10307601595873709700152284273816112264069230130616436755625194854815875713954"), bigFromBase10("21575463638280843010398324269430826099269044274347216827212613867836435027261")}
    43  
    44  // xiToPMinus1Over2 is ξ^((p-1)/2) where ξ = i+9.
    45  var xiToPMinus1Over2 = &gfP2{bigFromBase10("3505843767911556378687030309984248845540243509899259641013678093033130930403"), bigFromBase10("2821565182194536844548159561693502659359617185244120367078079554186484126554")}
    46  
    47  // xiToPSquaredMinus1Over3 is ξ^((p²-1)/3) where ξ = i+9.
    48  var xiToPSquaredMinus1Over3 = bigFromBase10("21888242871839275220042445260109153167277707414472061641714758635765020556616")
    49  
    50  // xiTo2PSquaredMinus2Over3 is ξ^((2p²-2)/3) where ξ = i+9 (a cubic root of unity, mod p).
    51  var xiTo2PSquaredMinus2Over3 = bigFromBase10("2203960485148121921418603742825762020974279258880205651966")
    52  
    53  // xiToPSquaredMinus1Over6 is ξ^((1p²-1)/6) where ξ = i+9 (a cubic root of -1, mod p).
    54  var xiToPSquaredMinus1Over6 = bigFromBase10("21888242871839275220042445260109153167277707414472061641714758635765020556617")
    55  
    56  // xiTo2PMinus2Over3 is ξ^((2p-2)/3) where ξ = i+9.
    57  var xiTo2PMinus2Over3 = &gfP2{bigFromBase10("19937756971775647987995932169929341994314640652964949448313374472400716661030"), bigFromBase10("2581911344467009335267311115468803099551665605076196740867805258568234346338")}