gnark-plonky2-verifier/field/field.go
field/field.goRaw
1package field
2
3import (
4 "math/big"
5
6 "github.com/consensys/gnark-crypto/ecc"
7 "github.com/consensys/gnark/frontend"
8 "github.com/consensys/gnark/std/math/emulated"
9)
10
11type EmulatedField = emulated.Goldilocks
12type F = emulated.Element[EmulatedField]
13type QuadraticExtension = [2]F
14type Hash = [4]F
15
16var TEST_CURVE = ecc.BN254
17
18func NewFieldElement(x uint64) F {
19 return emulated.NewElement[EmulatedField](x)
20}
21
22func NewFieldElementFromString(x string) F {
23 return emulated.NewElement[EmulatedField](x)
24}
25
26func NewFieldAPI(api frontend.API) frontend.API {
27 field, err := emulated.NewField[EmulatedField](api)
28 if err != nil {
29 panic(err)
30 }
31 return field
32}
33
34var r EmulatedField
35
36func EmulatedFieldModulus() *big.Int {
37 return r.Modulus()
38}