github.com/consensys/gnark-crypto@v0.14.0/ecc/bn254/internal/fptower/e2_bn254_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/bn254/fp" 21 22 // MulByNonResidue multiplies a E2 by (9,1) 23 func (z *E2) MulByNonResidue(x *E2) *E2 { 24 var a, b fp.Element 25 a.Double(&x.A0).Double(&a).Double(&a).Add(&a, &x.A0).Sub(&a, &x.A1) 26 b.Double(&x.A1).Double(&b).Double(&b).Add(&b, &x.A1).Add(&b, &x.A0) 27 z.A0.Set(&a) 28 z.A1.Set(&b) 29 return z 30 } 31 32 // Mul sets z to the E2-product of x,y, returns z 33 func (z *E2) Mul(x, y *E2) *E2 { 34 mulGenericE2(z, x, y) 35 return z 36 } 37 38 // Square sets z to the E2-product of x,x returns z 39 func (z *E2) Square(x *E2) *E2 { 40 squareGenericE2(z, x) 41 return z 42 }