Files
Ignacio HagopianandGitHub 38cc55ab70 Use gnark-crypto directly for Fp (#53)
* bandersnatch/fp: use Fp directly from gnark

Signed-off-by: Ignacio Hagopian <[email protected]>

* banderwagon: add precomp MSM benchmark

Signed-off-by: Ignacio Hagopian <[email protected]>

* mod: update to gnar-crypto v0.11.1

Signed-off-by: Ignacio Hagopian <[email protected]>

* rebase and update to [email protected].2

Signed-off-by: Ignacio Hagopian <[email protected]>

* mod: bump go min version to v1.19

Signed-off-by: Ignacio Hagopian <[email protected]>

* mod: bump go min version to v1.18

Signed-off-by: Ignacio Hagopian <[email protected]>

* fix comments

Signed-off-by: Ignacio Hagopian <[email protected]>

* fixes

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
2023-08-31 18:52:11 +01:00

46 lines
1.0 KiB
Go

package fp
import (
basefield "github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
)
// Element is a field element representing the basefield of the curve.
type Element = basefield.Element
// Limbs is the number of 64-bit words needed to represent the field element.
const Limbs = basefield.Limbs
// One returns the field element 1.
func One() Element {
return basefield.One()
}
// Zero returns the field element 0.
func Zero() Element {
return basefield.Element{}
}
// MinusOne returns the field element -1.
func MinusOne() Element {
m_one := One()
m_one.Neg(&m_one)
return m_one
}
// MulBy5 multiplies a field element by 5.
func MulBy5(a *Element) {
basefield.MulBy5(a)
}
// BatchInvert computes the inverse of a slice of field elements.
func BatchInvert(a []Element) []Element {
return basefield.BatchInvert(a)
}
// BytesLE returns the little-endian byte representation of a field element.
func BytesLE(a Element) []byte {
var result [basefield.Bytes]byte
basefield.LittleEndian.PutElement(&result, a)
return result[:]
}