6
6
"math/rand"
7
7
"testing"
8
8
9
- "github.com/iden3/go-iden3-crypto/constants"
10
- "github.com/iden3/go-iden3-crypto/utils"
9
+ "github.com/iden3/go-iden3-crypto/v2/ constants"
10
+ "github.com/iden3/go-iden3-crypto/v2/ utils"
11
11
"github.com/stretchr/testify/assert"
12
12
)
13
13
@@ -22,15 +22,15 @@ func TestAdd1(t *testing.T) {
22
22
}
23
23
24
24
func TestAdd2 (t * testing.T ) {
25
- aX := utils .NewIntFromString (
25
+ aX , _ := utils .NewIntFromString (
26
26
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
27
- aY := utils .NewIntFromString (
27
+ aY , _ := utils .NewIntFromString (
28
28
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
29
29
a := & Point {X : aX , Y : aY }
30
30
31
- bX := utils .NewIntFromString (
31
+ bX , _ := utils .NewIntFromString (
32
32
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
33
- bY := utils .NewIntFromString (
33
+ bY , _ := utils .NewIntFromString (
34
34
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
35
35
b := & Point {X : bX , Y : bY }
36
36
@@ -57,15 +57,15 @@ func TestAdd2(t *testing.T) {
57
57
}
58
58
59
59
func TestAdd3 (t * testing.T ) {
60
- aX := utils .NewIntFromString (
60
+ aX , _ := utils .NewIntFromString (
61
61
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
62
- aY := utils .NewIntFromString (
62
+ aY , _ := utils .NewIntFromString (
63
63
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
64
64
a := & Point {X : aX , Y : aY }
65
65
66
- bX := utils .NewIntFromString (
66
+ bX , _ := utils .NewIntFromString (
67
67
"16540640123574156134436876038791482806971768689494387082833631921987005038935" )
68
- bY := utils .NewIntFromString (
68
+ bY , _ := utils .NewIntFromString (
69
69
"20819045374670962167435360035096875258406992893633759881276124905556507972311" )
70
70
b := & Point {X : bX , Y : bY }
71
71
@@ -80,15 +80,15 @@ func TestAdd3(t *testing.T) {
80
80
}
81
81
82
82
func TestAdd4 (t * testing.T ) {
83
- aX := utils .NewIntFromString (
83
+ aX , _ := utils .NewIntFromString (
84
84
"0" )
85
- aY := utils .NewIntFromString (
85
+ aY , _ := utils .NewIntFromString (
86
86
"1" )
87
87
a := & Point {X : aX , Y : aY }
88
88
89
- bX := utils .NewIntFromString (
89
+ bX , _ := utils .NewIntFromString (
90
90
"16540640123574156134436876038791482806971768689494387082833631921987005038935" )
91
- bY := utils .NewIntFromString (
91
+ bY , _ := utils .NewIntFromString (
92
92
"20819045374670962167435360035096875258406992893633759881276124905556507972311" )
93
93
b := & Point {X : bX , Y : bY }
94
94
@@ -113,12 +113,12 @@ func TestInCurve2(t *testing.T) {
113
113
}
114
114
115
115
func TestMul0 (t * testing.T ) {
116
- x := utils .NewIntFromString (
116
+ x , _ := utils .NewIntFromString (
117
117
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
118
- y := utils .NewIntFromString (
118
+ y , _ := utils .NewIntFromString (
119
119
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
120
120
p := & Point {X : x , Y : y }
121
- s := utils .NewIntFromString ("3" )
121
+ s , _ := utils .NewIntFromString ("3" )
122
122
123
123
r2 := NewPoint ().Projective ().Add (p .Projective (), p .Projective ()).Affine ()
124
124
r2 = NewPoint ().Projective ().Add (r2 .Projective (), p .Projective ()).Affine ()
@@ -135,12 +135,12 @@ func TestMul0(t *testing.T) {
135
135
}
136
136
137
137
func TestMul1 (t * testing.T ) {
138
- x := utils .NewIntFromString (
138
+ x , _ := utils .NewIntFromString (
139
139
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
140
- y := utils .NewIntFromString (
140
+ y , _ := utils .NewIntFromString (
141
141
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
142
142
p := & Point {X : x , Y : y }
143
- s := utils .NewIntFromString (
143
+ s , _ := utils .NewIntFromString (
144
144
"14035240266687799601661095864649209771790948434046947201833777492504781204499" )
145
145
r := NewPoint ().Mul (s , p )
146
146
assert .Equal (t ,
@@ -152,12 +152,12 @@ func TestMul1(t *testing.T) {
152
152
}
153
153
154
154
func TestMul2 (t * testing.T ) {
155
- x := utils .NewIntFromString (
155
+ x , _ := utils .NewIntFromString (
156
156
"6890855772600357754907169075114257697580319025794532037257385534741338397365" )
157
- y := utils .NewIntFromString (
157
+ y , _ := utils .NewIntFromString (
158
158
"4338620300185947561074059802482547481416142213883829469920100239455078257889" )
159
159
p := & Point {X : x , Y : y }
160
- s := utils .NewIntFromString (
160
+ s , _ := utils .NewIntFromString (
161
161
"20819045374670962167435360035096875258406992893633759881276124905556507972311" )
162
162
r := NewPoint ().Mul (s , p )
163
163
assert .Equal (t ,
@@ -169,45 +169,45 @@ func TestMul2(t *testing.T) {
169
169
}
170
170
171
171
func TestInCurve3 (t * testing.T ) {
172
- x := utils .NewIntFromString (
172
+ x , _ := utils .NewIntFromString (
173
173
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
174
- y := utils .NewIntFromString (
174
+ y , _ := utils .NewIntFromString (
175
175
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
176
176
p := & Point {X : x , Y : y }
177
177
assert .Equal (t , true , p .InCurve ())
178
178
}
179
179
180
180
func TestInCurve4 (t * testing.T ) {
181
- x := utils .NewIntFromString (
181
+ x , _ := utils .NewIntFromString (
182
182
"6890855772600357754907169075114257697580319025794532037257385534741338397365" )
183
- y := utils .NewIntFromString (
183
+ y , _ := utils .NewIntFromString (
184
184
"4338620300185947561074059802482547481416142213883829469920100239455078257889" )
185
185
p := & Point {X : x , Y : y }
186
186
assert .Equal (t , true , p .InCurve ())
187
187
}
188
188
189
189
func TestInSubGroup1 (t * testing.T ) {
190
- x := utils .NewIntFromString (
190
+ x , _ := utils .NewIntFromString (
191
191
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
192
- y := utils .NewIntFromString (
192
+ y , _ := utils .NewIntFromString (
193
193
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
194
194
p := & Point {X : x , Y : y }
195
195
assert .Equal (t , true , p .InSubGroup ())
196
196
}
197
197
198
198
func TestInSubGroup2 (t * testing.T ) {
199
- x := utils .NewIntFromString (
199
+ x , _ := utils .NewIntFromString (
200
200
"6890855772600357754907169075114257697580319025794532037257385534741338397365" )
201
- y := utils .NewIntFromString (
201
+ y , _ := utils .NewIntFromString (
202
202
"4338620300185947561074059802482547481416142213883829469920100239455078257889" )
203
203
p := & Point {X : x , Y : y }
204
204
assert .Equal (t , true , p .InSubGroup ())
205
205
}
206
206
207
207
func TestPointFromSignAndy (t * testing.T ) {
208
- x := utils .NewIntFromString (
208
+ x , _ := utils .NewIntFromString (
209
209
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
210
- y := utils .NewIntFromString (
210
+ y , _ := utils .NewIntFromString (
211
211
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
212
212
p := & Point {X : x , Y : y }
213
213
@@ -219,9 +219,9 @@ func TestPointFromSignAndy(t *testing.T) {
219
219
}
220
220
221
221
func TestPackAndUnpackSignY (t * testing.T ) {
222
- x := utils .NewIntFromString (
222
+ x , _ := utils .NewIntFromString (
223
223
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
224
- y := utils .NewIntFromString (
224
+ y , _ := utils .NewIntFromString (
225
225
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
226
226
p := & Point {X : x , Y : y }
227
227
pComp := p .Compress ()
@@ -239,9 +239,9 @@ func TestPackAndUnpackSignY(t *testing.T) {
239
239
}
240
240
241
241
func TestCompressDecompress1 (t * testing.T ) {
242
- x := utils .NewIntFromString (
242
+ x , _ := utils .NewIntFromString (
243
243
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
244
- y := utils .NewIntFromString (
244
+ y , _ := utils .NewIntFromString (
245
245
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
246
246
p := & Point {X : x , Y : y }
247
247
@@ -257,9 +257,9 @@ func TestCompressDecompress1(t *testing.T) {
257
257
}
258
258
259
259
func TestCompressDecompress2 (t * testing.T ) {
260
- x := utils .NewIntFromString (
260
+ x , _ := utils .NewIntFromString (
261
261
"6890855772600357754907169075114257697580319025794532037257385534741338397365" )
262
- y := utils .NewIntFromString (
262
+ y , _ := utils .NewIntFromString (
263
263
"4338620300185947561074059802482547481416142213883829469920100239455078257889" )
264
264
p := & Point {X : x , Y : y }
265
265
@@ -299,9 +299,9 @@ func BenchmarkBabyjub(b *testing.B) {
299
299
300
300
var points [n ]* Point
301
301
var pointsProj [n ]* PointProjective
302
- baseX := utils .NewIntFromString (
302
+ baseX , _ := utils .NewIntFromString (
303
303
"17777552123799933955779906779655732241715742912184938656739573121738514868268" )
304
- baseY := utils .NewIntFromString (
304
+ baseY , _ := utils .NewIntFromString (
305
305
"2626589144620713026669568689430873010625803728049924121243784502389097019475" )
306
306
base := & Point {X : baseX , Y : baseY }
307
307
for i := 0 ; i < n ; i ++ {
0 commit comments