gitee.com/liu-zhao234568/cntest@v1.0.0/crypto/bls12381/arithmetic_decl.go (about)

     1  // Copyright 2020 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // +build amd64,blsasm amd64,blsadx
    18  
    19  package bls12381
    20  
    21  import (
    22  	"golang.org/x/sys/cpu"
    23  )
    24  
    25  func init() {
    26  	if !enableADX || !cpu.X86.HasADX || !cpu.X86.HasBMI2 {
    27  		mul = mulNoADX
    28  	}
    29  }
    30  
    31  // Use ADX backend for default
    32  var mul func(c, a, b *fe) = mulADX
    33  
    34  func square(c, a *fe) {
    35  	mul(c, a, a)
    36  }
    37  
    38  func neg(c, a *fe) {
    39  	if a.isZero() {
    40  		c.set(a)
    41  	} else {
    42  		_neg(c, a)
    43  	}
    44  }
    45  
    46  //go:noescape
    47  func add(c, a, b *fe)
    48  
    49  //go:noescape
    50  func addAssign(a, b *fe)
    51  
    52  //go:noescape
    53  func ladd(c, a, b *fe)
    54  
    55  //go:noescape
    56  func laddAssign(a, b *fe)
    57  
    58  //go:noescape
    59  func double(c, a *fe)
    60  
    61  //go:noescape
    62  func doubleAssign(a *fe)
    63  
    64  //go:noescape
    65  func ldouble(c, a *fe)
    66  
    67  //go:noescape
    68  func sub(c, a, b *fe)
    69  
    70  //go:noescape
    71  func subAssign(a, b *fe)
    72  
    73  //go:noescape
    74  func lsubAssign(a, b *fe)
    75  
    76  //go:noescape
    77  func _neg(c, a *fe)
    78  
    79  //go:noescape
    80  func mulNoADX(c, a, b *fe)
    81  
    82  //go:noescape
    83  func mulADX(c, a, b *fe)