github.com/deroproject/derosuite@v2.1.6-1.0.20200307070847-0f2e589c7a2b+incompatible/crypto/edwards25519_test.go (about) 1 // Copyright 2017-2018 DERO Project. All rights reserved. 2 // Use of this source code in any form is governed by RESEARCH license. 3 // license can be found in the LICENSE file. 4 // GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8 5 // 6 // 7 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 8 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 9 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 10 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 12 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 13 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 14 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 15 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 17 package crypto 18 19 import "os" 20 import "runtime/pprof" 21 import "crypto/rand" 22 import "testing" 23 24 func TestScMulSub(t *testing.T) { 25 tests := []struct { 26 name string 27 aHex string 28 bHex string 29 cHex string 30 wantHex string 31 }{ 32 { 33 name: "simple", 34 aHex: "0100000000000000000000000000000000000000000000000000000000000000", 35 bHex: "0100000000000000000000000000000000000000000000000000000000000000", 36 cHex: "0200000000000000000000000000000000000000000000000000000000000000", 37 wantHex: "0100000000000000000000000000000000000000000000000000000000000000", 38 }, 39 { 40 name: "more complex", 41 aHex: "1000000000000000000000000000000000000000000000000000000000000000", 42 bHex: "1000000000000000000000000000000000000000000000000000000000000000", 43 cHex: "0002000000000000000000000000000000000000000000000000000000000000", 44 wantHex: "0001000000000000000000000000000000000000000000000000000000000000", 45 }, 46 { 47 name: "more complex", 48 aHex: "0000000000000000000000000000000000000000000000000000000000000010", 49 bHex: "0000000000000000000000000000000000000000000000000000000000000010", 50 cHex: "0000000000000000000000000000000000000000000000000000000000000000", 51 wantHex: "844ae3b1946c2475b8f95e806867dbac410ae82d8c1331c265cf83e4be664c0e", 52 }, 53 } 54 for _, test := range tests { 55 a := HexToKey(test.aHex) 56 b := HexToKey(test.bHex) 57 c := HexToKey(test.cHex) 58 want := HexToKey(test.wantHex) 59 var got Key 60 ScMulSub(&got, &a, &b, &c) 61 if want != got { 62 t.Errorf("%s: want %x, got %x", test.name, want, got) 63 } 64 } 65 } 66 67 func TestScalarMult(t *testing.T) { 68 tests := []struct { 69 name string 70 scalarHex string 71 pointHex string 72 wantHex string 73 }{ 74 { 75 name: "zero", 76 scalarHex: "0000000000000000000000000000000000000000000000000000000000000000", 77 pointHex: "0100000000000000000000000000000000000000000000000000000000000000", 78 wantHex: "0100000000000000000000000000000000000000000000000000000000000000", 79 }, 80 { 81 name: "basepoint * 1", 82 scalarHex: "0100000000000000000000000000000000000000000000000000000000000000", 83 pointHex: "5866666666666666666666666666666666666666666666666666666666666666", 84 wantHex: "5866666666666666666666666666666666666666666666666666666666666666", 85 }, 86 { 87 name: "basepoint * 8", 88 scalarHex: "0800000000000000000000000000000000000000000000000000000000000000", 89 pointHex: "5866666666666666666666666666666666666666666666666666666666666666", 90 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 91 }, 92 { 93 name: "basepoint * 2", 94 scalarHex: "0200000000000000000000000000000000000000000000000000000000000000", 95 pointHex: "2f1132ca61ab38dff00f2fea3228f24c6c71d58085b80e47e19515cb27e8d047", 96 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 97 }, 98 } 99 for _, test := range tests { 100 scalarBytes := HexToKey(test.scalarHex) 101 pointBytes := HexToKey(test.pointHex) 102 want := HexToKey(test.wantHex) 103 point := new(ExtendedGroupElement) 104 point.FromBytes(&pointBytes) 105 result := new(ProjectiveGroupElement) 106 GeScalarMult(result, &scalarBytes, point) 107 var got Key 108 point.ToBytes(&got) 109 110 if got != pointBytes { 111 t.Fatalf("%s: want %s, got %s point testing failed", test.name, pointBytes, got) 112 } 113 114 result.ToBytes(&got) 115 116 if want != got { 117 t.Fatalf("%s: want %s, got %s", test.name, want, got) 118 } 119 } 120 } 121 122 func TestGeMul8(t *testing.T) { 123 tests := []struct { 124 name string 125 pointHex string 126 wantHex string 127 }{ 128 { 129 name: "zero", 130 pointHex: "0100000000000000000000000000000000000000000000000000000000000000", 131 wantHex: "0100000000000000000000000000000000000000000000000000000000000000", 132 }, 133 { 134 name: "basepoint", 135 pointHex: "5866666666666666666666666666666666666666666666666666666666666666", 136 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 137 }, 138 } 139 for _, test := range tests { 140 pointBytes := HexToKey(test.pointHex) 141 want := HexToKey(test.wantHex) 142 tmp := new(ExtendedGroupElement) 143 tmp.FromBytes(&pointBytes) 144 point := new(ProjectiveGroupElement) 145 tmp.ToProjective(point) 146 tmp2 := new(CompletedGroupElement) 147 result := new(ExtendedGroupElement) 148 var got Key 149 GeMul8(tmp2, point) 150 tmp2.ToExtended(result) 151 result.ToBytes(&got) 152 if want != got { 153 t.Errorf("%s: want %x, got %x", test.name, want, got) 154 } 155 } 156 } 157 158 func TestGeDoubleScalarMultVartime(t *testing.T) { 159 tests := []struct { 160 name string 161 pointHex string 162 scalar1Hex string 163 scalar2Hex string 164 wantHex string 165 }{ 166 { 167 name: "zero", 168 pointHex: "0100000000000000000000000000000000000000000000000000000000000000", 169 scalar1Hex: "0000000000000000000000000000000000000000000000000000000000000000", 170 scalar2Hex: "0000000000000000000000000000000000000000000000000000000000000000", 171 wantHex: "0100000000000000000000000000000000000000000000000000000000000000", 172 }, 173 { 174 name: "8 times base point only", 175 pointHex: "0100000000000000000000000000000000000000000000000000000000000000", 176 scalar1Hex: "0000000000000000000000000000000000000000000000000000000000000000", 177 scalar2Hex: "0800000000000000000000000000000000000000000000000000000000000000", 178 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 179 }, 180 { 181 name: "2 times non-base-point", 182 pointHex: "2f1132ca61ab38dff00f2fea3228f24c6c71d58085b80e47e19515cb27e8d047", 183 scalar1Hex: "0200000000000000000000000000000000000000000000000000000000000000", 184 scalar2Hex: "0000000000000000000000000000000000000000000000000000000000000000", 185 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 186 }, 187 { 188 name: "Combination", 189 pointHex: "2f1132ca61ab38dff00f2fea3228f24c6c71d58085b80e47e19515cb27e8d047", 190 scalar1Hex: "0100000000000000000000000000000000000000000000000000000000000000", 191 scalar2Hex: "0400000000000000000000000000000000000000000000000000000000000000", 192 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 193 }, 194 } 195 for _, test := range tests { 196 pointBytes := HexToKey(test.pointHex) 197 a := HexToKey(test.scalar1Hex) 198 b := HexToKey(test.scalar2Hex) 199 want := HexToKey(test.wantHex) 200 point := new(ExtendedGroupElement) 201 point.FromBytes(&pointBytes) 202 result := new(ProjectiveGroupElement) 203 GeDoubleScalarMultVartime(result, &a, point, &b) 204 var got Key 205 result.ToBytes(&got) 206 if want != got { 207 t.Errorf("%s: want %x, got %x", test.name, want, got) 208 } 209 } 210 } 211 212 func TestGeDoubleScalarMultPrecompVartime(t *testing.T) { 213 tests := []struct { 214 name string 215 point1Hex string 216 point2Hex string 217 scalar1Hex string 218 scalar2Hex string 219 wantHex string 220 }{ 221 { 222 name: "zero", 223 point1Hex: "0100000000000000000000000000000000000000000000000000000000000000", 224 point2Hex: "0100000000000000000000000000000000000000000000000000000000000000", 225 scalar1Hex: "0000000000000000000000000000000000000000000000000000000000000000", 226 scalar2Hex: "0000000000000000000000000000000000000000000000000000000000000000", 227 wantHex: "0100000000000000000000000000000000000000000000000000000000000000", 228 }, 229 { 230 name: "scalar 1 only", 231 point1Hex: "5866666666666666666666666666666666666666666666666666666666666666", 232 point2Hex: "0100000000000000000000000000000000000000000000000000000000000000", 233 scalar1Hex: "0800000000000000000000000000000000000000000000000000000000000000", 234 scalar2Hex: "0000000000000000000000000000000000000000000000000000000000000000", 235 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 236 }, 237 { 238 name: "scalar 2 only", 239 point1Hex: "0100000000000000000000000000000000000000000000000000000000000000", 240 point2Hex: "5866666666666666666666666666666666666666666666666666666666666666", 241 scalar1Hex: "0000000000000000000000000000000000000000000000000000000000000000", 242 scalar2Hex: "0800000000000000000000000000000000000000000000000000000000000000", 243 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 244 }, 245 { 246 name: "Combination", 247 point1Hex: "2f1132ca61ab38dff00f2fea3228f24c6c71d58085b80e47e19515cb27e8d047", 248 point2Hex: "5866666666666666666666666666666666666666666666666666666666666666", 249 scalar1Hex: "0100000000000000000000000000000000000000000000000000000000000000", 250 scalar2Hex: "0400000000000000000000000000000000000000000000000000000000000000", 251 wantHex: "b4b937fca95b2f1e93e41e62fc3c78818ff38a66096fad6e7973e5c90006d321", 252 }, 253 } 254 for _, test := range tests { 255 point1Bytes := HexToKey(test.point1Hex) 256 point2Bytes := HexToKey(test.point2Hex) 257 a := HexToKey(test.scalar1Hex) 258 b := HexToKey(test.scalar2Hex) 259 want := HexToKey(test.wantHex) 260 point1 := new(ExtendedGroupElement) 261 point1.FromBytes(&point1Bytes) 262 point2 := new(ExtendedGroupElement) 263 point2.FromBytes(&point2Bytes) 264 var point2Precomp [8]CachedGroupElement 265 GePrecompute(&point2Precomp, point2) 266 result := new(ProjectiveGroupElement) 267 GeDoubleScalarMultPrecompVartime(result, &a, point1, &b, &point2Precomp) 268 var got Key 269 result.ToBytes(&got) 270 if want != got { 271 t.Errorf("%s: want %x, got %x", test.name, want, got) 272 } 273 } 274 } 275 276 func TestScValid(t *testing.T) { 277 // All tests from github.com/monero-project/monero/tests/crypto/tests.txt 278 tests := []struct { 279 scalarHex string 280 valid bool 281 }{ 282 { 283 scalarHex: "ac10e070c8574ef374bdd1c5dbe9bacfd927f9ae0705cf08018ff865f6092d0f", 284 valid: true, 285 }, 286 { 287 scalarHex: "fa939388e8cb0ffc5c776cc517edc2a9457c11a89820a7bee91654ce2e2fb300", 288 valid: true, 289 }, 290 { 291 scalarHex: "6d728f89e567522dffe81cf641c2e483e2cee7051c1b3cd9cd38cba09d2dc900", 292 valid: true, 293 }, 294 { 295 scalarHex: "18fd66f7a0874de792f12a1b2add7d294100ea454537ae5794d0abc91dbf098a", 296 valid: false, 297 }, 298 { 299 scalarHex: "fdb4cee00230c448aeaa4790dd12e855eca6223d81dab6bfe3fe99ce5e702325", 300 valid: false, 301 }, 302 { 303 scalarHex: "f3ab5c4a64f9afbd48c75ad25700996a69504d31c75a6aa8beb24d178cfc32ba", 304 valid: false, 305 }, 306 { 307 scalarHex: "167e88e9298926ecd66d32a890148a9adcfb80a7ecc69396edc5f5ee8848ce91", 308 valid: false, 309 }, 310 { 311 scalarHex: "a9172ced17605ab2ba82caec382f1176fe6a1e0b92a9c95679978b3999d22605", 312 valid: true, 313 }, 314 { 315 scalarHex: "44f65ce00e64cf29e07bf3843e8e43e83b8b26d3dfcd83160d9a3fedda3fc908", 316 valid: true, 317 }, 318 { 319 scalarHex: "69951c807647f4dea33f8a40b0ddef999a9e8efd1b1b176f45fb92aae6287000", 320 valid: true, 321 }, 322 { 323 scalarHex: "dcb6f94312b4b815101af10775d189301d063816b0aa9b9ac028c0eb9b17dd0e", 324 valid: true, 325 }, 326 { 327 scalarHex: "a1a9574a90bed7f58bfd4c3295e181e152a4a39f9ad56520947e94fea40dfe2e", 328 valid: false, 329 }, 330 { 331 scalarHex: "757ebb27b14433f3ed696cd291825eba555af0863862216a98cf3080432bda01", 332 valid: true, 333 }, 334 { 335 scalarHex: "a7401d68c7956d41a05d8c6c1a3cc692cc269ad8a5837f93ac2c7654abaebf0e", 336 valid: true, 337 }, 338 { 339 scalarHex: "7c84ef4d9627529723f5e171a88bba91118192e6e19929204a6d23f5a541850b", 340 valid: true, 341 }, 342 { 343 scalarHex: "ebe4b2f9eadd52271e1115aa3b89b7bb3f68d58bf74d75486b77e6ae8216f609", 344 valid: true, 345 }, 346 { 347 scalarHex: "6221caf5dfd623587ca7aac45f5312faf1c2847d7bfbc5c46f88fd933970c866", 348 valid: false, 349 }, 350 { 351 scalarHex: "b38334b41f0b829bf3a2ea73b58c16afb56ccba5144668e78257ed4aa9a33a5e", 352 valid: false, 353 }, 354 { 355 scalarHex: "92e5df37f5412d9e9910cd28d27138ba46bdd4dee5dab1125f200f0a4e66f01c", 356 valid: false, 357 }, 358 { 359 scalarHex: "2d1717fe2965133009bdcf0c13b02ca85df4dc23d969d7b16fdab94341c2b90e", 360 valid: true, 361 }, 362 { 363 scalarHex: "82d771565024cf4b5c9add6d10a4114a2fbdbf7626f03749c8bddcf6c6feee03", 364 valid: true, 365 }, 366 { 367 scalarHex: "2db0f3d9bf47666bb40ae25ef7508296af2ef665a5333efff92c9daee5ecd986", 368 valid: false, 369 }, 370 { 371 scalarHex: "47883a3f0b0e624512887f3dae6f401b2f02eb8950eb8e741f07347108fbea14", 372 valid: false, 373 }, 374 { 375 scalarHex: "dae25f27f2756b8270f78015b1beafbd03a8d67a4dd940ee9550cecae9f3560f", 376 valid: true, 377 }, 378 { 379 scalarHex: "bab79d355572361259484ca77308943b7c71f5831be5dde11b3c7a26ac6e9a01", 380 valid: true, 381 }, 382 { 383 scalarHex: "f0bf30a9862d51fd8d1ca3a4e5a0e4330a5beab751af075b2e46f3e2d0297101", 384 valid: true, 385 }, 386 { 387 scalarHex: "a94270659333c985ab1461e9820f219416ad76f551a34f4c983ca967aa6b618c", 388 valid: false, 389 }, 390 { 391 scalarHex: "98e582e9d0e485e6b756e44b1cb187e9f2d4e16c02d2713a41dcee6d7fac0205", 392 valid: true, 393 }, 394 { 395 scalarHex: "62b57869238e72f05992e01f07c7a26c71ef9e3078ee7390cd4fc6406d3b37e3", 396 valid: false, 397 }, 398 { 399 scalarHex: "c751566f5420232cd626d2bd8073debedf219a0a28a7390200a2df9df8981647", 400 valid: false, 401 }, 402 { 403 scalarHex: "cfafede7d76def164bf15047a388365d712a600f1369bf692cb2dcb249f66508", 404 valid: true, 405 }, 406 { 407 scalarHex: "c0eb03c2c46a77b0cf67bea7d547b9b4d02116f70702790398bdabbfa775100a", 408 valid: true, 409 }, 410 { 411 scalarHex: "58c5afbb7b334e921bb46eeee1dfebadfbbc3a77c420b0b325b9470eff94cc0e", 412 valid: true, 413 }, 414 { 415 scalarHex: "b31b178b4dc8f7a7c24f6eb0987e32b8a9446ce8207186259074cc3d925c530d", 416 valid: true, 417 }, 418 { 419 scalarHex: "467b2c5f63120744b5aee7ec255d170aba83babdec9e76c2690300540eb17483", 420 valid: false, 421 }, 422 { 423 scalarHex: "9bc3be487bea81da020af0353660878e7deca693ac81278fac343b8b1809bd9c", 424 valid: false, 425 }, 426 { 427 scalarHex: "162cdb42f9d9147118537cc4d5eadb8f589f6de3929188f6c41428bdab2c650e", 428 valid: true, 429 }, 430 { 431 scalarHex: "6eeb88f685d1b5c99f8c27dcadf95f5bea9082e2735a4f8aafc3c3a35f749002", 432 valid: true, 433 }, 434 { 435 scalarHex: "e03bb5c9bedc41d324ca6d988e50b7e7c6cd6d2b1e471b752a00a10a19c9a604", 436 valid: true, 437 }, 438 { 439 scalarHex: "4fa064dcef2f14fc453c30865583468ad35af81c460a643b11285c15f2babb04", 440 valid: true, 441 }, 442 { 443 scalarHex: "bf067a7b53dab7fcd6a1f5a2c8b9b54c262e9be5ea5892dba5e4ad25585be702", 444 valid: true, 445 }, 446 { 447 scalarHex: "14d8d255c2156bb12133d5ee792061a21d3fbda2f14310753f3a90c2ad4ccbc8", 448 valid: false, 449 }, 450 { 451 scalarHex: "81e78a37b7e2dfed35ad8228a6c4a6f0aa34cc1de43da23895c5c86790804e01", 452 valid: true, 453 }, 454 { 455 scalarHex: "62366805970fb07b877bf1705d9c10517c6667ab7586d9afa82c30236a72f50f", 456 valid: true, 457 }, 458 { 459 scalarHex: "bb3b0e27b7c57052e5ac20bc6390229f57c6dbc8213dbc4ee1cbb9e174e389f9", 460 valid: false, 461 }, 462 { 463 scalarHex: "5c4039f162531ce9129667ed424446ef375a18da246a72c0dab00321fa04e929", 464 valid: false, 465 }, 466 { 467 scalarHex: "8d41a450d98a6f354266e36510921649e5229412976f8f318a3090d390a46807", 468 valid: true, 469 }, 470 { 471 scalarHex: "2fbce4441723379b8b6ef417803eb9220c8fee42f72da7e36e2c64b51628a10c", 472 valid: true, 473 }, 474 { 475 scalarHex: "5bbf0e5b58e3df89a5f4c607e3033fff8b9643fc900813f4ea50b889260bb004", 476 valid: true, 477 }, 478 { 479 scalarHex: "e5acfcb2ecb7175f90aa24db107cea1be7a45bc471c4c65b9f46535768545de5", 480 valid: false, 481 }, 482 { 483 scalarHex: "fae6e8d7226e6dc25faafdd8b5c63b68587980f6e76ea59b8595f18f64a96bd5", 484 valid: false, 485 }, 486 { 487 scalarHex: "6736f7939157ccee066a40056c13d96230ca5ffd014b0ebb0a454e3d8ea6830f", 488 valid: true, 489 }, 490 { 491 scalarHex: "b2b490d52f6e4d9ef14fc1ab3e1e97160693ba5d1220e4d63956eca316693504", 492 valid: true, 493 }, 494 { 495 scalarHex: "dca490cb4e21589e045150e8c0876871f08e6b3886c6393c6348bfb432799079", 496 valid: false, 497 }, 498 { 499 scalarHex: "ca2663d84aa7d7581ac4f0a270a685019178f5288013d163028d321e92b04901", 500 valid: true, 501 }, 502 { 503 scalarHex: "7dd277472249a53620d6b21c1ab0424024581b5ae3e6ecb9a46af8511b55a408", 504 valid: true, 505 }, 506 { 507 scalarHex: "30f07adb405de73987d81fcba3d523d420d130fe753afbf3dd19d5f08e8a1356", 508 valid: false, 509 }, 510 { 511 scalarHex: "cc31de9889440c695df43a9c621a7156bc064b161be2fdef35dd8ae0e1017fe2", 512 valid: false, 513 }, 514 { 515 scalarHex: "962ac1be6677cf0d298dd1244501e6a164a915df61b83c2837f80a84541e2e03", 516 valid: true, 517 }, 518 { 519 scalarHex: "e0a1e1c48f5dfb7c0faddd9186214ec2f81fb0bc3aca423ccf0e538cf43a2bd5", 520 valid: false, 521 }, 522 { 523 scalarHex: "8ed93780cbd46092acce856a8c691edbb8419deec5acfb26fcf82419b4a964b9", 524 valid: false, 525 }, 526 { 527 scalarHex: "f62cf00cac227d2b96e7f96268f0d606ad5924b0efb64e623e25584f993c93a8", 528 valid: false, 529 }, 530 { 531 scalarHex: "e49eacd6858efad9f3bedba8b9edff5ff3d5bd622926d5e96e6e8c8752a43d25", 532 valid: false, 533 }, 534 { 535 scalarHex: "ed424965b9a79c2f6611d7d4bcbe5bae4dbf2c8130141c714acc95c492061411", 536 valid: false, 537 }, 538 { 539 scalarHex: "7ea2bb2a4dab662c3adf71eb959314208ff9dbf50b3cb1a7940e4a4d6d797e0e", 540 valid: true, 541 }, 542 { 543 scalarHex: "96fc939742b8ed518bb7aa4bb6c9bbe3fddded6b9441d9ea27712c377e0bdff1", 544 valid: false, 545 }, 546 { 547 scalarHex: "c5122ad5575b54ebce3f1d1d97c3bb0cfeb9e5ea3bb223ab63189ced40579cf4", 548 valid: false, 549 }, 550 { 551 scalarHex: "c9147f1b42890b089ae2dfdc27f69b4a29c67b8bc0264259fcf71c39e31b893c", 552 valid: false, 553 }, 554 { 555 scalarHex: "9292516356f70e84852c3a563970bff369dfc39325c64432610baa0f31f2320e", 556 valid: true, 557 }, 558 { 559 scalarHex: "85f8b6251f177701b319c5db4bc372a5cf05cb07d86b2b2d5c938b0faf6d670f", 560 valid: true, 561 }, 562 { 563 scalarHex: "de88df59b4e8e3fe2beab575b4c6ffccbd24cf294f890fa61cbc231b0c976f0d", 564 valid: true, 565 }, 566 { 567 scalarHex: "2922bd9b50e09fe75a3745c62afd5bd1813dcffcf4503668e71d8f5d37c0090d", 568 valid: true, 569 }, 570 { 571 scalarHex: "f090b3ed9355221e4fb40397c367fb31a2c7ce308ba96b9c4fc9610c14cbe305", 572 valid: true, 573 }, 574 { 575 scalarHex: "1c545854bd134a995f2138d6d088032c33a9a23a30748615652e6675d56e670f", 576 valid: true, 577 }, 578 { 579 scalarHex: "588050d78a3079a12bc88d6bcaf34a95bc6928c9233f14056277bf36bb355d26", 580 valid: false, 581 }, 582 { 583 scalarHex: "3956481800462e5c34aa2178dde33d5096c23185d61a5839c212d11e61adc901", 584 valid: true, 585 }, 586 { 587 scalarHex: "d0d61e471d5d503a6efcd549694b61851a58b0c8f8fb400227e2a48c1cbe4a0d", 588 valid: true, 589 }, 590 { 591 scalarHex: "1eed64f825d3f1bba4a226425dbef91f102ec01bcf4a0ac0a00baef8de20c405", 592 valid: true, 593 }, 594 { 595 scalarHex: "86764f74c855d580581ff17416a2c394de55bb3cb6e676756e86f3893ee61a09", 596 valid: true, 597 }, 598 { 599 scalarHex: "a1cc5ecb2a528ab8fe3efac17a2859c2ef1b81b51d18643bb3ee3fcc8794eb80", 600 valid: false, 601 }, 602 { 603 scalarHex: "740464b60e54da6a3541057742d327330ae5ac190e2b86708f5af7a1ff89fd0a", 604 valid: true, 605 }, 606 { 607 scalarHex: "ada63ca80e15912177b738c7c7618917827893b57ad20688a0a9c93c6c7c4e0a", 608 valid: true, 609 }, 610 { 611 scalarHex: "a55a6f1f2cab41704b251d3c64f3123f1635e3ee24fcce7e88cdaaf148636500", 612 valid: true, 613 }, 614 { 615 scalarHex: "515bfea540021ffb6d8f2324952a1ffa02f40adb860cff143ff0d797bd63fb09", 616 valid: true, 617 }, 618 { 619 scalarHex: "2784fbff1cad8d63b47359691caf8c7972219d7f9a64ee25fdbfe970981b2e87", 620 valid: false, 621 }, 622 { 623 scalarHex: "596071a52ac2e1b55001170c7ae5ee8a66a52e4b14db270a66c4828eccfca8a5", 624 valid: false, 625 }, 626 { 627 scalarHex: "afee887ccf82dd3406988f4afafd0d779e43d1f0f1b5107b1c3aed15d4ab57ed", 628 valid: false, 629 }, 630 { 631 scalarHex: "fb38ec6e693ee2aed1364c29dc7a60a2a7cb10601582a0ca4f4a0ca2c0499e08", 632 valid: true, 633 }, 634 { 635 scalarHex: "7f890e7539b8b3e6510a3f523a764f582f9e2c791400678eee85bd5842978c06", 636 valid: true, 637 }, 638 { 639 scalarHex: "26efbf6e436e974860ee3b6c197afa55c29b115e68b488ba46c1e865fe37f894", 640 valid: false, 641 }, 642 { 643 scalarHex: "6f6d9f15f262dde42c60af6880e8c6b6f07cab7cad785c19866f9a5c37419240", 644 valid: false, 645 }, 646 { 647 scalarHex: "f90673b823b480de9e560948307e1ada8ff1f4380e74e89ee45aa7fecae1d308", 648 valid: true, 649 }, 650 { 651 scalarHex: "269abc577fd32b1625895a1117dbc367822f9849441d4dbf7f56ca633fbf50b8", 652 valid: false, 653 }, 654 { 655 scalarHex: "26fcbe1690ff0bc306a9ec3cef75bee1a5e39710d5c02d46334fb7d89e75dc0c", 656 valid: true, 657 }, 658 { 659 scalarHex: "48c827ac48cda0f2ccd29a37884a14fa9cebe2ddf76bcc4fdf827245835d1daa", 660 valid: false, 661 }, 662 { 663 scalarHex: "9c82c6403ec29e60ad812c1762610e00c05891c6eb0fbf2393b886f298397e1a", 664 valid: false, 665 }, 666 { 667 scalarHex: "260fb700bf36504bfc5bea76c115929746f4aa709ba831fddb64b59af9bfd704", 668 valid: true, 669 }, 670 { 671 scalarHex: "aaff292106a5dd831c507603f72fb7e0b9aa5ad990575a7a3dbe83744668c552", 672 valid: false, 673 }, 674 { 675 scalarHex: "aca3f81877ac78519ce2944063fd7c50530d0ba7de2fa20ebdb1107872b6f302", 676 valid: true, 677 }, 678 { 679 scalarHex: "1086efacf20320ba25eedd1cf8d3b28348b0bf3e2191b7585e16dc9e4f7f5803", 680 valid: true, 681 }, 682 { 683 scalarHex: "66905a80d3d06c38faa5212c7455e5f48cdd5f15d816025b6466c085ef6f2d51", 684 valid: false, 685 }, 686 { 687 scalarHex: "a9fb08088371cc78c2b514608cee6b43c534e657d4e1f7d0cfd9fd4173aca769", 688 valid: false, 689 }, 690 { 691 scalarHex: "590e0a35ac44640ecf0f1f89eba200c6d98245b87360496ef408297af0011673", 692 valid: false, 693 }, 694 { 695 scalarHex: "9a83a1ab418d8d9e92e0ecde0cb1246e4b25f407c5421a3997cda43ede83930b", 696 valid: true, 697 }, 698 { 699 scalarHex: "bd3b91b68594291e859ace170fedcc64adfff013ed9f066bc625326e452ebc54", 700 valid: false, 701 }, 702 { 703 scalarHex: "ef68e423644b94c8549a9a8ca49e396d642ef0fc28448b77b2bdee1487787a0f", 704 valid: true, 705 }, 706 { 707 scalarHex: "6a6fe13345ffd78567560c8dfb511f20edfc15067212aaee69bddb77d5b4860e", 708 valid: true, 709 }, 710 { 711 scalarHex: "a1fb1f4e3e88997e4e4017a8346d37671cad86cd5d795d2550b1b9c805dfdb0f", 712 valid: true, 713 }, 714 { 715 scalarHex: "99e61e19a4c6c94354a5b7a6e206663f677223a6d3fc78659d9eaec21ef38402", 716 valid: true, 717 }, 718 { 719 scalarHex: "d4bf37268f05041950d82420a78753d168b8b808628b48d6ce7b0ed330701d02", 720 valid: true, 721 }, 722 { 723 scalarHex: "fee112a3e2de6313bc8809aba4466720c552d3615538b0523163fb01cbd1258a", 724 valid: false, 725 }, 726 { 727 scalarHex: "b9692112ef467088d7f32a873719c7f2179be1445aef71eab73f218e6d6336b9", 728 valid: false, 729 }, 730 { 731 scalarHex: "9aa00cad08702566bc88d11a2e8a99b188efd0d5fb164a1b4f3fc7378b962800", 732 valid: true, 733 }, 734 { 735 scalarHex: "b4301f1630b288b9d6a8afed5c72c10c3c3ce8c935a7aed218e8ff3f70b4a539", 736 valid: false, 737 }, 738 { 739 scalarHex: "f7f4d3bd2a84cf95d8793bd5e792510d5e95b8ce833775572e901795b5e1bd01", 740 valid: true, 741 }, 742 { 743 scalarHex: "3b7d10a8b1a2695dc00c7f12fc12c0876b27509b1ffa452c8b80643f3cd26315", 744 valid: false, 745 }, 746 { 747 scalarHex: "be2fa0a79bfa9fad3d7e9be1e5961c4849a38a1f4243a0c55d65d019a4fc5c0b", 748 valid: true, 749 }, 750 { 751 scalarHex: "a03687639bb3d2e8506fcf8d062fbc342b499dfc26d36baea80edc87674d6b0f", 752 valid: true, 753 }, 754 { 755 scalarHex: "c995ca23c04d581d52f7e550a4531b837f185ef58362b13f237964c0663f0139", 756 valid: false, 757 }, 758 { 759 scalarHex: "32865bf3762338c5e13fba1ffcc08629498a31af695813f221ebfba72ff7714b", 760 valid: false, 761 }, 762 { 763 scalarHex: "a8f37b565fe66aa2e851a74904e98c3059f92a037979da3bd4a52a10f719bf09", 764 valid: true, 765 }, 766 { 767 scalarHex: "f7474c236309d9888f0d8a53ab5a22bb4d600f3687a4e1d2815b89f866523202", 768 valid: true, 769 }, 770 { 771 scalarHex: "090d4f638d250e4588d1a25888c0b9ac6c207e4a98a9ef5a69ad0b6b1ed7ce1f", 772 valid: false, 773 }, 774 { 775 scalarHex: "6b6daf404e2b6f4e2e0398baf8627fed108d0a0bc38a364e1b5d55bfd63f6d21", 776 valid: false, 777 }, 778 { 779 scalarHex: "7e83a7bbf587be0694738f36bf52b24577a3489d72f7426ec0886a37ece4f10d", 780 valid: true, 781 }, 782 { 783 scalarHex: "5f7abc23dcf726378db619bc2ce1e86ae209daa6d1909117ce7270829c4d3da3", 784 valid: false, 785 }, 786 { 787 scalarHex: "f9ffc537ad782ce9f00f80be30e8b822c901bf62b2433c365a2f856e65f88706", 788 valid: true, 789 }, 790 { 791 scalarHex: "9d3374f71e9ad3dbad360d8a80bc8b5c0d814eb09cade0c62bc094b858849004", 792 valid: true, 793 }, 794 { 795 scalarHex: "f97097fe5d46b78e030a5207f1db92df9c8efcb0051b6e3b65cb1a58dfab660d", 796 valid: true, 797 }, 798 { 799 scalarHex: "ead8314b9663a10344eaad550137ffb0906500057efd4a28b69def67bed8a10f", 800 valid: true, 801 }, 802 { 803 scalarHex: "38ca4c5eefa2a159c05eac5e05466db588c8fbbac7df6717e1c2fc1cd15e0956", 804 valid: false, 805 }, 806 { 807 scalarHex: "9b43159b9077fb2a049aa067e1d5c1a0d16da8515934b7588f4670483050ad0e", 808 valid: true, 809 }, 810 { 811 scalarHex: "a43c8bb23b53fcd288d71d301e9cdd225bdf88e5d58ef3b485d8318c19fb9b9d", 812 valid: false, 813 }, 814 { 815 scalarHex: "2278fffc9472031130714cd01599f4a476fe5b94cd092fdc5568917fb7a479f9", 816 valid: false, 817 }, 818 { 819 scalarHex: "b78718c39d1c90448ef8787350c8baaec08de36ecde9ac234eb570397761a703", 820 valid: true, 821 }, 822 { 823 scalarHex: "48a8506dd388eb99eab0d587bf4a7bd34e68f001eb88999a76f1878c32b8e478", 824 valid: false, 825 }, 826 { 827 scalarHex: "659eb800501cccb504ae9bdcf5779ba8b2d24e4f63824c84124c453a34dd3540", 828 valid: false, 829 }, 830 { 831 scalarHex: "1ce40f32aee47060a0dadf34ce04f81c48af3218051770fb86976785f981b05e", 832 valid: false, 833 }, 834 { 835 scalarHex: "e7360d88d6dbbf3c352b80811110235a213aa5a3ea182d36c8c670ba9610a00f", 836 valid: true, 837 }, 838 { 839 scalarHex: "82934fcaed4804020e1ce4ff798c30312aff862b1371f7f74d71b4316b413806", 840 valid: true, 841 }, 842 { 843 scalarHex: "5bb1383ae3547b8caeba767eaa73a8fc08ac5972f982c736568424f8665770ac", 844 valid: false, 845 }, 846 { 847 scalarHex: "533b7c9bde705efe0c08a8a0605ea2d4c3ec21919aeca99b40e10e29ca7dc255", 848 valid: false, 849 }, 850 { 851 scalarHex: "93c1411f47251750b1b95c481d0ce55b401722273932914e2d1e78924e08fb06", 852 valid: true, 853 }, 854 { 855 scalarHex: "5b90a4fd7d50881168802f7a8da19437305e38203b6bb6ac68b114b59dfbfa0e", 856 valid: true, 857 }, 858 { 859 scalarHex: "e98125b5ad8262054c811f92d0596863ef876cb86c7f6b5783aee2e8cd6a5300", 860 valid: true, 861 }, 862 { 863 scalarHex: "3b47eac89bc19bc46dde8fb091bb1128ddfb070cbac09b65d37416d62b1d9d3a", 864 valid: false, 865 }, 866 { 867 scalarHex: "4710f6af3f144eaa2a8f1f2af329bebe752d3594c73008bad237e5e0be0cf07f", 868 valid: false, 869 }, 870 { 871 scalarHex: "a6a654a6e2d2ecd7b1daea341897658b01ab34f7e84d9fc1b3ebf8214b39a840", 872 valid: false, 873 }, 874 { 875 scalarHex: "006ba25fa6dc45938b6ab7bf6fe7096bb0eee2fc17688995a3a01567739503d2", 876 valid: false, 877 }, 878 { 879 scalarHex: "ec2a2a700045b57c85c73770fbca5896aba8941ae39035a29641891ddb309a08", 880 valid: true, 881 }, 882 { 883 scalarHex: "a6ea18e936f99d7f284553e83545cf324784e5a263f47cdcd78cfc4da10cf80b", 884 valid: true, 885 }, 886 { 887 scalarHex: "86853a4044faaa87e2a949d9623d523eae1022467816a713488ef18de5db590a", 888 valid: true, 889 }, 890 { 891 scalarHex: "0f79400a90af899e64dc6c718cb2df4f8426cc77e1745e64af2dfc4743f4ef08", 892 valid: true, 893 }, 894 { 895 scalarHex: "4b9727146720b7b9fc2bb00b7b65b18909b53558fc5c4777e2efcb336ce9f103", 896 valid: true, 897 }, 898 { 899 scalarHex: "4a71e9840fb19d79255f06456bceda85029950a9d7aebd80f19da16672ea2e4f", 900 valid: false, 901 }, 902 { 903 scalarHex: "a76d81141e740c48642aeecb93f87edbe74c94d7795c35938979913f62355350", 904 valid: false, 905 }, 906 { 907 scalarHex: "fe82ea864b773ba785ae30742142fc95a6311f1caeacba19ed019a11b3ddee06", 908 valid: true, 909 }, 910 { 911 scalarHex: "c43a927dd10a6fc47bd3888aa9d9613ba258ad838832b923251a2863691c0600", 912 valid: true, 913 }, 914 { 915 scalarHex: "55d66194e087988015066ddc0237d061163797305034f8b54524e935f832ed08", 916 valid: true, 917 }, 918 { 919 scalarHex: "650c717392bdf31373dbeda48d99fd10b76080f0319b6039f48eedc8de8daa01", 920 valid: true, 921 }, 922 { 923 scalarHex: "ef8a542e46802078598d8f41489c0d618cc19ac897719f3b298ea22cca35030c", 924 valid: true, 925 }, 926 { 927 scalarHex: "6f8be2599f25b3645571a0d3edda8d354218f1bac4e22fed861fb472ff615a04", 928 valid: true, 929 }, 930 { 931 scalarHex: "78b99806f01c239ea3e717e15a509ffc2f3c7481b5eceb365f7eb8e2ab13d907", 932 valid: true, 933 }, 934 { 935 scalarHex: "2bae1ebc0fb83cade154f1daaed5d1f03581f350e733f2f0d56a73fa3c97cf2c", 936 valid: false, 937 }, 938 { 939 scalarHex: "4c9f5a53e544ae46926b1504af11a7500f57487e62836c3f37b445c2b701dc0e", 940 valid: true, 941 }, 942 { 943 scalarHex: "162003195972b318297a38632d9859bc86f1677154f94996970a320e0d23aa05", 944 valid: true, 945 }, 946 { 947 scalarHex: "9563b33d7a9a751d3c8ae2b4536bc2ed7cf5231051191653d7c08d502357ed0b", 948 valid: true, 949 }, 950 { 951 scalarHex: "2ffc2e41884b11129e1cc83aa95cd0b44dacb040a9ff1809a353597af8af0736", 952 valid: false, 953 }, 954 { 955 scalarHex: "ebfb376fb3a20871f35a54ecc2bf0003a2f2d00838196f0860e229c1db21e90c", 956 valid: true, 957 }, 958 { 959 scalarHex: "3da00eff81fd6771a23481fa8719fbe674c0dffa8db583e5fc0da7c9a0713006", 960 valid: true, 961 }, 962 { 963 scalarHex: "2d492ad9915f6274a6b62cdc245204527a1216b4ef0e7e1e1d3aa6d81f0c3905", 964 valid: true, 965 }, 966 { 967 scalarHex: "1a6d227bc48af4cff57ab11dc7ba3b7da21a9998b05dbeea4c05ca8bcffe2277", 968 valid: false, 969 }, 970 { 971 scalarHex: "8db67435b9e243dfbb58f252061ca3a005d197b941fa1f9cbbd29fbeafd507d4", 972 valid: false, 973 }, 974 { 975 scalarHex: "b2f744640c89049ebbbf94bd3013d3103ccf0e750a810543b39601116dc3300d", 976 valid: true, 977 }, 978 { 979 scalarHex: "8177e87433900f41dbdc22db054c79995f6f610647bcee7527f51091f5198274", 980 valid: false, 981 }, 982 { 983 scalarHex: "2c7cbaa6142473cecdb1c10bf9fc2430984a4b6cd34afc607668c6d88bf24f06", 984 valid: true, 985 }, 986 { 987 scalarHex: "a0a2ccb60bcbd0eda5dd11540e3517462bd841d58d4aed185beb5cfbda9e5f34", 988 valid: false, 989 }, 990 { 991 scalarHex: "767219f2581c07b1bbccd62fe4af10b4e202538fe918cedefbba3297bc89b604", 992 valid: true, 993 }, 994 { 995 scalarHex: "ed8828a708c013d80fe558be718b1e738063c4eca7528c06067b73d9dd2adccc", 996 valid: false, 997 }, 998 { 999 scalarHex: "4e81f8c4a0166a40db4063b31a5a4e511648b0f094d8930d956f74a7bec44f03", 1000 valid: true, 1001 }, 1002 { 1003 scalarHex: "09d5a71ca33bbc186f06b5ece548f25b0d008ad71c04e55d3d4c5fe0ef960b19", 1004 valid: false, 1005 }, 1006 { 1007 scalarHex: "51aa0d12359bc5819055618be5955824d81bd6e5ef52d51ee7e75aa9ca09edc4", 1008 valid: false, 1009 }, 1010 { 1011 scalarHex: "94927b83b0f167631a5c8eae13a9290c027f795dbd0c3d0f2d1a270b65db05e4", 1012 valid: false, 1013 }, 1014 { 1015 scalarHex: "e30c00666b11f332690267f3a2b8caa93a9a6e3961522a4ef886f3768f4c4166", 1016 valid: false, 1017 }, 1018 { 1019 scalarHex: "6ec7e22c9921501879a85c89c2833e04526538c6cbdecd8a040fe6c57c881c06", 1020 valid: true, 1021 }, 1022 { 1023 scalarHex: "54a4299c9d8572857247843d38842926fc88064905d8041974a1d9d407313a0f", 1024 valid: true, 1025 }, 1026 { 1027 scalarHex: "d4604b16400e77f37e8f6f5cc4ced1ef0da8f2a832bf6a0f51321d221111ce83", 1028 valid: false, 1029 }, 1030 { 1031 scalarHex: "a545d4cb99de9fc8f976356996351009628be30201dd42a11f7b379a5099c40b", 1032 valid: true, 1033 }, 1034 { 1035 scalarHex: "7db6f2c324cda1f3c9b39d659e5b5e39ad8e4b65e31e3afc10e91f890d6c0b9f", 1036 valid: false, 1037 }, 1038 { 1039 scalarHex: "afee4fe9a50c0d0aba669ca7f866ac4eb16e83afd843f142caf1132b9c5bcd11", 1040 valid: false, 1041 }, 1042 { 1043 scalarHex: "03cf1b6414acc2990bf4df95a9afa40aefcbc55946f8f40298cec7b45e942b09", 1044 valid: true, 1045 }, 1046 { 1047 scalarHex: "82c67f0cc06d1f5d878e710dc3734dc9b698fbd43b9cfaa50bc0734240631eee", 1048 valid: false, 1049 }, 1050 { 1051 scalarHex: "ef10fc4f79bdfade5af636fd41a7e5c48e966b5562693fd7a95568f52d472d06", 1052 valid: true, 1053 }, 1054 { 1055 scalarHex: "0ce4ab8a2f342f7ff2fd10b1b734d5333c7f8240075b2ae8522313d192d8a01d", 1056 valid: false, 1057 }, 1058 { 1059 scalarHex: "745a1228beb514bac4521c342b345f301fb28e7bfebb85d3c22497d4474fe904", 1060 valid: true, 1061 }, 1062 { 1063 scalarHex: "684cfecbb321a4236354e94fd8bc74c22a28f1a3ee7e21193b0cf264204fce51", 1064 valid: false, 1065 }, 1066 { 1067 scalarHex: "14a31b0cf4630e8e74730979d661c1902ab2f47823244ff7809be751b273b00c", 1068 valid: true, 1069 }, 1070 { 1071 scalarHex: "6c0c31a9e40faf4ead079582dae043bee80f27fbb8b76ffa5c960083d578ac0f", 1072 valid: true, 1073 }, 1074 { 1075 scalarHex: "ef49cd4030926ad3dbc08425fedfed7de48a1ca119259abec5600be5b60deb0f", 1076 valid: true, 1077 }, 1078 { 1079 scalarHex: "b432db4174848e42b9a680c74d66e746a48cb397b4008815064178cf7acec91c", 1080 valid: false, 1081 }, 1082 { 1083 scalarHex: "8c041643a91de5b9a652c3edb1b2512656daf33521197f7ab01056aa04d33708", 1084 valid: true, 1085 }, 1086 { 1087 scalarHex: "d683e2784298e070cd686eddc848e1ce3205c42822650cf9bc2301fb9a330564", 1088 valid: false, 1089 }, 1090 { 1091 scalarHex: "48ad5703dbf88a809d1bde1d295c4e51e3cf24215a3136c251c165505f80e84e", 1092 valid: false, 1093 }, 1094 { 1095 scalarHex: "19d22f694db4b90b5500af61b7d6a26d5568b4a3048ddef5709698ed6df8820b", 1096 valid: true, 1097 }, 1098 { 1099 scalarHex: "f8d5164c397f22c6b8cf3ae26ebfa4a9fe893afc2d7aec1f7c4f1e46c9eca306", 1100 valid: true, 1101 }, 1102 { 1103 scalarHex: "64a5a328e130e416cf1b3fb3accd3bd032f66df404f5364e0ec9d18d652196c2", 1104 valid: false, 1105 }, 1106 { 1107 scalarHex: "300931fb2c3670af36168883af39e10e1593945114e11c4eee9547d253f4f504", 1108 valid: true, 1109 }, 1110 { 1111 scalarHex: "0bbe9316029ea6d59883574d39d1fcd3af3344d73033e2b615f0883361a11602", 1112 valid: true, 1113 }, 1114 { 1115 scalarHex: "75609b2f7a8c04053ba7c1dbfc1b7c2a8f00720817d1abd2dc1db11645bbaaa1", 1116 valid: false, 1117 }, 1118 { 1119 scalarHex: "fa98e50dd3e3fa8308ffe861194920ec6b4f431eb34c67d7332a92830a7cb20d", 1120 valid: true, 1121 }, 1122 { 1123 scalarHex: "50b48576275008950b552a94e32d25c0835cb6dd44e146519848c9a7ee003707", 1124 valid: true, 1125 }, 1126 { 1127 scalarHex: "032487e8b30ddec54b5cf90cbc38dde71104169e48228c2336916f1575c1c005", 1128 valid: true, 1129 }, 1130 { 1131 scalarHex: "574fe8ee31b42bcb9224c34c34ddca2908db4b5f4f630ce76244d1257f81e504", 1132 valid: true, 1133 }, 1134 { 1135 scalarHex: "a4bba7f4765850dd77a67e56cf89e3c8967ba8f3c72ba14c7ea014202f81780b", 1136 valid: true, 1137 }, 1138 { 1139 scalarHex: "90eca818a69f6b8c52bddee273f37eaa96c58f2322fa5f09de36d606edc2ef04", 1140 valid: true, 1141 }, 1142 { 1143 scalarHex: "ac689dc28cb94239b78e6dd66249feec0519686e0a3f974ef8d4760d320de842", 1144 valid: false, 1145 }, 1146 { 1147 scalarHex: "a578412ffcd608f1fc4d77b954b5650d5016a24747e08664373a6c1c8d61c71a", 1148 valid: false, 1149 }, 1150 { 1151 scalarHex: "d5b2f9a4b3ae8dcfc1a2ade16b320d7d00180ad72e9ba500cfeceb4e45335c00", 1152 valid: true, 1153 }, 1154 { 1155 scalarHex: "ba26b0105b5d74df01e27ac128303cf4f139b2d164772ce56a31b5787b5d2207", 1156 valid: true, 1157 }, 1158 { 1159 scalarHex: "fb9e9e404f5901ffc02ba848ed33c98a88365ff161b4d484f67f8d4d2bc9fe85", 1160 valid: false, 1161 }, 1162 { 1163 scalarHex: "e326865f9ee2b68fdff8c36d39672f897669d9efb52bd4b4d037f4e219f72887", 1164 valid: false, 1165 }, 1166 { 1167 scalarHex: "8d911a2a666472a69614bbdd887169936e4e4384992cffac6f5c8ad3f81da708", 1168 valid: true, 1169 }, 1170 { 1171 scalarHex: "a9c04591640432f35dcdcdbe5027080c31613253f01a8e4fb1c2ed04f3e8c2a1", 1172 valid: false, 1173 }, 1174 { 1175 scalarHex: "e5e18376596aa363f1de26fb318eadaee85792bb7e51af164ba80da6e358ac03", 1176 valid: true, 1177 }, 1178 { 1179 scalarHex: "2632ef6ab45b46f2a48b5691c3e82e54e50ba74f23751aa602ec77a39596a10d", 1180 valid: true, 1181 }, 1182 { 1183 scalarHex: "f110202b14458789eb17321f757032e3515012143e8dd156a401d0b48ebb6287", 1184 valid: false, 1185 }, 1186 { 1187 scalarHex: "82d4274f7518f0cf92637657c69407a5fccb685ce9de8fa617a6f6f6b86c290d", 1188 valid: true, 1189 }, 1190 { 1191 scalarHex: "e1d9512e60b4dab6b55f14f56c320ad8eda6b8e378c5f873ce5d89c622c76c0c", 1192 valid: true, 1193 }, 1194 { 1195 scalarHex: "adf9a384148ff31f52f4e2365c5234b93edd574df1b5b664650859a764130f07", 1196 valid: true, 1197 }, 1198 { 1199 scalarHex: "f5c8043c4b5a3a1ded6d02af7e048d298872e8fedbdfdb544b881215313956f9", 1200 valid: false, 1201 }, 1202 { 1203 scalarHex: "cd7d1bd7c2bf26b7060d2407dbd88a5ba4add8044436bcbf6e00e690eae29699", 1204 valid: false, 1205 }, 1206 { 1207 scalarHex: "af5b7ede9808e45e80f427d27e660443851ee2063d53c23dacb487b6b375807f", 1208 valid: false, 1209 }, 1210 { 1211 scalarHex: "3a854a6125fbae08eeaf8f29177b83cec19f8f23f82e1c0213acfda03a19a057", 1212 valid: false, 1213 }, 1214 { 1215 scalarHex: "307e8bc876b71a1ad7da7e3f8687d3173a6605184b912d80b34cec7abd09fd05", 1216 valid: true, 1217 }, 1218 { 1219 scalarHex: "5936e762cfe201af05d2e7082a10e5f58cb71cee179406eb026b05437211f5a0", 1220 valid: false, 1221 }, 1222 { 1223 scalarHex: "c02d9bb9b3ce61da67d7eb839ad6135b28485be17b6749a5d07a3a442e33890a", 1224 valid: true, 1225 }, 1226 { 1227 scalarHex: "766459f999aa16992ec9639aed4e1ecdd7b78c6ab7cc63400f2f2dbad02796e7", 1228 valid: false, 1229 }, 1230 { 1231 scalarHex: "39be058fddfed6dee0840cd03f7c407c3a30b0a0e87cc8ada9772b4150fd9a07", 1232 valid: true, 1233 }, 1234 { 1235 scalarHex: "18c994dad23375e3860e21ce5d430ef2b876820bd0fe9e84a3b3a5ba45c790c5", 1236 valid: false, 1237 }, 1238 { 1239 scalarHex: "0583e64db042f0e22e7abd759ef1b51ab5155314caf362de34781e8da9b4a20b", 1240 valid: true, 1241 }, 1242 { 1243 scalarHex: "8d71c7122df856668387356a704a0bcd1865493b65ab254b24c9bd06c5414386", 1244 valid: false, 1245 }, 1246 { 1247 scalarHex: "ca94f5f35fe069a057e9a9431e7ea3b99c7efd9700c0f838d3b99ab82648d343", 1248 valid: false, 1249 }, 1250 { 1251 scalarHex: "850d3c5acb9103049e0ce06fcd64a543a38bf20fb31ce3a47e275d1e043c5506", 1252 valid: true, 1253 }, 1254 { 1255 scalarHex: "06580accc5c48aa72ce261547614b8629c10e2ee8d62971f8453b2007f91a60f", 1256 valid: true, 1257 }, 1258 { 1259 scalarHex: "bef7fb38fcb2d6a5c22f1db03c4c26a0f61eaaa1e7f846b2bb46ff06aa9ca407", 1260 valid: true, 1261 }, 1262 { 1263 scalarHex: "fc7956e14919bb2f531c6cba13e0bf3568db3927b24a2f9131e0c42aac0cbbb1", 1264 valid: false, 1265 }, 1266 { 1267 scalarHex: "bf2ed7b0fdd8cc1222db5ae9e699de5d54abee91a3f8bd988d248ab041738aa3", 1268 valid: false, 1269 }, 1270 { 1271 scalarHex: "126213a8e3de2ab1fc862ad8bb27d3b13de5ba55657bf6e04efcf4015dd70895", 1272 valid: false, 1273 }, 1274 { 1275 scalarHex: "d1729b969a9395788931713933c587ef3748c96976a488f6a1e2f1e1ed6973d0", 1276 valid: false, 1277 }, 1278 { 1279 scalarHex: "2448345de229bb4c2695f9653653301c4562ff4a60c568a3f483474b6800875c", 1280 valid: false, 1281 }, 1282 { 1283 scalarHex: "e72284802f2737c293838a6357251398101ec60ba6e8458304bbd25de570010b", 1284 valid: true, 1285 }, 1286 { 1287 scalarHex: "87c0898c4c283f24b7164fa8aaab9fc3b06ad5237b389d9735d58c54dd989186", 1288 valid: false, 1289 }, 1290 { 1291 scalarHex: "4cceb19c61263feaffeedc984280a6f5ecc1eeebeed05a407359661d61bdf8a6", 1292 valid: false, 1293 }, 1294 { 1295 scalarHex: "2e286296d5300eb4ae7200036acbd47a319d3f9a8eb66a986a36683b85b26002", 1296 valid: true, 1297 }, 1298 { 1299 scalarHex: "1b7140ff3a09a82554d4219425c2213abd16d9f342e30e2f7c05f2a5188432a4", 1300 valid: false, 1301 }, 1302 { 1303 scalarHex: "c0cdfe0ac8dd014bc1fb4c5d3f22d74f30623054f3008c0d1e34af4f2eafdec4", 1304 valid: false, 1305 }, 1306 { 1307 scalarHex: "0000000000000000000000000000000000000000000000000000000000000000", 1308 valid: true, 1309 }, 1310 { 1311 scalarHex: "0100000000000000000000000000000000000000000000000000000000000000", 1312 valid: true, 1313 }, 1314 { 1315 scalarHex: "0200000000000000000000000000000000000000000000000000000000000000", 1316 valid: true, 1317 }, 1318 { 1319 scalarHex: "0300000000000000000000000000000000000000000000000000000000000000", 1320 valid: true, 1321 }, 1322 { 1323 scalarHex: "0400000000000000000000000000000000000000000000000000000000000000", 1324 valid: true, 1325 }, 1326 { 1327 scalarHex: "0500000000000000000000000000000000000000000000000000000000000000", 1328 valid: true, 1329 }, 1330 { 1331 scalarHex: "0600000000000000000000000000000000000000000000000000000000000000", 1332 valid: true, 1333 }, 1334 { 1335 scalarHex: "0700000000000000000000000000000000000000000000000000000000000000", 1336 valid: true, 1337 }, 1338 { 1339 scalarHex: "0800000000000000000000000000000000000000000000000000000000000000", 1340 valid: true, 1341 }, 1342 { 1343 scalarHex: "0900000000000000000000000000000000000000000000000000000000000000", 1344 valid: true, 1345 }, 1346 { 1347 scalarHex: "0a00000000000000000000000000000000000000000000000000000000000000", 1348 valid: true, 1349 }, 1350 { 1351 scalarHex: "0b00000000000000000000000000000000000000000000000000000000000000", 1352 valid: true, 1353 }, 1354 { 1355 scalarHex: "0c00000000000000000000000000000000000000000000000000000000000000", 1356 valid: true, 1357 }, 1358 { 1359 scalarHex: "0d00000000000000000000000000000000000000000000000000000000000000", 1360 valid: true, 1361 }, 1362 { 1363 scalarHex: "0e00000000000000000000000000000000000000000000000000000000000000", 1364 valid: true, 1365 }, 1366 { 1367 scalarHex: "0f00000000000000000000000000000000000000000000000000000000000000", 1368 valid: true, 1369 }, 1370 { 1371 scalarHex: "1000000000000000000000000000000000000000000000000000000000000000", 1372 valid: true, 1373 }, 1374 { 1375 scalarHex: "1100000000000000000000000000000000000000000000000000000000000000", 1376 valid: true, 1377 }, 1378 { 1379 scalarHex: "1200000000000000000000000000000000000000000000000000000000000000", 1380 valid: true, 1381 }, 1382 { 1383 scalarHex: "1300000000000000000000000000000000000000000000000000000000000000", 1384 valid: true, 1385 }, 1386 { 1387 scalarHex: "d9d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1388 valid: true, 1389 }, 1390 { 1391 scalarHex: "dad3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1392 valid: true, 1393 }, 1394 { 1395 scalarHex: "dbd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1396 valid: true, 1397 }, 1398 { 1399 scalarHex: "dcd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1400 valid: true, 1401 }, 1402 { 1403 scalarHex: "ddd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1404 valid: true, 1405 }, 1406 { 1407 scalarHex: "ded3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1408 valid: true, 1409 }, 1410 { 1411 scalarHex: "dfd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1412 valid: true, 1413 }, 1414 { 1415 scalarHex: "e0d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1416 valid: true, 1417 }, 1418 { 1419 scalarHex: "e1d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1420 valid: true, 1421 }, 1422 { 1423 scalarHex: "e2d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1424 valid: true, 1425 }, 1426 { 1427 scalarHex: "e3d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1428 valid: true, 1429 }, 1430 { 1431 scalarHex: "e4d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1432 valid: true, 1433 }, 1434 { 1435 scalarHex: "e5d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1436 valid: true, 1437 }, 1438 { 1439 scalarHex: "e6d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1440 valid: true, 1441 }, 1442 { 1443 scalarHex: "e7d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1444 valid: true, 1445 }, 1446 { 1447 scalarHex: "e8d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1448 valid: true, 1449 }, 1450 { 1451 scalarHex: "e9d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1452 valid: true, 1453 }, 1454 { 1455 scalarHex: "ead3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1456 valid: true, 1457 }, 1458 { 1459 scalarHex: "ebd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1460 valid: true, 1461 }, 1462 { 1463 scalarHex: "ecd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1464 valid: true, 1465 }, 1466 { 1467 scalarHex: "edd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1468 valid: false, 1469 }, 1470 { 1471 scalarHex: "eed3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1472 valid: false, 1473 }, 1474 { 1475 scalarHex: "efd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1476 valid: false, 1477 }, 1478 { 1479 scalarHex: "f0d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1480 valid: false, 1481 }, 1482 { 1483 scalarHex: "f1d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1484 valid: false, 1485 }, 1486 { 1487 scalarHex: "f2d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1488 valid: false, 1489 }, 1490 { 1491 scalarHex: "f3d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1492 valid: false, 1493 }, 1494 { 1495 scalarHex: "f4d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1496 valid: false, 1497 }, 1498 { 1499 scalarHex: "f5d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1500 valid: false, 1501 }, 1502 { 1503 scalarHex: "f6d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1504 valid: false, 1505 }, 1506 { 1507 scalarHex: "f7d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1508 valid: false, 1509 }, 1510 { 1511 scalarHex: "f8d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1512 valid: false, 1513 }, 1514 { 1515 scalarHex: "f9d3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1516 valid: false, 1517 }, 1518 { 1519 scalarHex: "fad3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1520 valid: false, 1521 }, 1522 { 1523 scalarHex: "fbd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1524 valid: false, 1525 }, 1526 { 1527 scalarHex: "fcd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1528 valid: false, 1529 }, 1530 { 1531 scalarHex: "fdd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1532 valid: false, 1533 }, 1534 { 1535 scalarHex: "fed3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1536 valid: false, 1537 }, 1538 { 1539 scalarHex: "ffd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1540 valid: false, 1541 }, 1542 { 1543 scalarHex: "00d4f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1544 valid: false, 1545 }, 1546 { 1547 scalarHex: "01d4f55c1a631258d69cf7a2def9de1400000000000000000000000000000010", 1548 valid: false, 1549 }, 1550 { 1551 scalarHex: "ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1552 valid: false, 1553 }, 1554 { 1555 scalarHex: "edffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1556 valid: false, 1557 }, 1558 { 1559 scalarHex: "eeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1560 valid: false, 1561 }, 1562 { 1563 scalarHex: "efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1564 valid: false, 1565 }, 1566 { 1567 scalarHex: "f0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1568 valid: false, 1569 }, 1570 { 1571 scalarHex: "f1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1572 valid: false, 1573 }, 1574 { 1575 scalarHex: "f2ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1576 valid: false, 1577 }, 1578 { 1579 scalarHex: "f3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1580 valid: false, 1581 }, 1582 { 1583 scalarHex: "f4ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1584 valid: false, 1585 }, 1586 { 1587 scalarHex: "f5ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1588 valid: false, 1589 }, 1590 { 1591 scalarHex: "f6ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1592 valid: false, 1593 }, 1594 { 1595 scalarHex: "f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1596 valid: false, 1597 }, 1598 { 1599 scalarHex: "f8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1600 valid: false, 1601 }, 1602 { 1603 scalarHex: "f9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1604 valid: false, 1605 }, 1606 { 1607 scalarHex: "faffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1608 valid: false, 1609 }, 1610 { 1611 scalarHex: "fbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1612 valid: false, 1613 }, 1614 { 1615 scalarHex: "fcffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1616 valid: false, 1617 }, 1618 { 1619 scalarHex: "fdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1620 valid: false, 1621 }, 1622 { 1623 scalarHex: "feffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1624 valid: false, 1625 }, 1626 { 1627 scalarHex: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 1628 valid: false, 1629 }, 1630 } 1631 for _, test := range tests { 1632 scalar := HexToKey(test.scalarHex) 1633 got := ScValid(&scalar) 1634 if test.valid != got { 1635 t.Errorf("%x: want %t, got %t", scalar, test.valid, got) 1636 } 1637 } 1638 } 1639 1640 func TestAddKeys3_3(t *testing.T) { 1641 1642 for i := 0; i < 1000; i++ { 1643 s1 := *(RandomScalar()) 1644 s2 := *(RandomScalar()) //*(identity()) // *(RandomScalar()) 1645 1646 p1 := s1.PublicKey() 1647 p2 := s2.PublicKey() 1648 1649 first_part := ScalarMultKey(p1, &s1) 1650 second_part := ScalarMultKey(p2, &s2) 1651 1652 // do it traditional way 1653 var sum_result Key 1654 AddKeys(&sum_result, first_part, second_part) 1655 1656 // lets do it optimal way, pre compute 1657 var p1_extended, p2_extended ExtendedGroupElement 1658 var p1_precomputed, p2_precomputed [8]CachedGroupElement 1659 1660 p1_extended.FromBytes(p1) 1661 p2_extended.FromBytes(p2) 1662 1663 GePrecompute(&p1_precomputed, &p1_extended) 1664 GePrecompute(&p2_precomputed, &p2_extended) 1665 1666 var fast_result Key 1667 AddKeys3_3(&fast_result, &s1, &p1_precomputed, &s2, &p2_precomputed) 1668 1669 if sum_result != fast_result { 1670 t.Fatalf("AddKeys3_3 Failed Expected %s Actual %s", sum_result, fast_result) 1671 } 1672 } 1673 1674 } 1675 1676 func TestElements(t *testing.T) { 1677 1678 for i := 0; i < 100; i++ { 1679 p1 := *(RandomScalar()).PublicKey() 1680 p2 := *(RandomScalar()).PublicKey() 1681 1682 var exp1, exp2 ExtendedGroupElement 1683 var cached CachedGroupElement 1684 var precomputed PreComputedGroupElement 1685 var actual, naive, fast Key 1686 var tmpe ExtendedGroupElement 1687 1688 exp1.FromBytes(&p1) 1689 exp2.FromBytes(&p2) 1690 1691 //original 1692 AddKeys(&actual, &p1, &p2) 1693 1694 // naive 1695 var r CompletedGroupElement 1696 exp2.ToCached(&cached) 1697 geAdd(&r, &exp1, &cached) 1698 r.ToExtended(&tmpe) 1699 tmpe.ToBytes(&naive) 1700 1701 if actual != naive { 1702 t.Fatalf("Naive addition failed") 1703 } 1704 1705 exp2.ToPreComputed(&precomputed) 1706 geMixedAdd(&r, &exp1, &precomputed) 1707 r.ToExtended(&tmpe) 1708 tmpe.ToBytes(&fast) 1709 1710 if actual != fast { 1711 t.Fatalf("Fast addition failed") 1712 } 1713 } 1714 } 1715 1716 func TestPrecompute(t *testing.T) { 1717 1718 var table PRECOMPUTE_TABLE 1719 1720 s1 := *(RandomScalar()) 1721 //p1 := &GBASE //identity() // s1.PublicKey() 1722 p1 := s1.PublicKey() 1723 1724 GenPrecompute(&table, *p1) 1725 1726 //s1[1]=29 1727 1728 expected := ScalarMultKey(p1, &s1) 1729 1730 var actual Key 1731 1732 var result_extended ExtendedGroupElement 1733 ScalarMultPrecompute(&result_extended, &s1, &table) 1734 1735 result_extended.ToBytes(&actual) 1736 1737 //t.Logf("Super compute Expected %s actual %s", expected,actual) 1738 1739 if actual != *expected { 1740 t.Logf("Super compute failed Expected %s actual %s", expected, actual) 1741 } 1742 1743 } 1744 1745 func TestSuperPrecompute(t *testing.T) { 1746 var table PRECOMPUTE_TABLE 1747 var stable SUPER_PRECOMPUTE_TABLE 1748 1749 s1 := *(RandomScalar()) 1750 p1 := s1.PublicKey() 1751 1752 GenPrecompute(&table, *p1) 1753 GenSuperPrecompute(&stable, &table) 1754 1755 //s1[1]=29 1756 1757 expected := ScalarMultKey(p1, &s1) 1758 1759 var actual Key 1760 1761 var result_extended ExtendedGroupElement 1762 ScalarMultSuperPrecompute(&result_extended, &s1, &stable) 1763 1764 result_extended.ToBytes(&actual) 1765 1766 //t.Logf("Super compute Expected %s actual %s", expected,actual) 1767 1768 if actual != *expected { 1769 t.Logf("Super compute failed Expected %s actual %s", expected, actual) 1770 } 1771 1772 } 1773 1774 func Test_DoubleScalarDoubleBaseMulPrecomputed(t *testing.T) { 1775 1776 var ex ExtendedGroupElement 1777 1778 s1 := *(RandomScalar()) 1779 s2 := *(RandomScalar()) //*(RandomScalar()) //*(identity()) // *(RandomScalar()) 1780 1781 p1 := s1.PublicKey() 1782 p2 := s2.PublicKey() 1783 1784 first_part := ScalarMultKey(p1, &s1) 1785 second_part := ScalarMultKey(p2, &s2) 1786 1787 // do it traditional way 1788 var sum_result Key 1789 var actual Key 1790 AddKeys(&sum_result, first_part, second_part) 1791 1792 // lets do it using precomputed tables 1793 var table PRECOMPUTE_TABLE 1794 1795 GenDoublePrecompute(&table, *p1, *p2) 1796 1797 /* 1798 multprecompscalar(&ex,&s1) 1799 1800 1801 ex.ToBytes(&actual) 1802 1803 if *first_part != actual{ 1804 1805 //t.Logf("%+v table ", table) 1806 t.Fatalf("simple scalar precompyed failed expected %s actual %s", sum_result,actual) 1807 } 1808 */ 1809 1810 DoubleScalarDoubleBaseMulPrecomputed(&ex, &s1, &s2, &table) 1811 ex.ToBytes(&actual) 1812 1813 // t.Logf("first part %s", first_part) 1814 // t.Logf("second_part part %s", second_part) 1815 // t.Logf("actual %s expected %s", actual,sum_result) 1816 1817 if sum_result != actual { 1818 1819 //t.Logf("%+v table ", table) 1820 t.Fatalf("Double scalar precompyed failed %s %s", sum_result, actual) 1821 } 1822 1823 } 1824 1825 func BenchmarkDoublePrecompute(b *testing.B) { 1826 var table PRECOMPUTE_TABLE 1827 1828 s1 := *(identity()) // *(RandomScalar()) 1829 s2 := *(identity()) //*(RandomScalar()) //*(identity()) // *(RandomScalar()) 1830 1831 p1 := identity() //s1.PublicKey() 1832 p2 := s2.PublicKey() 1833 1834 GenDoublePrecompute(&table, *p1, *p2) 1835 1836 cpufile, err := os.Create("/tmp/dprecompute_cpuprofile.prof") 1837 if err != nil { 1838 1839 } 1840 if err := pprof.StartCPUProfile(cpufile); err != nil { 1841 } 1842 defer pprof.StopCPUProfile() 1843 1844 var result_extended ExtendedGroupElement 1845 result_extended.Zero() // make it identity 1846 1847 b.ResetTimer() 1848 1849 for i := 0; i < b.N; i++ { 1850 DoubleScalarDoubleBaseMulPrecomputed(&result_extended, &s1, &s2, &table) 1851 1852 } 1853 } 1854 1855 // test 64 bit version used for bulletproofs 1856 func Test_DoubleScalarDoubleBaseMulPrecomputed64(t *testing.T) { 1857 1858 var s1, s2 [64]Key 1859 var p1, p2 [64]Key 1860 1861 for i := 0; i < 64; i++ { 1862 s1[i] = *(RandomScalar()) 1863 s2[i] = *(RandomScalar()) //*(RandomScalar()) //*(identity()) // *(RandomScalar()) 1864 1865 p1[i] = *(s1[i].PublicKey()) 1866 p2[i] = *(s2[i].PublicKey()) 1867 1868 } 1869 1870 // compute actual result using naive method 1871 naive_result := Identity 1872 for i := 0; i < 64; i++ { 1873 1874 first_part := ScalarMultKey(&p1[i], &s1[i]) 1875 second_part := ScalarMultKey(&p2[i], &s2[i]) 1876 1877 // do it traditional way 1878 var sum_result Key 1879 AddKeys(&sum_result, first_part, second_part) 1880 AddKeys(&naive_result, &naive_result, &sum_result) 1881 1882 } 1883 1884 // lets do it using precomputed tables 1885 var table [64]PRECOMPUTE_TABLE 1886 for i := 0; i < 64; i++ { 1887 GenDoublePrecompute(&table[i], p1[i], p2[i]) 1888 } 1889 1890 var ex ExtendedGroupElement 1891 var actual Key 1892 DoubleScalarDoubleBaseMulPrecomputed64(&ex, s1[:], s2[:], table[:]) 1893 1894 ex.ToBytes(&actual) 1895 1896 // t.Logf("first part %s", first_part) 1897 // t.Logf("second_part part %s", second_part) 1898 // t.Logf("actual %s expected %s", actual,sum_result) 1899 1900 if naive_result != actual { 1901 1902 //t.Logf("%+v table ", table) 1903 t.Fatalf("Double scalar precomputed 64 failed expected %s actual %s", naive_result, actual) 1904 } 1905 1906 } 1907 1908 // test 64 bit version used for bulletproofs 1909 func Benchmark_DoubleScalarDoubleBaseMulPrecomputed64(b *testing.B) { 1910 1911 var s1, s2 [64]Key 1912 var p1, p2 [64]Key 1913 1914 for i := 0; i < 64; i++ { 1915 s1[i] = *(RandomScalar()) 1916 s2[i] = *(RandomScalar()) //*(RandomScalar()) //*(identity()) // *(RandomScalar()) 1917 1918 p1[i] = *(s1[i].PublicKey()) 1919 p2[i] = *(s2[i].PublicKey()) 1920 1921 } 1922 1923 // compute actual result using naive method 1924 naive_result := Identity 1925 for i := 0; i < 64; i++ { 1926 1927 first_part := ScalarMultKey(&p1[i], &s1[i]) 1928 second_part := ScalarMultKey(&p2[i], &s2[i]) 1929 1930 // do it traditional way 1931 var sum_result Key 1932 AddKeys(&sum_result, first_part, second_part) 1933 AddKeys(&naive_result, &naive_result, &sum_result) 1934 1935 } 1936 1937 // lets do it using precomputed tables 1938 var table [64]PRECOMPUTE_TABLE 1939 for i := 0; i < 64; i++ { 1940 GenDoublePrecompute(&table[i], p1[i], p2[i]) 1941 } 1942 1943 var ex ExtendedGroupElement 1944 var actual Key 1945 1946 b.ResetTimer() 1947 1948 for i := 0; i < b.N; i++ { 1949 DoubleScalarDoubleBaseMulPrecomputed64(&ex, s1[:], s2[:], table[:]) 1950 1951 ex.ToBytes(&actual) 1952 1953 // t.Logf("first part %s", first_part) 1954 // t.Logf("second_part part %s", second_part) 1955 // t.Logf("actual %s expected %s", actual,sum_result) 1956 1957 if naive_result != actual { 1958 1959 //t.Logf("%+v table ", table) 1960 b.Fatalf("Double scalar precomputed 64 failed expected %s actual %s", naive_result, actual) 1961 } 1962 } 1963 1964 } 1965 1966 func BenchmarkPrecompute(b *testing.B) { 1967 var table PRECOMPUTE_TABLE 1968 1969 GenPrecompute(&table, GBASE) 1970 1971 s1 := *(RandomScalar()) 1972 //s1[1]=29 1973 1974 /* 1975 cpufile,err := os.Create("/tmp/precompute_cpuprofile.prof") 1976 if err != nil{ 1977 1978 } 1979 if err := pprof.StartCPUProfile(cpufile); err != nil { 1980 } 1981 defer pprof.StopCPUProfile() 1982 1983 */ 1984 1985 var result_extended ExtendedGroupElement 1986 result_extended.Zero() // make it identity 1987 1988 b.ResetTimer() 1989 1990 for i := 0; i < b.N; i++ { 1991 result_extended.Zero() // make it identity 1992 1993 ScalarMultPrecompute(&result_extended, &s1, &table) 1994 1995 } 1996 } 1997 1998 func BenchmarkSuperPrecompute(b *testing.B) { 1999 var table PRECOMPUTE_TABLE 2000 var stable SUPER_PRECOMPUTE_TABLE 2001 2002 GenPrecompute(&table, GBASE) 2003 GenSuperPrecompute(&stable, &table) 2004 2005 s1 := *(RandomScalar()) 2006 //s1[1]=29 2007 2008 /* 2009 cpufile,err := os.Create("/tmp/superprecompute_cpuprofile.prof") 2010 if err != nil{ 2011 2012 } 2013 if err := pprof.StartCPUProfile(cpufile); err != nil { 2014 } 2015 defer pprof.StopCPUProfile() 2016 2017 */ 2018 2019 var result_extended ExtendedGroupElement 2020 result_extended.Zero() // make it identity 2021 2022 b.ResetTimer() 2023 2024 for i := 0; i < b.N; i++ { 2025 result_extended.Zero() // make it identity 2026 2027 ScalarMultSuperPrecompute(&result_extended, &s1, &stable) 2028 2029 } 2030 } 2031 2032 func BenchmarkGeScalarMultBase(b *testing.B) { 2033 var s Key 2034 rand.Reader.Read(s[:]) 2035 var P ExtendedGroupElement 2036 2037 b.ResetTimer() 2038 for i := 0; i < b.N; i++ { 2039 GeScalarMultBase(&P, &s) 2040 } 2041 } 2042 2043 func BenchmarkGeScalarMult(b *testing.B) { 2044 var s Key 2045 rand.Reader.Read(s[:]) 2046 2047 var P ExtendedGroupElement 2048 var E ProjectiveGroupElement 2049 s[31] &= 127 2050 GeScalarMultBase(&P, &s) 2051 2052 b.ResetTimer() 2053 for i := 0; i < b.N; i++ { 2054 GeScalarMult(&E, &s, &P) 2055 } 2056 } 2057 2058 func BenchmarkGeDoubleScalarMultVartime(b *testing.B) { 2059 var s Key 2060 rand.Reader.Read(s[:]) 2061 2062 var P, Pout ExtendedGroupElement 2063 s[31] &= 127 2064 GeScalarMultBase(&P, &s) 2065 _ = Pout 2066 2067 var out ProjectiveGroupElement 2068 2069 b.ResetTimer() 2070 var x Key 2071 for i := 0; i < b.N; i++ { 2072 GeDoubleScalarMultVartime(&out, &s, &P, &x) 2073 //out.ToExtended(&Pout) 2074 } 2075 } 2076 2077 /* 2078 func BenchmarkGeAdd(b *testing.B) { 2079 var s Key 2080 rand.Reader.Read(s[:]) 2081 2082 var R, P ExtendedGroupElement 2083 s[31] &= 127 2084 GeScalarMultBase(&P, &s) 2085 R = P 2086 2087 b.ResetTimer() 2088 for i := 0; i < b.N; i++ { 2089 GeAdd(&R, &R, &P) 2090 } 2091 } 2092 */ 2093 2094 /* 2095 func BenchmarkGeDouble(b *testing.B) { 2096 var s [32]byte 2097 rand.Reader.Read(s[:]) 2098 2099 var R, P ExtendedGroupElement 2100 s[31] &= 127 2101 GeScalarMultBase(&P, &s) 2102 R = P 2103 2104 b.ResetTimer() 2105 for i := 0; i < b.N; i++ { 2106 GeDouble(&R, &P) 2107 } 2108 } 2109 */