-
Notifications
You must be signed in to change notification settings - Fork 1
/
elligator_test.go
408 lines (385 loc) · 19.8 KB
/
elligator_test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
package ed448
import (
. "gopkg.in/check.v1"
)
func (s *Ed448Suite) Test_PointFromNonUniformHash(c *C) {
ser := [56]byte{
0x0d, 0xc3, 0x50, 0x83, 0xbd, 0x0d, 0x55, 0xd3,
0xdd, 0x8c, 0x50, 0x28, 0x1c, 0x32, 0x77, 0x7e,
0x62, 0x03, 0x82, 0xa3, 0x18, 0x72, 0xc1, 0x7b,
0xc2, 0x69, 0x11, 0xb7, 0x34, 0xbd, 0x2b, 0xc4,
0x26, 0x3b, 0x82, 0xc2, 0x12, 0x3c, 0x2a, 0x3c,
0xe7, 0x49, 0x3c, 0x21, 0xfb, 0xb2, 0xb5, 0xe2,
0x41, 0xa8, 0xce, 0xa6, 0xb7, 0xf1, 0xc1, 0x3f,
}
exp := &twExtendedPoint{
&bigNumber{
0x333bf6, 0x348f59f, 0xfa8f51, 0x1a45b6f,
0xc96ff10, 0xd7f98a3, 0xd0c0b22, 0x6a3b696,
0x832df79, 0x2824845, 0xd78421b, 0x748a71,
0x5d67a95, 0x566135d, 0xd4ac41a, 0x3ace179,
},
&bigNumber{
0x4650aac, 0xb984b48, 0x4b3deb4, 0x1f7c40,
0x5766713, 0x938ae1c, 0x14e14aa, 0x23088a8,
0x2a3d97a, 0xfc23e90, 0xd9b4f23, 0x9a3bef4,
0xdf20d8e, 0xcd9cc1d, 0xb76a0d7, 0x48ad86d,
},
&bigNumber{
0xcb1854c, 0xf29cb25, 0x3159292, 0x2101752,
0xbc095c5, 0x13ccc0a, 0x7058e53, 0x7b77b37,
0x5316c77, 0xaa930cd, 0x2a179e8, 0x4a4fca6,
0xe91a389, 0x1593de7, 0xff691f7, 0x623b4c1,
},
&bigNumber{
0x2470f89, 0x72c68a3, 0xa7701ab, 0x41b2e5a,
0x5958957, 0x22ca902, 0xf5b72a5, 0x7ddc067,
0xe724bec, 0x67350a2, 0x842d3e1, 0x413c1d8,
0xdb8a266, 0xf2472a6, 0xb630473, 0x8468933,
},
}
p := pointFromNonUniformHash(ser)
c.Assert(p.x, DeepEquals, exp.x)
c.Assert(p.y, DeepEquals, exp.y)
c.Assert(p.z, DeepEquals, exp.z)
c.Assert(p.t, DeepEquals, exp.t)
}
var elligatorTestVectorsInput = [][]byte{
{0x2d, 0x86, 0xa1, 0x42, 0x33, 0x8d, 0xe2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f,
0x72, 0xf8, 0xf2, 0xf6, 0x7e, 0x75, 0x24, 0xff, 0x91, 0xd6, 0xf6, 0xc8, 0xa7, 0x56,
0xab, 0x03, 0x96, 0x7a, 0x64, 0x89, 0x42, 0x71, 0xe7, 0x1e, 0x71, 0xd8, 0x95, 0x72,
0x9f, 0x06, 0x31, 0xfd, 0x7c, 0x0d, 0xe1, 0xc2, 0x73, 0xc0, 0x90, 0x92, 0x43, 0x23},
{0x9b, 0x30, 0x03, 0x76, 0xa4, 0xb9, 0x5e, 0xa2, 0x02, 0x4b, 0xdb, 0xd9, 0x7a, 0x96,
0x93, 0xc3, 0xf6, 0x0a, 0xe0, 0xbb, 0xdb, 0xda, 0xfc, 0x47, 0x09, 0x27, 0x8b, 0x65,
0x34, 0xc8, 0xa2, 0xd5, 0xff, 0x9b, 0xb3, 0xd2, 0x10, 0xd9, 0x49, 0xd5, 0xbf, 0x09,
0x49, 0x19, 0xb9, 0x0d, 0x2f, 0x0f, 0xf9, 0x82, 0xed, 0x92, 0x79, 0x95, 0xdc, 0x60},
{0x90, 0x95, 0x7d, 0x59, 0x78, 0x10, 0xb2, 0x7b, 0x84, 0x9a, 0x69, 0x1f, 0x5d, 0x27,
0xd5, 0x48, 0x96, 0x3d, 0x35, 0x4a, 0xe9, 0xe2, 0x9a, 0xd5, 0x9a, 0x23, 0x0a, 0x15,
0x5a, 0xaa, 0x6f, 0xe7, 0xc5, 0x4c, 0x82, 0xd5, 0x08, 0x14, 0xd8, 0xfd, 0xcd, 0x2d,
0x3b, 0xb1, 0xe5, 0x53, 0xa8, 0x41, 0xf9, 0x71, 0xd7, 0x24, 0xa4, 0x64, 0x7a, 0xba},
}
var elligatorTestVectorsOutput = [][]byte{
{0xa6, 0x99, 0x3b, 0x5a, 0x6c, 0xbb, 0x40, 0x71, 0x6e, 0xb2, 0xaf, 0xa1, 0x53, 0x05,
0x27, 0x75, 0xd2, 0x55, 0xff, 0x2f, 0x64, 0x4e, 0x2f, 0x91, 0x32, 0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0xf7, 0xe3, 0x4d, 0x27, 0x02, 0xea, 0xdb, 0xbe,
0x80, 0xeb, 0xcf, 0x94, 0x4c, 0x2a, 0x54, 0x2a, 0x98, 0x35, 0x59, 0xd9, 0x24, 0x8a},
{0x50, 0xdf, 0xb7, 0xe7, 0x92, 0x92, 0xf3, 0xb0, 0x4e, 0x0d, 0x5c, 0x73, 0x8a, 0xf2,
0xba, 0xc6, 0xda, 0xdf, 0x00, 0xe5, 0x37, 0x7b, 0xbf, 0xc1, 0xe7, 0x13, 0xe1, 0xda,
0x5f, 0xa1, 0xa3, 0xc2, 0xfd, 0x4b, 0x10, 0x81, 0x0d, 0x99, 0xcf, 0x8f, 0xca, 0x91,
0x37, 0x3e, 0x47, 0x8a, 0x84, 0xab, 0xcd, 0x65, 0xdf, 0xf9, 0x27, 0x3c, 0x13, 0xf1},
{0xe4, 0xe1, 0xa4, 0x8d, 0x1d, 0x72, 0xe2, 0x72, 0x3b, 0x09, 0x09, 0xf9, 0x7f, 0xcd,
0x57, 0x0d, 0xdf, 0x8c, 0xdc, 0x47, 0xdf, 0x6d, 0xfa, 0x6a, 0x8d, 0x67, 0x45, 0x4f,
0x6b, 0x44, 0x6d, 0xbf, 0xf3, 0x41, 0x1c, 0x57, 0x1c, 0xf0, 0x77, 0x14, 0x06, 0xf6,
0x8c, 0xb9, 0xa3, 0x40, 0x34, 0x70, 0xd6, 0x36, 0xe5, 0xa6, 0xce, 0x1b, 0x84, 0xcc},
}
func (s *Ed448Suite) Test_elligator_testVectors(c *C) {
for ix, v := range elligatorTestVectorsInput {
var inp [56]byte
var exp serialized
q := &twExtendedPoint{
x: &bigNumber{},
y: &bigNumber{},
z: &bigNumber{},
t: &bigNumber{},
}
copy(exp[:], elligatorTestVectorsOutput[ix])
copy(inp[:], v)
decafDecode(q, exp, false)
p := pointFromNonUniformHash(inp)
c.Assert(p.Equals(q), Equals, true)
}
}
func (s *Ed448Suite) Test_PointFromUniformHash(c *C) {
ser := [112]byte{
0x15, 0x1d, 0xb9, 0x33, 0x08, 0xd8, 0xe2, 0xeb,
0x97, 0x7c, 0x97, 0xf3, 0x16, 0xcf, 0x43, 0xd3,
0x0b, 0x45, 0x67, 0x2b, 0x83, 0x17, 0xd7, 0x1c,
0x39, 0xe8, 0x8a, 0xfc, 0x5f, 0x81, 0xa1, 0x4f,
0x0d, 0x35, 0x86, 0xf0, 0xc3, 0xd9, 0x14, 0xa2,
0x22, 0xa7, 0x49, 0x6c, 0x37, 0x87, 0x9c, 0x5c,
0xd7, 0x8b, 0xd5, 0x8a, 0x4a, 0x03, 0x98, 0x7a,
0xcc, 0x94, 0x46, 0xcb, 0xa2, 0xd6, 0x4b, 0xe0,
0x09, 0xbe, 0xca, 0x3c, 0xbf, 0x3e, 0xab, 0xc2,
0x7f, 0x57, 0xa8, 0x09, 0x1b, 0x02, 0x29, 0xae,
0xc0, 0x8b, 0x1e, 0x70, 0x35, 0xcc, 0x7a, 0x04,
0x37, 0x32, 0x96, 0x47, 0x38, 0x7e, 0xc7, 0xfe,
0x43, 0x6f, 0x71, 0xc0, 0x0c, 0x29, 0xf3, 0x59,
0x17, 0x3f, 0x5d, 0x49, 0x06, 0x8b, 0x03, 0xd9,
}
exp := &twExtendedPoint{
&bigNumber{
0x0733a0e6, 0x0565dc88, 0x05b952cf, 0x0ac980c7,
0x06f8790a, 0x068b9aa4, 0x03ffb7ac, 0x0f9498f8,
0x0c9f684f, 0x05a4009e, 0x0d3b77fa, 0x05d415d3,
0x0c1b1986, 0x08e8f930, 0x0e71fded, 0x0c4e739,
},
&bigNumber{
0x69f3a21, 0x68162b, 0xde028ac, 0xe630df1,
0x11624e6, 0xb906e9d, 0x32bf83b, 0x6a2ecad,
0xdcd4912, 0x3c6cb80, 0x42fea3e, 0x1e3abf9,
0xa1cfe30, 0x7e2ef28, 0xde0fd5d, 0xab1f02f,
},
&bigNumber{
0xefd11da, 0xf0d00fe, 0x2c0aa2, 0x7dad43d,
0xc6d9a72, 0x36e95fc, 0x7581bda, 0xc15e0e6,
0xfcdb211, 0xadccc30, 0x5ad0c9b, 0x9944eba,
0x259e9b0, 0x80ed3be, 0xa45f8f4, 0xa45fef7,
},
&bigNumber{
0x1303ca8, 0x508047a, 0x51aca8e, 0xb65f114,
0xb5ed74b, 0x340d7df, 0x76e6f27, 0x251cd2a,
0xf0bd360, 0xa047eb2, 0x50c4ad0, 0x76addbe,
0x194e63a, 0xc910898, 0x265ddac, 0x8d02176,
},
}
p := pointFromUniformHash(ser)
c.Assert(p.x, DeepEquals, exp.x)
c.Assert(p.y, DeepEquals, exp.y)
c.Assert(p.z, DeepEquals, exp.z)
c.Assert(p.t, DeepEquals, exp.t)
}
func (s *Ed448Suite) Test_InvertElligatorNonUniform(c *C) {
p := &twExtendedPoint{
&bigNumber{
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0ffffffe, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
},
&bigNumber{
0x00000000, 0x01000000, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0ffffffe, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
},
&bigNumber{
0x0ffffffe, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0ffffffe, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
},
&bigNumber{
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0ffffffe, 0x0fffffff, 0x0fffffff, 0x0fffffff,
0x0fffffff, 0x0fffffff, 0x0fffffff, 0x0fffffff,
},
}
exp := [56]byte{
0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
ser, ok := invertElligatorNonUniform(p, word(0x01))
c.Assert(ser, DeepEquals, exp)
c.Assert(ok, Equals, true)
q := &twExtendedPoint{
&bigNumber{
0x07a9207e, 0x016130d5, 0x010497c8, 0x075f03fb,
0x0b50d815, 0x0b185d70, 0x0029d45a, 0x01d4d572,
0x04939594, 0x092be6fb, 0x01b851dd, 0x080ba46f,
0x00e58dd4, 0x02a256f7, 0x0a30d0a0, 0x095ec3cd,
},
&bigNumber{
0x00923a40, 0x002eee8c, 0x0d19ff94, 0x04093df5,
0x0f158f1e, 0x01d57e7a, 0x0a387f85, 0x0ea1c535,
0x036af3c6, 0x098713a4, 0x047d691d, 0x044101c5,
0x0d217bc4, 0x07a787b7, 0x06589af3, 0x0cbdfd81,
},
&bigNumber{
0x038a5f41, 0x04f8ce5e, 0x02012801, 0x0d839806,
0x0630513e, 0x0c4f0e13, 0x030358c0, 0x0074703a,
0x0aa04899, 0x0d4f4768, 0x05c7127d, 0x0ef4c099,
0x05e36d5b, 0x07f1e299, 0x01e079a0, 0x05909da2,
},
&bigNumber{
0x0fdc305f, 0x04c698f8, 0x022c3e10, 0x0f1538b6,
0x0ebf17a1, 0x0a31b24a, 0x03821060, 0x0e7cf360,
0x0d8bc54d, 0x08d025e7, 0x019756d3, 0x0a7be4de,
0x067dd8b9, 0x00c19582, 0x0044f64e, 0x096cd541,
},
}
exp2 := [56]byte{
0xbf, 0x4f, 0xb4, 0x45, 0x84, 0x59, 0x5c, 0x3c,
0x4e, 0x04, 0x44, 0x87, 0xdb, 0x8d, 0xf6, 0x1d,
0xe9, 0x0c, 0x04, 0x3c, 0x9f, 0x2d, 0x92, 0x09,
0x5d, 0xe4, 0xb6, 0xb7, 0x0a, 0x76, 0x25, 0x38,
0x92, 0x4c, 0xef, 0x12, 0xaf, 0x27, 0x3b, 0x00,
0xee, 0xd7, 0xdb, 0x0c, 0x1c, 0xed, 0xa7, 0x0a,
0x32, 0xf7, 0x52, 0x4a, 0x7e, 0x79, 0xa9, 0xd9,
}
ser2, ok2 := invertElligatorNonUniform(q, word(0x07))
c.Assert(ser2, DeepEquals, exp2)
c.Assert(ok2, Equals, true)
}
func (s *Ed448Suite) Test_InvertElligatorUniform(c *C) {
p := &twExtendedPoint{
&bigNumber{
0x0fc18ee8, 0x06e52384, 0x090f51e9, 0x02090a94,
0x0314d5f3, 0x0813d5d0, 0x01d8ea67, 0x0d01dcbe,
0x0930c74f, 0x051b42c9, 0x04d2a414, 0x058c7d3b,
0x0858ed59, 0x06cac045, 0x0d8a80e7, 0x021a5a8e,
},
&bigNumber{
0x04232323, 0x09b24e49, 0x04384c1a, 0x001bf8e4,
0x0c09a485, 0x00bf20b5, 0x0906679f, 0x0b88a665,
0x073d389f, 0x053fc152, 0x0edab941, 0x08dd83c8,
0x054e0716, 0x0eb04549, 0x01bb1c4e, 0x0b870d06,
},
&bigNumber{
0x0f075470, 0x08535015, 0x05b5b1bb, 0x048e5d42,
0x0f8c5a7c, 0x0050ecdf, 0x0ebdc995, 0x0ccb0cf2,
0x0d048eda, 0x0180ed00, 0x08436d25, 0x04c69104,
0x07e469aa, 0x0f7ea8ea, 0x09d25f90, 0x0f1960b9,
},
&bigNumber{
0x08b93b9a, 0x0fd7d592, 0x0db0cc77, 0x02fdd1c2,
0x0dcd7ad4, 0x0b2aea7e, 0x01f71af2, 0x086a9d4b,
0x092bbef3, 0x0a7ac451, 0x0eb40b5d, 0x04560fbd,
0x057107d7, 0x01204ba7, 0x0c1740f4, 0x0a7b08e0,
},
}
src := [112]byte{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x24, 0xcc, 0x70, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
exp := [112]byte{
0x7f, 0x48, 0x75, 0xc5, 0x6d, 0xc0, 0xb5, 0x3d,
0xfd, 0x10, 0xfa, 0x38, 0x80, 0x16, 0x9c, 0x9c,
0x06, 0xc0, 0xa7, 0xdb, 0x75, 0x9f, 0xa9, 0x8e,
0x02, 0x65, 0xd9, 0x8d, 0x10, 0x74, 0x12, 0x88,
0xef, 0x66, 0x6a, 0x4c, 0x05, 0xe9, 0x64, 0xb6,
0xcf, 0xb3, 0x53, 0x30, 0xba, 0x92, 0x3f, 0x08,
0x27, 0xa0, 0x83, 0x68, 0x19, 0xe9, 0x5b, 0xaf,
0x24, 0xcc, 0x70, 0x7e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
ser, ok := invertElligatorUniform(src, p, word(0x06))
c.Assert(ser, DeepEquals, exp)
c.Assert(ok, Equals, true)
}