github.com/consensys/gnark-crypto@v0.14.0/ecc/bw6-633/internal/fptower/frobenius.go (about)

     1  // Copyright 2020 ConsenSys AG
     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  package fptower
    16  
    17  import (
    18  	"github.com/consensys/gnark-crypto/ecc/bw6-633/fp"
    19  )
    20  
    21  // Frobenius set z in E6 to Frobenius(x), return z
    22  func (z *E6) Frobenius(x *E6) *E6 {
    23  	a := fp.Element{
    24  		13379576892826363940,
    25  		7215010732331695319,
    26  		9587968273680355194,
    27  		17498442511873681277,
    28  		17430577930908868575,
    29  		3900545948475841198,
    30  		4911233234059649485,
    31  		5259203007663136357,
    32  		784833376601091838,
    33  		14101604511763105,
    34  	}
    35  	b := fp.Element{
    36  		14915121275341857583,
    37  		17181477577419481383,
    38  		7084037479344459509,
    39  		15839663182812461911,
    40  		1480269266224751652,
    41  		8132863462598737762,
    42  		18142219247247109524,
    43  		16952785282480028983,
    44  		10364476017837376831,
    45  		17548851641601399,
    46  	}
    47  	c := fp.Element{
    48  		597834311555652830,
    49  		5676150712176383509,
    50  		8459519236066800431,
    51  		11690428270517348528,
    52  		11839864809966557220,
    53  		1185830464157066542,
    54  		5950198841798077595,
    55  		13670804634510857615,
    56  		7801381657215673717,
    57  		65313904097694188,
    58  	}
    59  	ac := fp.Element{
    60  		9847954094458669907,
    61  		5949744236041625087,
    62  		16672005753024814704,
    63  		14891361620976591572,
    64  		464103123424068612,
    65  		12033409411074578961,
    66  		4606708407597207393,
    67  		3765244216433613725,
    68  		11149309394438468670,
    69  		31650456153364504,
    70  	}
    71  	bc := fp.Element{
    72  		2133378694071146473,
    73  		15642617557264169573,
    74  		5955588441730904746,
    75  		10031648941456129162,
    76  		14336300218991991913,
    77  		5418147978279963105,
    78  		734440781275986018,
    79  		6917642835618198626,
    80  		17381024298451958711,
    81  		68761151227532482,
    82  	}
    83  
    84  	z.B0.A0.Set(&x.B0.A0)
    85  	z.B0.A1.Mul(&x.B0.A1, &a)
    86  	z.B0.A2.Mul(&x.B0.A2, &b)
    87  
    88  	z.B1.A0.Mul(&x.B1.A0, &c)
    89  	z.B1.A1.Mul(&x.B1.A1, &ac)
    90  	z.B1.A2.Mul(&x.B1.A2, &bc)
    91  
    92  	return z
    93  }