@@ -21,7 +21,7 @@ type G2 struct {
21
21
// Unmarshal deserializes `buf` into `g`
22
22
//
23
23
// The input is expected to be in the EVM format:
24
- // 128 bytes: [32-byte x.0 ][32-byte x.1 ][32-byte y.0 ][32-byte y.1 ]
24
+ // 128 bytes: [32-byte x.1 ][32-byte x.0 ][32-byte y.1 ][32-byte y.0 ]
25
25
// where each value is a big-endian integer.
26
26
//
27
27
// This method also checks whether the point is on the
@@ -39,16 +39,16 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
39
39
g .inner .Y .A1 .SetZero ()
40
40
return 128 , nil
41
41
}
42
- if err := g .inner .X .A0 .SetBytesCanonical (buf [0 :32 ]); err != nil {
42
+ if err := g .inner .X .A1 .SetBytesCanonical (buf [0 :32 ]); err != nil {
43
43
return 0 , err
44
44
}
45
- if err := g .inner .X .A1 .SetBytesCanonical (buf [32 :64 ]); err != nil {
45
+ if err := g .inner .X .A0 .SetBytesCanonical (buf [32 :64 ]); err != nil {
46
46
return 0 , err
47
47
}
48
- if err := g .inner .Y .A0 .SetBytesCanonical (buf [64 :96 ]); err != nil {
48
+ if err := g .inner .Y .A1 .SetBytesCanonical (buf [64 :96 ]); err != nil {
49
49
return 0 , err
50
50
}
51
- if err := g .inner .Y .A1 .SetBytesCanonical (buf [96 :128 ]); err != nil {
51
+ if err := g .inner .Y .A0 .SetBytesCanonical (buf [96 :128 ]); err != nil {
52
52
return 0 , err
53
53
}
54
54
@@ -64,22 +64,22 @@ func (g *G2) Unmarshal(buf []byte) (int, error) {
64
64
// Marshal serializes the point into a byte slice.
65
65
//
66
66
// The output is in EVM format: 128 bytes total.
67
- // [32-byte x.0 ][32-byte x.1 ][32-byte y.0 ][32-byte y.1 ]
67
+ // [32-byte x.1 ][32-byte x.0 ][32-byte y.1 ][32-byte y.0 ]
68
68
// where each value is a big-endian integer.
69
69
func (g * G2 ) Marshal () []byte {
70
70
output := make ([]byte , 128 )
71
71
72
- xA0Bytes := g .inner .X .A0 .Bytes ()
73
- copy (output [:32 ], xA0Bytes [:])
74
-
75
72
xA1Bytes := g .inner .X .A1 .Bytes ()
76
- copy (output [32 : 64 ], xA1Bytes [:])
73
+ copy (output [: 32 ], xA1Bytes [:])
77
74
78
- yA0Bytes := g .inner .Y .A0 .Bytes ()
79
- copy (output [64 : 96 ], yA0Bytes [:])
75
+ xA0Bytes := g .inner .X .A0 .Bytes ()
76
+ copy (output [32 : 64 ], xA0Bytes [:])
80
77
81
78
yA1Bytes := g .inner .Y .A1 .Bytes ()
82
- copy (output [96 :128 ], yA1Bytes [:])
79
+ copy (output [64 :96 ], yA1Bytes [:])
80
+
81
+ yA0Bytes := g .inner .Y .A0 .Bytes ()
82
+ copy (output [96 :128 ], yA0Bytes [:])
83
83
84
84
return output
85
85
}
0 commit comments