github.com/consensys/gnark-crypto@v0.14.0/ecc/bls12-381/internal/fptower/e2_bls381_fallback.go (about)

     1  //go:build !amd64
     2  // +build !amd64
     3  
     4  // Copyright 2020 ConsenSys AG
     5  //
     6  // Licensed under the Apache License, Version 2.0 (the "License");
     7  // you may not use this file except in compliance with the License.
     8  // You may obtain a copy of the License at
     9  //
    10  //     http://www.apache.org/licenses/LICENSE-2.0
    11  //
    12  // Unless required by applicable law or agreed to in writing, software
    13  // distributed under the License is distributed on an "AS IS" BASIS,
    14  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  // See the License for the specific language governing permissions and
    16  // limitations under the License.
    17  
    18  package fptower
    19  
    20  import "github.com/consensys/gnark-crypto/ecc/bls12-381/fp"
    21  
    22  // MulByNonResidue multiplies a E2 by (1,1)
    23  func (z *E2) MulByNonResidue(x *E2) *E2 {
    24  	var a fp.Element
    25  	a.Sub(&x.A0, &x.A1)
    26  	z.A1.Add(&x.A0, &x.A1)
    27  	z.A0.Set(&a)
    28  	return z
    29  }
    30  
    31  // Mul sets z to the E2-product of x,y, returns z
    32  func (z *E2) Mul(x, y *E2) *E2 {
    33  	mulGenericE2(z, x, y)
    34  	return z
    35  }
    36  
    37  // Square sets z to the E2-product of x,x returns z
    38  func (z *E2) Square(x *E2) *E2 {
    39  	squareGenericE2(z, x)
    40  	return z
    41  }