forked from Consensys/gnark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
g1.go
35 lines (28 loc) · 1.19 KB
/
g1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package sw_bw6761
import (
bw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761"
fr_bw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/fr"
"github.com/airchains-network/gnark/std/algebra/emulated/sw_emulated"
"github.com/airchains-network/gnark/std/math/emulated"
)
// G1Affine is the point in G1. It is an alias to the generic emulated affine
// point.
type G1Affine = sw_emulated.AffinePoint[BaseField]
// Scalar is the scalar in the groups. It is an alias to the emulated element
// defined over the scalar field of the groups.
type Scalar = emulated.Element[ScalarField]
// NewG1Affine allocates a witness from the native G1 element and returns it.
func NewG1Affine(v bw6761.G1Affine) G1Affine {
return G1Affine{
X: emulated.ValueOf[BaseField](v.X),
Y: emulated.ValueOf[BaseField](v.Y),
}
}
// NewScalar allocates a witness from the native scalar and returns it.
func NewScalar(v fr_bw6761.Element) Scalar {
return emulated.ValueOf[ScalarField](v)
}
// ScalarField is the [emulated.FieldParams] impelementation of the curve scalar field.
type ScalarField = emulated.BW6761Fr
// BaseField is the [emulated.FieldParams] impelementation of the curve base field.
type BaseField = emulated.BW6761Fp