7 #if defined HAVE_CONFIG_H
22 #ifdef ENABLE_OPENSSL_TESTS
23 #include "openssl/bn.h"
24 #include "openssl/ec.h"
25 #include "openssl/ecdsa.h"
26 #include "openssl/obj_mac.h"
27 # if OPENSSL_VERSION_NUMBER < 0x10100000L
28 void ECDSA_SIG_get0(
const ECDSA_SIG *sig,
const BIGNUM **pr,
const BIGNUM **ps) {*pr = sig->r; *ps = sig->s;}
56 unsigned char b32[32];
76 CHECK(fe->magnitude == n);
109 unsigned char b32[32];
122 unsigned char b32[32];
143 unsigned char ctmp[32];
150 void *none_prealloc = NULL;
151 void *sign_prealloc = NULL;
152 void *vrfy_prealloc = NULL;
153 void *both_prealloc = NULL;
165 CHECK(none_prealloc != NULL);
166 CHECK(sign_prealloc != NULL);
167 CHECK(vrfy_prealloc != NULL);
168 CHECK(both_prealloc != NULL);
180 memset(&zero_pubkey, 0,
sizeof(zero_pubkey));
269 CHECK(ecount2 == 10);
271 CHECK(ecount2 == 11);
275 CHECK(ecount2 == 12);
279 CHECK(ecount2 == 13);
285 CHECK(ecount2 == 14);
295 CHECK(ecount2 == 14);
297 CHECK(ecount2 == 14);
351 CHECK(scratch != NULL);
393 memset(&local_scratch, 0,
sizeof(local_scratch));
394 scratch = &local_scratch;
422 static const char *inputs[8] = {
423 "",
"abc",
"message digest",
"secure hash algorithm",
"SHA256 is considered to be safe",
424 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
425 "For this sample, this 63-byte string will be used as input data",
426 "This is exactly 64 bytes long, not counting the terminating byte"
428 static const unsigned char outputs[8][32] = {
429 {0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55},
430 {0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, 0xb4, 0x10, 0xff, 0x61, 0xf2, 0x00, 0x15, 0xad},
431 {0xf7, 0x84, 0x6f, 0x55, 0xcf, 0x23, 0xe1, 0x4e, 0xeb, 0xea, 0xb5, 0xb4, 0xe1, 0x55, 0x0c, 0xad, 0x5b, 0x50, 0x9e, 0x33, 0x48, 0xfb, 0xc4, 0xef, 0xa3, 0xa1, 0x41, 0x3d, 0x39, 0x3c, 0xb6, 0x50},
432 {0xf3, 0x0c, 0xeb, 0x2b, 0xb2, 0x82, 0x9e, 0x79, 0xe4, 0xca, 0x97, 0x53, 0xd3, 0x5a, 0x8e, 0xcc, 0x00, 0x26, 0x2d, 0x16, 0x4c, 0xc0, 0x77, 0x08, 0x02, 0x95, 0x38, 0x1c, 0xbd, 0x64, 0x3f, 0x0d},
433 {0x68, 0x19, 0xd9, 0x15, 0xc7, 0x3f, 0x4d, 0x1e, 0x77, 0xe4, 0xe1, 0xb5, 0x2d, 0x1f, 0xa0, 0xf9, 0xcf, 0x9b, 0xea, 0xea, 0xd3, 0x93, 0x9f, 0x15, 0x87, 0x4b, 0xd9, 0x88, 0xe2, 0xa2, 0x36, 0x30},
434 {0x24, 0x8d, 0x6a, 0x61, 0xd2, 0x06, 0x38, 0xb8, 0xe5, 0xc0, 0x26, 0x93, 0x0c, 0x3e, 0x60, 0x39, 0xa3, 0x3c, 0xe4, 0x59, 0x64, 0xff, 0x21, 0x67, 0xf6, 0xec, 0xed, 0xd4, 0x19, 0xdb, 0x06, 0xc1},
435 {0xf0, 0x8a, 0x78, 0xcb, 0xba, 0xee, 0x08, 0x2b, 0x05, 0x2a, 0xe0, 0x70, 0x8f, 0x32, 0xfa, 0x1e, 0x50, 0xc5, 0xc4, 0x21, 0xaa, 0x77, 0x2b, 0xa5, 0xdb, 0xb4, 0x06, 0xa2, 0xea, 0x6b, 0xe3, 0x42},
436 {0xab, 0x64, 0xef, 0xf7, 0xe8, 0x8e, 0x2e, 0x46, 0x16, 0x5e, 0x29, 0xf2, 0xbc, 0xe4, 0x18, 0x26, 0xbd, 0x4c, 0x7b, 0x35, 0x52, 0xf6, 0xb3, 0x82, 0xa9, 0xe7, 0xd3, 0xaf, 0x47, 0xc2, 0x45, 0xf8}
439 for (i = 0; i < 8; i++) {
440 unsigned char out[32];
446 if (strlen(inputs[i]) > 0) {
458 static const char *keys[6] = {
459 "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
461 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
462 "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19",
463 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
464 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"
466 static const char *inputs[6] = {
467 "\x48\x69\x20\x54\x68\x65\x72\x65",
468 "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f",
469 "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd",
470 "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd",
471 "\x54\x65\x73\x74\x20\x55\x73\x69\x6e\x67\x20\x4c\x61\x72\x67\x65\x72\x20\x54\x68\x61\x6e\x20\x42\x6c\x6f\x63\x6b\x2d\x53\x69\x7a\x65\x20\x4b\x65\x79\x20\x2d\x20\x48\x61\x73\x68\x20\x4b\x65\x79\x20\x46\x69\x72\x73\x74",
472 "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d\x2e"
474 static const unsigned char outputs[6][32] = {
475 {0xb0, 0x34, 0x4c, 0x61, 0xd8, 0xdb, 0x38, 0x53, 0x5c, 0xa8, 0xaf, 0xce, 0xaf, 0x0b, 0xf1, 0x2b, 0x88, 0x1d, 0xc2, 0x00, 0xc9, 0x83, 0x3d, 0xa7, 0x26, 0xe9, 0x37, 0x6c, 0x2e, 0x32, 0xcf, 0xf7},
476 {0x5b, 0xdc, 0xc1, 0x46, 0xbf, 0x60, 0x75, 0x4e, 0x6a, 0x04, 0x24, 0x26, 0x08, 0x95, 0x75, 0xc7, 0x5a, 0x00, 0x3f, 0x08, 0x9d, 0x27, 0x39, 0x83, 0x9d, 0xec, 0x58, 0xb9, 0x64, 0xec, 0x38, 0x43},
477 {0x77, 0x3e, 0xa9, 0x1e, 0x36, 0x80, 0x0e, 0x46, 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7, 0x29, 0x59, 0x09, 0x8b, 0x3e, 0xf8, 0xc1, 0x22, 0xd9, 0x63, 0x55, 0x14, 0xce, 0xd5, 0x65, 0xfe},
478 {0x82, 0x55, 0x8a, 0x38, 0x9a, 0x44, 0x3c, 0x0e, 0xa4, 0xcc, 0x81, 0x98, 0x99, 0xf2, 0x08, 0x3a, 0x85, 0xf0, 0xfa, 0xa3, 0xe5, 0x78, 0xf8, 0x07, 0x7a, 0x2e, 0x3f, 0xf4, 0x67, 0x29, 0x66, 0x5b},
479 {0x60, 0xe4, 0x31, 0x59, 0x1e, 0xe0, 0xb6, 0x7f, 0x0d, 0x8a, 0x26, 0xaa, 0xcb, 0xf5, 0xb7, 0x7f, 0x8e, 0x0b, 0xc6, 0x21, 0x37, 0x28, 0xc5, 0x14, 0x05, 0x46, 0x04, 0x0f, 0x0e, 0xe3, 0x7f, 0x54},
480 {0x9b, 0x09, 0xff, 0xa7, 0x1b, 0x94, 0x2f, 0xcb, 0x27, 0x63, 0x5f, 0xbc, 0xd5, 0xb0, 0xe9, 0x44, 0xbf, 0xdc, 0x63, 0x64, 0x4f, 0x07, 0x13, 0x93, 0x8a, 0x7f, 0x51, 0x53, 0x5c, 0x3a, 0x35, 0xe2}
483 for (i = 0; i < 6; i++) {
485 unsigned char out[32];
490 if (strlen(inputs[i]) > 0) {
502 static const unsigned char key1[65] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x00, 0x4b, 0xf5, 0x12, 0x2f, 0x34, 0x45, 0x54, 0xc5, 0x3b, 0xde, 0x2e, 0xbb, 0x8c, 0xd2, 0xb7, 0xe3, 0xd1, 0x60, 0x0a, 0xd6, 0x31, 0xc3, 0x85, 0xa5, 0xd7, 0xcc, 0xe2, 0x3c, 0x77, 0x85, 0x45, 0x9a, 0};
503 static const unsigned char out1[3][32] = {
504 {0x4f, 0xe2, 0x95, 0x25, 0xb2, 0x08, 0x68, 0x09, 0x15, 0x9a, 0xcd, 0xf0, 0x50, 0x6e, 0xfb, 0x86, 0xb0, 0xec, 0x93, 0x2c, 0x7b, 0xa4, 0x42, 0x56, 0xab, 0x32, 0x1e, 0x42, 0x1e, 0x67, 0xe9, 0xfb},
505 {0x2b, 0xf0, 0xff, 0xf1, 0xd3, 0xc3, 0x78, 0xa2, 0x2d, 0xc5, 0xde, 0x1d, 0x85, 0x65, 0x22, 0x32, 0x5c, 0x65, 0xb5, 0x04, 0x49, 0x1a, 0x0c, 0xbd, 0x01, 0xcb, 0x8f, 0x3a, 0xa6, 0x7f, 0xfd, 0x4a},
506 {0xf5, 0x28, 0xb4, 0x10, 0xcb, 0x54, 0x1f, 0x77, 0x00, 0x0d, 0x7a, 0xfb, 0x6c, 0x5b, 0x53, 0xc5, 0xc4, 0x71, 0xea, 0xb4, 0x3e, 0x46, 0x6d, 0x9a, 0xc5, 0x19, 0x0c, 0x39, 0xc8, 0x2f, 0xd8, 0x2e}
509 static const unsigned char key2[64] = {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, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55};
510 static const unsigned char out2[3][32] = {
511 {0x9c, 0x23, 0x6c, 0x16, 0x5b, 0x82, 0xae, 0x0c, 0xd5, 0x90, 0x65, 0x9e, 0x10, 0x0b, 0x6b, 0xab, 0x30, 0x36, 0xe7, 0xba, 0x8b, 0x06, 0x74, 0x9b, 0xaf, 0x69, 0x81, 0xe1, 0x6f, 0x1a, 0x2b, 0x95},
512 {0xdf, 0x47, 0x10, 0x61, 0x62, 0x5b, 0xc0, 0xea, 0x14, 0xb6, 0x82, 0xfe, 0xee, 0x2c, 0x9c, 0x02, 0xf2, 0x35, 0xda, 0x04, 0x20, 0x4c, 0x1d, 0x62, 0xa1, 0x53, 0x6c, 0x6e, 0x17, 0xae, 0xd7, 0xa9},
513 {0x75, 0x97, 0x88, 0x7c, 0xbd, 0x76, 0x32, 0x1f, 0x32, 0xe3, 0x04, 0x40, 0x67, 0x9a, 0x22, 0xcf, 0x7f, 0x8d, 0x9d, 0x2e, 0xac, 0x39, 0x0e, 0x58, 0x1f, 0xea, 0x09, 0x1c, 0xe2, 0x02, 0xba, 0x94}
517 unsigned char out[32];
521 for (i = 0; i < 3; i++) {
528 for (i = 0; i < 3; i++) {
535 for (i = 0; i < 3; i++) {
547 static const unsigned int rounds[7] = {1, 30, 73, 156, 322, 653, 1316};
550 static const uint32_t mults[6] = {1, 3, 21, 289, 0x9999, 0x80402011};
552 unsigned int usebits = bits > 6 ? 6 : bits;
553 unsigned int maxshift = bits - usebits;
556 uint64_t x[6][27] = {{0}};
557 unsigned int i, shift, m;
560 for (i = 0; i < rounds[usebits]; i++) {
562 CHECK((((uint64_t)r) >> bits) == 0);
563 for (m = 0; m <
sizeof(mults) /
sizeof(mults[0]); m++) {
564 uint32_t rm = r * mults[m];
565 for (shift = 0; shift <= maxshift; shift++) {
566 x[m][shift] |= (((uint64_t)1) << ((rm >> shift) & ((1 << usebits) - 1)));
570 for (m = 0; m <
sizeof(mults) /
sizeof(mults[0]); m++) {
571 for (shift = 0; shift <= maxshift; shift++) {
573 CHECK(((~x[m][shift]) << (64 - (1 << usebits))) == 0);
581 int rounds = (subrange * 2073) / 100;
584 CHECK((range % subrange) == 0);
585 for (i = 0; i < rounds; i++) {
589 x |= (((uint64_t)1) << r);
592 CHECK(((~x) << (64 - subrange)) == 0);
598 for (b = 1; b <= 32; b++) {
604 static const uint32_t ms[] = {1, 3, 17, 1000, 13771, 999999, 33554432};
605 static const uint32_t ss[] = {1, 3, 6, 9, 13, 31, 64};
607 for (m = 0; m <
sizeof(ms) /
sizeof(ms[0]); m++) {
608 for (s = 0; s <
sizeof(ss) /
sizeof(ss[0]); s++) {
690 for (i = 0; i < 250; ++i) {
721 for (i = 0; i < 8; ++i) {
735 const int jacobi5[10] = { 0, 1, -1, -1, 1, 0, 1, -1, -1, 1 };
740 for (i = 0; i < 10; ++i) {
791 for (i = 0; i < 100*
count; i++) {
837 for (i = 0; i < 256; i += 4) {
841 for (j = 0; j < 4; j++) {
862 for (j = 0; j < now; j++) {
933 unsigned char cone[1] = {0x01};
950 for (i = 0; i < 100; ++i) {
953 int expected = r.
d[0] % (1 << shift);
955 CHECK(expected == low);
1003 for (i = 0; i < bit; i++) {
1092 unsigned char b32[32];
1102 memset(b32, 0,
sizeof(b32));
1104 memset(b32, 0xFF,
sizeof(b32));
1110 for (i = 0; i < 128 *
count; i++) {
1113 for (i = 0; i <
count; i++) {
1129 #ifndef USE_NUM_NONE
1134 unsigned char bin[32];
1135 unsigned char bin_tmp[32];
1139 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000001UL,
1140 0x45512319UL, 0x50B75FC4UL, 0x402DA173UL, 0x2FC9BEBEUL
1146 CHECK(overflow == 0);
1153 CHECK(overflow == 1);
1159 CHECK(overflow == 0);
1164 memset(bin, 0xFF, 32);
1166 CHECK(overflow == 1);
1174 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
1175 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
1193 #if defined(USE_SCALAR_INV_NUM)
1197 unsigned char chal[33][2][32] = {
1198 {{0xff, 0xff, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00,
1199 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
1200 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
1201 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff},
1202 {0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
1203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
1204 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1205 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff}},
1206 {{0xef, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
1207 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
1208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1210 {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
1212 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
1213 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x80, 0xff}},
1214 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1215 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
1216 0x80, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00,
1217 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00},
1218 {0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x80,
1219 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0,
1220 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
1221 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}},
1222 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1223 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1224 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1225 0x00, 0x1e, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff},
1226 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
1227 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0xe0,
1228 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
1229 0xf3, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}},
1230 {{0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00,
1231 0x00, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
1232 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0x00,
1233 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff},
1234 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
1235 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1236 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f,
1237 0x00, 0xfe, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff}},
1238 {{0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfc, 0x9f,
1239 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
1240 0xff, 0x0f, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00,
1241 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1242 {0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1243 0x00, 0x00, 0xf8, 0xff, 0x0f, 0xc0, 0xff, 0xff,
1244 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
1245 0xff, 0xff, 0xff, 0x07, 0x80, 0xff, 0xff, 0xff}},
1246 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
1247 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1248 0xf7, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0x00,
1249 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0},
1250 {0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
1251 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1252 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
1253 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1254 {{0x00, 0xf8, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00,
1255 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1256 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1257 0xff, 0xff, 0x03, 0xc0, 0xff, 0x0f, 0xfc, 0xff},
1258 {0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff,
1259 0xff, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xc0,
1260 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1261 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1262 {{0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1263 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
1264 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1265 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1266 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1267 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1270 {{0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
1271 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1272 0xff, 0xff, 0x03, 0x00, 0x80, 0x00, 0x00, 0x80,
1273 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0x7f},
1274 {0xff, 0xcf, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1275 0x00, 0xc0, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff,
1276 0xbf, 0xff, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
1277 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}},
1278 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
1279 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
1280 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
1281 0xff, 0x01, 0xfc, 0xff, 0x01, 0x00, 0xfe, 0xff},
1282 {0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
1283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
1285 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00}},
1286 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1287 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1288 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1289 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
1290 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1291 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0xff,
1292 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
1293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1294 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1295 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1297 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00},
1298 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
1299 0xfc, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f,
1300 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xff,
1301 0xff, 0xff, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00}},
1302 {{0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1303 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1304 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1305 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0x07, 0x00},
1306 {0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
1307 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1308 0xff, 0xfb, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
1309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60}},
1310 {{0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00,
1311 0x80, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03,
1312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1313 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1314 {0xff, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0xff, 0xff,
1315 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1316 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1317 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00}},
1318 {{0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
1319 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1320 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1321 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1322 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1323 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
1324 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
1325 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff}},
1326 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1327 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1328 0xc0, 0xff, 0xff, 0xcf, 0xff, 0x1f, 0x00, 0x00,
1329 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80},
1330 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1331 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1332 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x7e,
1333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1334 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1335 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
1336 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
1337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00},
1338 {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1339 0xff, 0xff, 0x7f, 0x00, 0x80, 0x00, 0x00, 0x00,
1340 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1341 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff}},
1342 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1343 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1344 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1345 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1346 {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1347 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80,
1348 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
1349 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0xfe}},
1350 {{0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff,
1351 0xff, 0x03, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00,
1352 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1353 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07},
1354 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1355 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1356 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff,
1357 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}},
1358 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1362 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1363 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1364 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1365 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}},
1366 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
1370 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1374 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1375 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1376 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1377 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1378 {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1379 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1380 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1381 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1382 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0,
1383 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1384 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
1385 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f},
1386 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
1387 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
1388 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
1389 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff}},
1390 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1391 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1392 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1393 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1394 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1395 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1396 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1397 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}},
1398 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1399 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1400 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1401 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1402 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1403 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1405 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1406 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1407 0x7e, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
1408 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
1409 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1410 {0xff, 0x01, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1411 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1412 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
1413 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1414 {{0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00,
1415 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1416 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1417 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff},
1418 {0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1419 0xff, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff,
1420 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1421 0xff, 0x3f, 0x00, 0x00, 0xc0, 0xf1, 0x7f, 0x00}},
1422 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1423 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
1424 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1425 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00},
1426 {0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1428 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f,
1429 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0xff, 0xff}},
1430 {{0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1431 0x80, 0x00, 0x00, 0x80, 0xff, 0x03, 0xe0, 0x01,
1432 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff,
1433 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1434 {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
1435 0xfe, 0xff, 0xff, 0xf0, 0x07, 0x00, 0x3c, 0x80,
1436 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
1437 0xff, 0xff, 0x07, 0xe0, 0xff, 0x00, 0x00, 0x00}},
1438 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1439 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1440 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf8,
1441 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
1442 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1443 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x80, 0x00,
1444 0x00, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0xff, 0x1f,
1445 0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0xfe, 0xff}},
1446 {{0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00,
1447 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83,
1448 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1449 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf0},
1450 {0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1451 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
1452 0xf8, 0x07, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1453 0xff, 0xc7, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff}},
1454 {{0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1455 0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1456 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x03, 0xfb,
1457 0xfa, 0x8a, 0x7d, 0xdf, 0x13, 0x86, 0xe2, 0x03},
1458 {0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1459 0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1460 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x03, 0xfb,
1461 0xfa, 0x8a, 0x7d, 0xdf, 0x13, 0x86, 0xe2, 0x03}}
1463 unsigned char res[33][2][32] = {
1464 {{0x0c, 0x3b, 0x0a, 0xca, 0x8d, 0x1a, 0x2f, 0xb9,
1465 0x8a, 0x7b, 0x53, 0x5a, 0x1f, 0xc5, 0x22, 0xa1,
1466 0x07, 0x2a, 0x48, 0xea, 0x02, 0xeb, 0xb3, 0xd6,
1467 0x20, 0x1e, 0x86, 0xd0, 0x95, 0xf6, 0x92, 0x35},
1468 {0xdc, 0x90, 0x7a, 0x07, 0x2e, 0x1e, 0x44, 0x6d,
1469 0xf8, 0x15, 0x24, 0x5b, 0x5a, 0x96, 0x37, 0x9c,
1470 0x37, 0x7b, 0x0d, 0xac, 0x1b, 0x65, 0x58, 0x49,
1471 0x43, 0xb7, 0x31, 0xbb, 0xa7, 0xf4, 0x97, 0x15}},
1472 {{0xf1, 0xf7, 0x3a, 0x50, 0xe6, 0x10, 0xba, 0x22,
1473 0x43, 0x4d, 0x1f, 0x1f, 0x7c, 0x27, 0xca, 0x9c,
1474 0xb8, 0xb6, 0xa0, 0xfc, 0xd8, 0xc0, 0x05, 0x2f,
1475 0xf7, 0x08, 0xe1, 0x76, 0xdd, 0xd0, 0x80, 0xc8},
1476 {0xe3, 0x80, 0x80, 0xb8, 0xdb, 0xe3, 0xa9, 0x77,
1477 0x00, 0xb0, 0xf5, 0x2e, 0x27, 0xe2, 0x68, 0xc4,
1478 0x88, 0xe8, 0x04, 0xc1, 0x12, 0xbf, 0x78, 0x59,
1479 0xe6, 0xa9, 0x7c, 0xe1, 0x81, 0xdd, 0xb9, 0xd5}},
1480 {{0x96, 0xe2, 0xee, 0x01, 0xa6, 0x80, 0x31, 0xef,
1481 0x5c, 0xd0, 0x19, 0xb4, 0x7d, 0x5f, 0x79, 0xab,
1482 0xa1, 0x97, 0xd3, 0x7e, 0x33, 0xbb, 0x86, 0x55,
1483 0x60, 0x20, 0x10, 0x0d, 0x94, 0x2d, 0x11, 0x7c},
1484 {0xcc, 0xab, 0xe0, 0xe8, 0x98, 0x65, 0x12, 0x96,
1485 0x38, 0x5a, 0x1a, 0xf2, 0x85, 0x23, 0x59, 0x5f,
1486 0xf9, 0xf3, 0xc2, 0x81, 0x70, 0x92, 0x65, 0x12,
1487 0x9c, 0x65, 0x1e, 0x96, 0x00, 0xef, 0xe7, 0x63}},
1488 {{0xac, 0x1e, 0x62, 0xc2, 0x59, 0xfc, 0x4e, 0x5c,
1489 0x83, 0xb0, 0xd0, 0x6f, 0xce, 0x19, 0xf6, 0xbf,
1490 0xa4, 0xb0, 0xe0, 0x53, 0x66, 0x1f, 0xbf, 0xc9,
1491 0x33, 0x47, 0x37, 0xa9, 0x3d, 0x5d, 0xb0, 0x48},
1492 {0x86, 0xb9, 0x2a, 0x7f, 0x8e, 0xa8, 0x60, 0x42,
1493 0x26, 0x6d, 0x6e, 0x1c, 0xa2, 0xec, 0xe0, 0xe5,
1494 0x3e, 0x0a, 0x33, 0xbb, 0x61, 0x4c, 0x9f, 0x3c,
1495 0xd1, 0xdf, 0x49, 0x33, 0xcd, 0x72, 0x78, 0x18}},
1496 {{0xf7, 0xd3, 0xcd, 0x49, 0x5c, 0x13, 0x22, 0xfb,
1497 0x2e, 0xb2, 0x2f, 0x27, 0xf5, 0x8a, 0x5d, 0x74,
1498 0xc1, 0x58, 0xc5, 0xc2, 0x2d, 0x9f, 0x52, 0xc6,
1499 0x63, 0x9f, 0xba, 0x05, 0x76, 0x45, 0x7a, 0x63},
1500 {0x8a, 0xfa, 0x55, 0x4d, 0xdd, 0xa3, 0xb2, 0xc3,
1501 0x44, 0xfd, 0xec, 0x72, 0xde, 0xef, 0xc0, 0x99,
1502 0xf5, 0x9f, 0xe2, 0x52, 0xb4, 0x05, 0x32, 0x58,
1503 0x57, 0xc1, 0x8f, 0xea, 0xc3, 0x24, 0x5b, 0x94}},
1504 {{0x05, 0x83, 0xee, 0xdd, 0x64, 0xf0, 0x14, 0x3b,
1505 0xa0, 0x14, 0x4a, 0x3a, 0x41, 0x82, 0x7c, 0xa7,
1506 0x2c, 0xaa, 0xb1, 0x76, 0xbb, 0x59, 0x64, 0x5f,
1507 0x52, 0xad, 0x25, 0x29, 0x9d, 0x8f, 0x0b, 0xb0},
1508 {0x7e, 0xe3, 0x7c, 0xca, 0xcd, 0x4f, 0xb0, 0x6d,
1509 0x7a, 0xb2, 0x3e, 0xa0, 0x08, 0xb9, 0xa8, 0x2d,
1510 0xc2, 0xf4, 0x99, 0x66, 0xcc, 0xac, 0xd8, 0xb9,
1511 0x72, 0x2a, 0x4a, 0x3e, 0x0f, 0x7b, 0xbf, 0xf4}},
1512 {{0x8c, 0x9c, 0x78, 0x2b, 0x39, 0x61, 0x7e, 0xf7,
1513 0x65, 0x37, 0x66, 0x09, 0x38, 0xb9, 0x6f, 0x70,
1514 0x78, 0x87, 0xff, 0xcf, 0x93, 0xca, 0x85, 0x06,
1515 0x44, 0x84, 0xa7, 0xfe, 0xd3, 0xa4, 0xe3, 0x7e},
1516 {0xa2, 0x56, 0x49, 0x23, 0x54, 0xa5, 0x50, 0xe9,
1517 0x5f, 0xf0, 0x4d, 0xe7, 0xdc, 0x38, 0x32, 0x79,
1518 0x4f, 0x1c, 0xb7, 0xe4, 0xbb, 0xf8, 0xbb, 0x2e,
1519 0x40, 0x41, 0x4b, 0xcc, 0xe3, 0x1e, 0x16, 0x36}},
1520 {{0x0c, 0x1e, 0xd7, 0x09, 0x25, 0x40, 0x97, 0xcb,
1521 0x5c, 0x46, 0xa8, 0xda, 0xef, 0x25, 0xd5, 0xe5,
1522 0x92, 0x4d, 0xcf, 0xa3, 0xc4, 0x5d, 0x35, 0x4a,
1523 0xe4, 0x61, 0x92, 0xf3, 0xbf, 0x0e, 0xcd, 0xbe},
1524 {0xe4, 0xaf, 0x0a, 0xb3, 0x30, 0x8b, 0x9b, 0x48,
1525 0x49, 0x43, 0xc7, 0x64, 0x60, 0x4a, 0x2b, 0x9e,
1526 0x95, 0x5f, 0x56, 0xe8, 0x35, 0xdc, 0xeb, 0xdc,
1527 0xc7, 0xc4, 0xfe, 0x30, 0x40, 0xc7, 0xbf, 0xa4}},
1528 {{0xd4, 0xa0, 0xf5, 0x81, 0x49, 0x6b, 0xb6, 0x8b,
1529 0x0a, 0x69, 0xf9, 0xfe, 0xa8, 0x32, 0xe5, 0xe0,
1530 0xa5, 0xcd, 0x02, 0x53, 0xf9, 0x2c, 0xe3, 0x53,
1531 0x83, 0x36, 0xc6, 0x02, 0xb5, 0xeb, 0x64, 0xb8},
1532 {0x1d, 0x42, 0xb9, 0xf9, 0xe9, 0xe3, 0x93, 0x2c,
1533 0x4c, 0xee, 0x6c, 0x5a, 0x47, 0x9e, 0x62, 0x01,
1534 0x6b, 0x04, 0xfe, 0xa4, 0x30, 0x2b, 0x0d, 0x4f,
1535 0x71, 0x10, 0xd3, 0x55, 0xca, 0xf3, 0x5e, 0x80}},
1536 {{0x77, 0x05, 0xf6, 0x0c, 0x15, 0x9b, 0x45, 0xe7,
1537 0xb9, 0x11, 0xb8, 0xf5, 0xd6, 0xda, 0x73, 0x0c,
1538 0xda, 0x92, 0xea, 0xd0, 0x9d, 0xd0, 0x18, 0x92,
1539 0xce, 0x9a, 0xaa, 0xee, 0x0f, 0xef, 0xde, 0x30},
1540 {0xf1, 0xf1, 0xd6, 0x9b, 0x51, 0xd7, 0x77, 0x62,
1541 0x52, 0x10, 0xb8, 0x7a, 0x84, 0x9d, 0x15, 0x4e,
1542 0x07, 0xdc, 0x1e, 0x75, 0x0d, 0x0c, 0x3b, 0xdb,
1543 0x74, 0x58, 0x62, 0x02, 0x90, 0x54, 0x8b, 0x43}},
1544 {{0xa6, 0xfe, 0x0b, 0x87, 0x80, 0x43, 0x67, 0x25,
1545 0x57, 0x5d, 0xec, 0x40, 0x50, 0x08, 0xd5, 0x5d,
1546 0x43, 0xd7, 0xe0, 0xaa, 0xe0, 0x13, 0xb6, 0xb0,
1547 0xc0, 0xd4, 0xe5, 0x0d, 0x45, 0x83, 0xd6, 0x13},
1548 {0x40, 0x45, 0x0a, 0x92, 0x31, 0xea, 0x8c, 0x60,
1549 0x8c, 0x1f, 0xd8, 0x76, 0x45, 0xb9, 0x29, 0x00,
1550 0x26, 0x32, 0xd8, 0xa6, 0x96, 0x88, 0xe2, 0xc4,
1551 0x8b, 0xdb, 0x7f, 0x17, 0x87, 0xcc, 0xc8, 0xf2}},
1552 {{0xc2, 0x56, 0xe2, 0xb6, 0x1a, 0x81, 0xe7, 0x31,
1553 0x63, 0x2e, 0xbb, 0x0d, 0x2f, 0x81, 0x67, 0xd4,
1554 0x22, 0xe2, 0x38, 0x02, 0x25, 0x97, 0xc7, 0x88,
1555 0x6e, 0xdf, 0xbe, 0x2a, 0xa5, 0x73, 0x63, 0xaa},
1556 {0x50, 0x45, 0xe2, 0xc3, 0xbd, 0x89, 0xfc, 0x57,
1557 0xbd, 0x3c, 0xa3, 0x98, 0x7e, 0x7f, 0x36, 0x38,
1558 0x92, 0x39, 0x1f, 0x0f, 0x81, 0x1a, 0x06, 0x51,
1559 0x1f, 0x8d, 0x6a, 0xff, 0x47, 0x16, 0x06, 0x9c}},
1560 {{0x33, 0x95, 0xa2, 0x6f, 0x27, 0x5f, 0x9c, 0x9c,
1561 0x64, 0x45, 0xcb, 0xd1, 0x3c, 0xee, 0x5e, 0x5f,
1562 0x48, 0xa6, 0xaf, 0xe3, 0x79, 0xcf, 0xb1, 0xe2,
1563 0xbf, 0x55, 0x0e, 0xa2, 0x3b, 0x62, 0xf0, 0xe4},
1564 {0x14, 0xe8, 0x06, 0xe3, 0xbe, 0x7e, 0x67, 0x01,
1565 0xc5, 0x21, 0x67, 0xd8, 0x54, 0xb5, 0x7f, 0xa4,
1566 0xf9, 0x75, 0x70, 0x1c, 0xfd, 0x79, 0xdb, 0x86,
1567 0xad, 0x37, 0x85, 0x83, 0x56, 0x4e, 0xf0, 0xbf}},
1568 {{0xbc, 0xa6, 0xe0, 0x56, 0x4e, 0xef, 0xfa, 0xf5,
1569 0x1d, 0x5d, 0x3f, 0x2a, 0x5b, 0x19, 0xab, 0x51,
1570 0xc5, 0x8b, 0xdd, 0x98, 0x28, 0x35, 0x2f, 0xc3,
1571 0x81, 0x4f, 0x5c, 0xe5, 0x70, 0xb9, 0xeb, 0x62},
1572 {0xc4, 0x6d, 0x26, 0xb0, 0x17, 0x6b, 0xfe, 0x6c,
1573 0x12, 0xf8, 0xe7, 0xc1, 0xf5, 0x2f, 0xfa, 0x91,
1574 0x13, 0x27, 0xbd, 0x73, 0xcc, 0x33, 0x31, 0x1c,
1575 0x39, 0xe3, 0x27, 0x6a, 0x95, 0xcf, 0xc5, 0xfb}},
1576 {{0x30, 0xb2, 0x99, 0x84, 0xf0, 0x18, 0x2a, 0x6e,
1577 0x1e, 0x27, 0xed, 0xa2, 0x29, 0x99, 0x41, 0x56,
1578 0xe8, 0xd4, 0x0d, 0xef, 0x99, 0x9c, 0xf3, 0x58,
1579 0x29, 0x55, 0x1a, 0xc0, 0x68, 0xd6, 0x74, 0xa4},
1580 {0x07, 0x9c, 0xe7, 0xec, 0xf5, 0x36, 0x73, 0x41,
1581 0xa3, 0x1c, 0xe5, 0x93, 0x97, 0x6a, 0xfd, 0xf7,
1582 0x53, 0x18, 0xab, 0xaf, 0xeb, 0x85, 0xbd, 0x92,
1583 0x90, 0xab, 0x3c, 0xbf, 0x30, 0x82, 0xad, 0xf6}},
1584 {{0xc6, 0x87, 0x8a, 0x2a, 0xea, 0xc0, 0xa9, 0xec,
1585 0x6d, 0xd3, 0xdc, 0x32, 0x23, 0xce, 0x62, 0x19,
1586 0xa4, 0x7e, 0xa8, 0xdd, 0x1c, 0x33, 0xae, 0xd3,
1587 0x4f, 0x62, 0x9f, 0x52, 0xe7, 0x65, 0x46, 0xf4},
1588 {0x97, 0x51, 0x27, 0x67, 0x2d, 0xa2, 0x82, 0x87,
1589 0x98, 0xd3, 0xb6, 0x14, 0x7f, 0x51, 0xd3, 0x9a,
1590 0x0b, 0xd0, 0x76, 0x81, 0xb2, 0x4f, 0x58, 0x92,
1591 0xa4, 0x86, 0xa1, 0xa7, 0x09, 0x1d, 0xef, 0x9b}},
1592 {{0xb3, 0x0f, 0x2b, 0x69, 0x0d, 0x06, 0x90, 0x64,
1593 0xbd, 0x43, 0x4c, 0x10, 0xe8, 0x98, 0x1c, 0xa3,
1594 0xe1, 0x68, 0xe9, 0x79, 0x6c, 0x29, 0x51, 0x3f,
1595 0x41, 0xdc, 0xdf, 0x1f, 0xf3, 0x60, 0xbe, 0x33},
1596 {0xa1, 0x5f, 0xf7, 0x1d, 0xb4, 0x3e, 0x9b, 0x3c,
1597 0xe7, 0xbd, 0xb6, 0x06, 0xd5, 0x60, 0x06, 0x6d,
1598 0x50, 0xd2, 0xf4, 0x1a, 0x31, 0x08, 0xf2, 0xea,
1599 0x8e, 0xef, 0x5f, 0x7d, 0xb6, 0xd0, 0xc0, 0x27}},
1600 {{0x62, 0x9a, 0xd9, 0xbb, 0x38, 0x36, 0xce, 0xf7,
1601 0x5d, 0x2f, 0x13, 0xec, 0xc8, 0x2d, 0x02, 0x8a,
1602 0x2e, 0x72, 0xf0, 0xe5, 0x15, 0x9d, 0x72, 0xae,
1603 0xfc, 0xb3, 0x4f, 0x02, 0xea, 0xe1, 0x09, 0xfe},
1604 {0x00, 0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3d, 0xbc,
1605 0xad, 0x16, 0x0c, 0xb6, 0xe7, 0x7c, 0x8b, 0x39,
1606 0x9a, 0x43, 0xbb, 0xe3, 0xc2, 0x55, 0x15, 0x14,
1607 0x75, 0xac, 0x90, 0x9b, 0x7f, 0x9a, 0x92, 0x00}},
1608 {{0x8b, 0xac, 0x70, 0x86, 0x29, 0x8f, 0x00, 0x23,
1609 0x7b, 0x45, 0x30, 0xaa, 0xb8, 0x4c, 0xc7, 0x8d,
1610 0x4e, 0x47, 0x85, 0xc6, 0x19, 0xe3, 0x96, 0xc2,
1611 0x9a, 0xa0, 0x12, 0xed, 0x6f, 0xd7, 0x76, 0x16},
1612 {0x45, 0xaf, 0x7e, 0x33, 0xc7, 0x7f, 0x10, 0x6c,
1613 0x7c, 0x9f, 0x29, 0xc1, 0xa8, 0x7e, 0x15, 0x84,
1614 0xe7, 0x7d, 0xc0, 0x6d, 0xab, 0x71, 0x5d, 0xd0,
1615 0x6b, 0x9f, 0x97, 0xab, 0xcb, 0x51, 0x0c, 0x9f}},
1616 {{0x9e, 0xc3, 0x92, 0xb4, 0x04, 0x9f, 0xc8, 0xbb,
1617 0xdd, 0x9e, 0xc6, 0x05, 0xfd, 0x65, 0xec, 0x94,
1618 0x7f, 0x2c, 0x16, 0xc4, 0x40, 0xac, 0x63, 0x7b,
1619 0x7d, 0xb8, 0x0c, 0xe4, 0x5b, 0xe3, 0xa7, 0x0e},
1620 {0x43, 0xf4, 0x44, 0xe8, 0xcc, 0xc8, 0xd4, 0x54,
1621 0x33, 0x37, 0x50, 0xf2, 0x87, 0x42, 0x2e, 0x00,
1622 0x49, 0x60, 0x62, 0x02, 0xfd, 0x1a, 0x7c, 0xdb,
1623 0x29, 0x6c, 0x6d, 0x54, 0x53, 0x08, 0xd1, 0xc8}},
1624 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1625 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1626 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1627 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1628 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1629 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1630 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1631 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1632 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1633 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1634 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1635 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1636 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1637 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1638 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1639 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1640 {{0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1641 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1642 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1643 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92},
1644 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1645 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1646 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1647 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1648 {{0x28, 0x56, 0xac, 0x0e, 0x4f, 0x98, 0x09, 0xf0,
1649 0x49, 0xfa, 0x7f, 0x84, 0xac, 0x7e, 0x50, 0x5b,
1650 0x17, 0x43, 0x14, 0x89, 0x9c, 0x53, 0xa8, 0x94,
1651 0x30, 0xf2, 0x11, 0x4d, 0x92, 0x14, 0x27, 0xe8},
1652 {0x39, 0x7a, 0x84, 0x56, 0x79, 0x9d, 0xec, 0x26,
1653 0x2c, 0x53, 0xc1, 0x94, 0xc9, 0x8d, 0x9e, 0x9d,
1654 0x32, 0x1f, 0xdd, 0x84, 0x04, 0xe8, 0xe2, 0x0a,
1655 0x6b, 0xbe, 0xbb, 0x42, 0x40, 0x67, 0x30, 0x6c}},
1656 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1657 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1658 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
1659 0x40, 0x2d, 0xa1, 0x73, 0x2f, 0xc9, 0xbe, 0xbd},
1660 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1661 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1662 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1663 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1664 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1665 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1666 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1667 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1668 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1669 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1670 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1671 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1672 {{0x1c, 0xc4, 0xf7, 0xda, 0x0f, 0x65, 0xca, 0x39,
1673 0x70, 0x52, 0x92, 0x8e, 0xc3, 0xc8, 0x15, 0xea,
1674 0x7f, 0x10, 0x9e, 0x77, 0x4b, 0x6e, 0x2d, 0xdf,
1675 0xe8, 0x30, 0x9d, 0xda, 0xe8, 0x9a, 0x65, 0xae},
1676 {0x02, 0xb0, 0x16, 0xb1, 0x1d, 0xc8, 0x57, 0x7b,
1677 0xa2, 0x3a, 0xa2, 0xa3, 0x38, 0x5c, 0x8f, 0xeb,
1678 0x66, 0x37, 0x91, 0xa8, 0x5f, 0xef, 0x04, 0xf6,
1679 0x59, 0x75, 0xe1, 0xee, 0x92, 0xf6, 0x0e, 0x30}},
1680 {{0x8d, 0x76, 0x14, 0xa4, 0x14, 0x06, 0x9f, 0x9a,
1681 0xdf, 0x4a, 0x85, 0xa7, 0x6b, 0xbf, 0x29, 0x6f,
1682 0xbc, 0x34, 0x87, 0x5d, 0xeb, 0xbb, 0x2e, 0xa9,
1683 0xc9, 0x1f, 0x58, 0xd6, 0x9a, 0x82, 0xa0, 0x56},
1684 {0xd4, 0xb9, 0xdb, 0x88, 0x1d, 0x04, 0xe9, 0x93,
1685 0x8d, 0x3f, 0x20, 0xd5, 0x86, 0xa8, 0x83, 0x07,
1686 0xdb, 0x09, 0xd8, 0x22, 0x1f, 0x7f, 0xf1, 0x71,
1687 0xc8, 0xe7, 0x5d, 0x47, 0xaf, 0x8b, 0x72, 0xe9}},
1688 {{0x83, 0xb9, 0x39, 0xb2, 0xa4, 0xdf, 0x46, 0x87,
1689 0xc2, 0xb8, 0xf1, 0xe6, 0x4c, 0xd1, 0xe2, 0xa9,
1690 0xe4, 0x70, 0x30, 0x34, 0xbc, 0x52, 0x7c, 0x55,
1691 0xa6, 0xec, 0x80, 0xa4, 0xe5, 0xd2, 0xdc, 0x73},
1692 {0x08, 0xf1, 0x03, 0xcf, 0x16, 0x73, 0xe8, 0x7d,
1693 0xb6, 0x7e, 0x9b, 0xc0, 0xb4, 0xc2, 0xa5, 0x86,
1694 0x02, 0x77, 0xd5, 0x27, 0x86, 0xa5, 0x15, 0xfb,
1695 0xae, 0x9b, 0x8c, 0xa9, 0xf9, 0xf8, 0xa8, 0x4a}},
1696 {{0x8b, 0x00, 0x49, 0xdb, 0xfa, 0xf0, 0x1b, 0xa2,
1697 0xed, 0x8a, 0x9a, 0x7a, 0x36, 0x78, 0x4a, 0xc7,
1698 0xf7, 0xad, 0x39, 0xd0, 0x6c, 0x65, 0x7a, 0x41,
1699 0xce, 0xd6, 0xd6, 0x4c, 0x20, 0x21, 0x6b, 0xc7},
1700 {0xc6, 0xca, 0x78, 0x1d, 0x32, 0x6c, 0x6c, 0x06,
1701 0x91, 0xf2, 0x1a, 0xe8, 0x43, 0x16, 0xea, 0x04,
1702 0x3c, 0x1f, 0x07, 0x85, 0xf7, 0x09, 0x22, 0x08,
1703 0xba, 0x13, 0xfd, 0x78, 0x1e, 0x3f, 0x6f, 0x62}},
1704 {{0x25, 0x9b, 0x7c, 0xb0, 0xac, 0x72, 0x6f, 0xb2,
1705 0xe3, 0x53, 0x84, 0x7a, 0x1a, 0x9a, 0x98, 0x9b,
1706 0x44, 0xd3, 0x59, 0xd0, 0x8e, 0x57, 0x41, 0x40,
1707 0x78, 0xa7, 0x30, 0x2f, 0x4c, 0x9c, 0xb9, 0x68},
1708 {0xb7, 0x75, 0x03, 0x63, 0x61, 0xc2, 0x48, 0x6e,
1709 0x12, 0x3d, 0xbf, 0x4b, 0x27, 0xdf, 0xb1, 0x7a,
1710 0xff, 0x4e, 0x31, 0x07, 0x83, 0xf4, 0x62, 0x5b,
1711 0x19, 0xa5, 0xac, 0xa0, 0x32, 0x58, 0x0d, 0xa7}},
1712 {{0x43, 0x4f, 0x10, 0xa4, 0xca, 0xdb, 0x38, 0x67,
1713 0xfa, 0xae, 0x96, 0xb5, 0x6d, 0x97, 0xff, 0x1f,
1714 0xb6, 0x83, 0x43, 0xd3, 0xa0, 0x2d, 0x70, 0x7a,
1715 0x64, 0x05, 0x4c, 0xa7, 0xc1, 0xa5, 0x21, 0x51},
1716 {0xe4, 0xf1, 0x23, 0x84, 0xe1, 0xb5, 0x9d, 0xf2,
1717 0xb8, 0x73, 0x8b, 0x45, 0x2b, 0x35, 0x46, 0x38,
1718 0x10, 0x2b, 0x50, 0xf8, 0x8b, 0x35, 0xcd, 0x34,
1719 0xc8, 0x0e, 0xf6, 0xdb, 0x09, 0x35, 0xf0, 0xda}},
1720 {{0xdb, 0x21, 0x5c, 0x8d, 0x83, 0x1d, 0xb3, 0x34,
1721 0xc7, 0x0e, 0x43, 0xa1, 0x58, 0x79, 0x67, 0x13,
1722 0x1e, 0x86, 0x5d, 0x89, 0x63, 0xe6, 0x0a, 0x46,
1723 0x5c, 0x02, 0x97, 0x1b, 0x62, 0x43, 0x86, 0xf5},
1724 {0xdb, 0x21, 0x5c, 0x8d, 0x83, 0x1d, 0xb3, 0x34,
1725 0xc7, 0x0e, 0x43, 0xa1, 0x58, 0x79, 0x67, 0x13,
1726 0x1e, 0x86, 0x5d, 0x89, 0x63, 0xe6, 0x0a, 0x46,
1727 0x5c, 0x02, 0x97, 0x1b, 0x62, 0x43, 0x86, 0xf5}}
1730 for (i = 0; i < 33; i++) {
1745 #if defined(USE_SCALAR_INV_NUM)
1769 unsigned char bin[32];
1779 unsigned char bin[32];
1790 while (--tries >= 0) {
1825 static const unsigned char b32[32] = {
1826 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1827 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1828 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
1829 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40
1832 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1833 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1836 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1837 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1840 unsigned char b322[32];
1857 t.magnitude = a->magnitude;
1858 t.normalized = a->normalized;
1870 for (i = 0; i < 5*
count; i++) {
1883 CHECK(x.normalized && x.magnitude == 1);
1890 CHECK(!q.normalized && q.magnitude == z.magnitude);
1899 CHECK(q.normalized && q.magnitude == 1);
1901 for (j = 0; j < 6; j++) {
1906 CHECK((q.normalized != (j&1)) && q.magnitude == ((j&1) ? z.magnitude : 1));
1946 for (i = 0; i < 10*
count; i++) {
1958 for (i = 0; i < 10*
count; i++) {
1972 for (i = 0; i <
count; i++) {
1975 for (j = 0; j < len; j++) {
1979 for (j = 0; j < len; j++) {
1983 for (j = 0; j < len; j++) {
1997 for (i = 1; i <= 512; ++i) {
2008 CHECK((v == 0) == (k == NULL));
2029 for (i = 1; i <= 100; i++) {
2038 for (i = 0; i < 10; i++) {
2041 for (j = 0; j <
count; j++) {
2121 for (i = 0; i < runs; i++) {
2125 if (i >= runs - 2) {
2128 if (i >= runs - 1) {
2139 for (j = 0; j < 4; j++) {
2151 for (i = 0; i < 4 * runs + 1; i++) {
2174 for (i1 = 0; i1 < 1 + 4 * runs; i1++) {
2176 for (i2 = 0; i2 < 1 + 4 * runs; i2++) {
2216 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 == ((i2 + 3)%4)/2)) {
2233 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 != ((i2 + 3)%4)/2)) {
2255 for (i = 0; i < 4 * runs + 1; i++) {
2256 gej_shuffled[i] = gej[i];
2258 for (i = 0; i < 4 * runs + 1; i++) {
2262 gej_shuffled[i] = gej_shuffled[swap];
2263 gej_shuffled[swap] = t;
2266 for (i = 0; i < 4 * runs + 1; i++) {
2277 for (i = 0; i < 4 * runs + 1; i++) {
2284 for (i = 0; i < 4 * runs + 1; i++) {
2295 for (i = 0; i < 4 * runs + 1; i++) {
2306 for (i = 0; i < 4 * runs + 1; i++) {
2380 0x8d24cd95, 0x0a355af1, 0x3c543505, 0x44238d30,
2381 0x0643d79f, 0x05a59614, 0x2f8ec030, 0xd58977cb,
2382 0x001e337a, 0x38093dcd, 0x6c0f386d, 0x0b1293a8,
2383 0x4d72c879, 0xd7681924, 0x44e6d2f3, 0x9190117d
2386 0xc7b74206, 0x1f788cd9, 0xabd0937d, 0x164a0d86,
2387 0x95f6ff75, 0xf19a4ce9, 0xd013bd7b, 0xbf92d2a7,
2388 0xffe1cc85, 0xc7f6c232, 0x93f0c792, 0xf4ed6c57,
2389 0xb28d3786, 0x2897e6db, 0xbb192d0b, 0x6e6feab2
2392 0x671a63c0, 0x3efdad4c, 0x389a7798, 0x24356027,
2393 0xb3d69010, 0x278625c3, 0x5c86d390, 0x184a8f7a,
2394 0x5f6409c2, 0x2ce01f2b, 0x511fd375, 0x25071d08,
2395 0xda651801, 0x70e95caf, 0x8f0d893c, 0xbed8fbbe
2417 for (i = 0; i <
count * 32; i++) {
2433 for (i = 1; i <= 6; i++) {
2440 d[i - 1] = &data[i - 1];
2451 for (i = 0; i <
count * 8; i++) {
2464 int res_quad, res_even, res_odd;
2472 CHECK(res_quad == res_even);
2473 CHECK(res_quad == res_odd);
2522 for (i = 0; i <
count * 4; i++) {
2534 0x8b30bbe9, 0xae2a9906, 0x96b22f67, 0x0709dff3,
2535 0x727fd8bc, 0x04d3362c, 0x6c7bf458, 0xe2846004,
2536 0xa357ae91, 0x5c4a6528, 0x1309edf2, 0x0504740f,
2537 0x0eb33439, 0x90216b4f, 0x81063cb6, 0x5f2f7e0f
2541 0x84cc5452, 0xf7fde1ed, 0xb4d38a8c, 0xe9b1b84c,
2542 0xcef31f14, 0x6e569be9, 0x705d357a, 0x42985407
2545 0xa1e58d22, 0x553dcd42, 0xb2398062, 0x5d4c57a9,
2546 0x6e9323d4, 0x2b3152e5, 0xca2c3990, 0xedc7c9de
2561 for (i = 0; i < 200*
count; i++) {
2577 0xD6E96687, 0xF9B10D09, 0x2A6F3543, 0x9D86CEBE,
2578 0xA4535D0D, 0x409F5358, 0x6440BD74, 0xB933E830,
2579 0xB95CBCA2, 0xC77DA786, 0x539BE8FD, 0x53354D2D,
2580 0x3B4F566A, 0xE6580454, 0x07ED6015, 0xEE1B2A88
2603 unsigned char pub[65];
2637 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fc),
2638 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fd),
2639 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fe),
2640 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6ff),
2641 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632d),
2642 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632e),
2643 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632f),
2644 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf76330),
2645 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b209f),
2646 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a0),
2647 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a1),
2648 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a2),
2649 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede11),
2650 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede12),
2651 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede13),
2652 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede14),
2653 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a42),
2654 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a43),
2655 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a44),
2656 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a45)
2682 }
else if (mode == 1) {
2701 for (i = 0; i < 4*
count; ++i) {
2714 0x7603CB59, 0xB0EF6C63, 0xFE608479, 0x2A0C378C,
2715 0xDB3233A8, 0x0F8A9A09, 0xA877DEAD, 0x31B38C45
2717 for (i = 0; i < 500; i++) {
2734 0x6d986544, 0x57ff52b8, 0xcf1b8126, 0x5b802a5b,
2735 0xa97f9263, 0xb1e88044, 0x93351325, 0x91bc450a,
2736 0x535c59f7, 0x325e5d2b, 0xc391fbe8, 0x3c12787c,
2737 0x337e4a98, 0xe82a9011, 0x0123ba37, 0xdd769c7d
2741 0x649d4f77, 0xc4242df7, 0x7f2079c9, 0x14530327,
2742 0xa31b876a, 0xd2d8ce2a, 0x2236d5c6, 0xd7b2029b
2746 0x23773684, 0x4d209dc7, 0x098a786f, 0x20d06fcd,
2747 0x070a38bf, 0xc11ac651, 0x03004319, 0x1e2a8786,
2748 0xed8c3b8e, 0xc06dd57b, 0xd06ea66e, 0x45492b0f,
2749 0xb84e4e1b, 0xfb77e21f, 0x96baae2a, 0x63dec956
2804 0x4968d524, 0x2abf9b7a, 0x466abbcf, 0x34b11b6d,
2805 0xcd83d307, 0x827bed62, 0x05fad0ce, 0x18fae63b
2808 0x5494c15d, 0x32099706, 0xc2395f94, 0x348745fd,
2809 0x757ce30e, 0x4e8c90fb, 0xa2bad184, 0xf883c69f,
2810 0x5d195d20, 0xe191bf7f, 0x1be3e55f, 0x56a80196,
2811 0x6071ad01, 0xf1462f66, 0xc997fa94, 0xdb858435
2818 for (i = 0; i < 100; ++i) {
2841 *sc = data->
sc[idx];
2842 *pt = data->
pt[idx];
2871 for (ncount = 0; ncount <
count; ncount++) {
2915 for (ncount = 0; ncount <
count; ncount++) {
2918 size_t sizes[] = { 2, 10, 32 };
2920 for (j = 0; j < 3; j++) {
2921 for (i = 0; i < 32; i++) {
2929 for (j = 0; j < 3; j++) {
2930 for (i = 0; i < 32; i++) {
2939 for (j = 0; j < 3; j++) {
2941 for (i = 0; i < 16; i++) {
2945 pt[2 * i + 1] = ptg;
2952 for (i = 0; i < 16; i++) {
2968 for (i = 1; i < 32; i++) {
2981 for (ncount = 0; ncount <
count; ncount++) {
2986 for (i = 0; i < 20; i++) {
3002 for (ncount = 0; ncount <
count; ncount++) {
3010 for (i = 0; i < 20; i++) {
3025 for (ncount = 0; ncount < 20; ncount++) {
3042 const size_t TOP = 8;
3051 for(t0i = 0; t0i < TOP; t0i++) {
3052 for(t1i = 0; t1i < TOP; t1i++) {
3064 for(s0i = 0; s0i < TOP; s0i++) {
3065 for(s1i = 0; s1i < TOP; s1i++) {
3137 size_t n_points_supported;
3138 int bucket_window = 0;
3140 for(; scratch_size < max_size; scratch_size+=256) {
3145 CHECK(scratch != NULL);
3148 if (n_points_supported == 0) {
3167 size_t n_batches, n_batch_points, max_n_batch_points, n;
3169 max_n_batch_points = 0;
3173 max_n_batch_points = 1;
3176 CHECK(n_batches == 0);
3177 CHECK(n_batch_points == 0);
3179 max_n_batch_points = 2;
3182 CHECK(n_batches == 3);
3183 CHECK(n_batch_points == 2);
3188 CHECK(n_batches == 1);
3194 CHECK(n_batches == 2);
3197 max_n_batch_points = 1;
3200 CHECK(n_batches == SIZE_MAX);
3201 CHECK(n_batch_points == 1);
3203 max_n_batch_points = 2;
3206 CHECK(n_batches == SIZE_MAX/2 + 1);
3207 CHECK(n_batch_points == 2);
3232 for(i = 0; i < n_points; i++) {
3263 for(i = 1; i <= n_points; i++) {
3314 for (i = bits-1; i >= 0; i--) {
3318 CHECK(zeroes == -1 || zeroes >= w-1);
3320 CHECK((v & 1) == 1);
3321 CHECK(v <= (1 << (w-1)) - 1);
3322 CHECK(v >= -(1 << (w-1)) - 1);
3324 CHECK(zeroes != -1);
3349 CHECK(sign1 == sign2);
3355 int wnaf[256] = {0};
3364 for (i = 0; i < 16; ++i) {
3375 CHECK(v > -(1 << w));
3376 CHECK(v < (1 << w));
3395 int wnaf[256] = {0};
3402 for (i = 0; i < 16; ++i) {
3410 CHECK(v == 0 || v & 1);
3411 CHECK(v > -(1 << w));
3412 CHECK(v < (1 << w));
3433 CHECK(wnaf[i] == 0);
3435 for (i = 7; i >= 0; --i) {
3436 CHECK(wnaf[i] == wnaf_expected[i]);
3442 int wnaf[256] = {0};
3461 CHECK(wnaf[0] == 1);
3465 int wnaf_expected[8] = { 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf };
3472 int wnaf_expected[8] = { -1, -1, -1, -1, -1, -1, -1, 0xf };
3479 int wnaf_expected[8] = { 1, 0, 1, 0, 1, 0, 1, 0 };
3486 int wnaf_expected[8] = { -0xf, 0, 0xf, -0xf, 0, 0xf, 1, 0 };
3526 for (i = 0; i <
count; i++) {
3548 for (i = 0; i < 36; i++ ) {
3551 for (j = 0; j < i; j++) {
3559 for (i = 1; i <= 36; i++ ) {
3563 for (j = 0; j < i; j++) {
3581 unsigned char seed32[32];
3615 for (i = 0; i < 10; i++) {
3623 const unsigned char zero[32] = {0};
3624 unsigned char tmp[32];
3659 for (i = 0; i < 100U *
count; ++i) {
3670 unsigned char pubkeyc[65];
3677 for (pubkeyclen = 3; pubkeyclen <= 65; pubkeyclen++) {
3680 memcpy(&pubkeyc[1], input, 64);
3681 VG_UNDEF(&pubkeyc[pubkeyclen], 65 - pubkeyclen);
3682 for (i = 0; i < 256; i++) {
3689 ysign = (input[63] & 1) + 2;
3691 xpass = xvalid && (pubkeyclen == 33) && ((i & 254) == 2);
3693 ypass = xvalid && yvalid && ((i & 4) == ((pubkeyclen == 65) << 2)) &&
3694 ((i == 4) || ((i & 251) == ysign)) && ((pubkeyclen == 33) || (pubkeyclen == 65));
3695 if (xpass || ypass) {
3697 unsigned char pubkeyo[65];
3699 memset(&pubkey, 0,
sizeof(pubkey));
3710 CHECK((pubkeyclen != 33) || (pubkeyo[0] == pubkeyc[0]));
3713 CHECK(pubkeyo[0] == ysign);
3715 memset(&pubkey, 0,
sizeof(pubkey));
3724 CHECK(pubkeyo[0] == 4);
3730 memset(&pubkey, 0xfe,
sizeof(pubkey));
3745 #define SECP256K1_EC_PARSE_TEST_NVALID (12)
3749 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x52,
3750 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3751 0x00, 0x00, 0x64, 0xef, 0xa1, 0x7b, 0x77, 0x61, 0xe1, 0xe4, 0x27, 0x06, 0x98, 0x9f, 0xb4, 0x83,
3752 0xb8, 0xd2, 0xd4, 0x9b, 0xf7, 0x8f, 0xae, 0x98, 0x03, 0xf0, 0x99, 0xb8, 0x34, 0xed, 0xeb, 0x00
3756 0x7a, 0xe9, 0x6a, 0x2b, 0x65, 0x7c, 0x07, 0x10, 0x6e, 0x64, 0x47, 0x9e, 0xac, 0x34, 0x34, 0xe9,
3757 0x9c, 0xf0, 0x49, 0x75, 0x12, 0xf5, 0x89, 0x95, 0xc1, 0x39, 0x6c, 0x28, 0x71, 0x95, 0x01, 0xee,
3758 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
3759 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
3763 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3764 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
3765 0x0e, 0x99, 0x4b, 0x14, 0xea, 0x72, 0xf8, 0xc3, 0xeb, 0x95, 0xc7, 0x1e, 0xf6, 0x92, 0x57, 0x5e,
3766 0x77, 0x50, 0x58, 0x33, 0x2d, 0x7e, 0x52, 0xd0, 0x99, 0x5c, 0xf8, 0x03, 0x88, 0x71, 0xb6, 0x7d,
3770 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3771 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
3772 0xf1, 0x66, 0xb4, 0xeb, 0x15, 0x8d, 0x07, 0x3c, 0x14, 0x6a, 0x38, 0xe1, 0x09, 0x6d, 0xa8, 0xa1,
3773 0x88, 0xaf, 0xa7, 0xcc, 0xd2, 0x81, 0xad, 0x2f, 0x66, 0xa3, 0x07, 0xfb, 0x77, 0x8e, 0x45, 0xb2,
3777 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3778 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3779 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
3780 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
3784 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3785 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3786 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
3787 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
3791 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
3792 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
3793 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3794 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
3798 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
3799 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
3800 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3801 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
3805 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
3806 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
3807 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3808 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
3812 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
3813 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
3814 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3815 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3819 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
3820 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
3821 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3822 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3826 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
3827 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
3828 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3829 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
3832 #define SECP256K1_EC_PARSE_TEST_NXVALID (4)
3836 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
3837 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
3838 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3839 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
3843 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
3844 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
3845 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3846 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
3850 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
3851 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
3852 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3853 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
3857 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3858 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3859 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3860 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03
3863 #define SECP256K1_EC_PARSE_TEST_NINVALID (7)
3867 0x0a, 0x2d, 0x2b, 0xa9, 0x35, 0x07, 0xf1, 0xdf, 0x23, 0x37, 0x70, 0xc2, 0xa7, 0x97, 0x96, 0x2c,
3868 0xc6, 0x1f, 0x6d, 0x15, 0xda, 0x14, 0xec, 0xd4, 0x7d, 0x8d, 0x27, 0xae, 0x1c, 0xd5, 0xf8, 0x53,
3869 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3870 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3874 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3875 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
3876 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
3877 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
3881 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3882 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
3883 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
3884 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
3888 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3889 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
3890 0xf4, 0x84, 0x14, 0x5c, 0xb0, 0x14, 0x9b, 0x82, 0x5d, 0xff, 0x41, 0x2f, 0xa0, 0x52, 0xa8, 0x3f,
3891 0xcb, 0x72, 0xdb, 0x61, 0xd5, 0x6f, 0x37, 0x70, 0xce, 0x06, 0x6b, 0x73, 0x49, 0xa2, 0xaa, 0x28,
3895 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3896 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
3897 0x0b, 0x7b, 0xeb, 0xa3, 0x4f, 0xeb, 0x64, 0x7d, 0xa2, 0x00, 0xbe, 0xd0, 0x5f, 0xad, 0x57, 0xc0,
3898 0x34, 0x8d, 0x24, 0x9e, 0x2a, 0x90, 0xc8, 0x8f, 0x31, 0xf9, 0x94, 0x8b, 0xb6, 0x5d, 0x52, 0x07,
3902 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3903 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3904 0x8f, 0x53, 0x7e, 0xef, 0xdf, 0xc1, 0x60, 0x6a, 0x07, 0x27, 0xcd, 0x69, 0xb4, 0xa7, 0x33, 0x3d,
3905 0x38, 0xed, 0x44, 0xe3, 0x93, 0x2a, 0x71, 0x79, 0xee, 0xcb, 0x4b, 0x6f, 0xba, 0x93, 0x60, 0xdc,
3909 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3910 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3911 0x70, 0xac, 0x81, 0x10, 0x20, 0x3e, 0x9f, 0x95, 0xf8, 0xd8, 0x32, 0x96, 0x4b, 0x58, 0xcc, 0xc2,
3912 0xc7, 0x12, 0xbb, 0x1c, 0x6c, 0xd5, 0x8e, 0x86, 0x11, 0x34, 0xb4, 0x8f, 0x45, 0x6c, 0x9b, 0x53
3915 const unsigned char pubkeyc[66] = {
3917 0x04, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B,
3918 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17,
3919 0x98, 0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0x0E, 0x11, 0x08,
3920 0xA8, 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4,
3923 unsigned char sout[65];
3924 unsigned char shortkey[2];
3936 memset(&pubkey, 0xfe,
sizeof(pubkey));
3946 for (i = 0; i < 256 ; i++) {
3947 memset(&pubkey, 0xfe,
sizeof(pubkey));
3959 for (i = 0; i < 65536 ; i++) {
3960 memset(&pubkey, 0xfe,
sizeof(pubkey));
3962 shortkey[0] = i & 255;
3963 shortkey[1] = i >> 8;
3971 memset(&pubkey, 0xfe,
sizeof(pubkey));
3984 memset(&pubkey, 0xfe,
sizeof(pubkey));
3993 memset(&pubkey, 0xfe,
sizeof(pubkey));
4002 memset(&pubkey, 0xfe,
sizeof(pubkey));
4011 memset(&pubkey, 0,
sizeof(pubkey));
4058 CHECK(ecount2 == 10);
4073 const unsigned char orderc[32] = {
4074 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4075 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
4076 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
4077 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
4080 unsigned char ctmp[33];
4081 unsigned char ctmp2[33];
4096 memset(ctmp, 255, 32);
4098 memset(&pubkey, 1,
sizeof(pubkey));
4104 memset(ctmp, 0, 32);
4106 memset(&pubkey, 1,
sizeof(pubkey));
4114 memset(&pubkey, 0,
sizeof(pubkey));
4119 pubkey_one = pubkey;
4121 memcpy(ctmp, orderc, 32);
4124 memset(&pubkey, 1,
sizeof(pubkey));
4132 memset(&pubkey, 0,
sizeof(pubkey));
4137 pubkey_negone = pubkey;
4139 memset(ctmp2, 0, 32);
4142 memcpy(&pubkey2, &pubkey,
sizeof(pubkey));
4150 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4153 memcpy(ctmp, orderc, 32);
4154 memset(ctmp2, 0, 32);
4160 memcpy(ctmp, orderc, 32);
4165 memcpy(ctmp, orderc, 32);
4169 memcpy(ctmp, orderc, 32);
4173 memcpy(ctmp, orderc, 32);
4179 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4182 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4186 memcpy(ctmp, orderc, 32);
4188 memset(ctmp2, 0, 32);
4195 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4215 memset(&pubkey, 0, 32);
4219 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4220 memset(&pubkey2, 0, 32);
4231 memset(ctmp2, 0, 32);
4238 memset(ctmp2, 0, 32);
4245 memset(ctmp2, 0, 32);
4251 memset(ctmp2, 0, 32);
4260 memset(&pubkey, 1,
sizeof(pubkey));
4266 pubkeys[0] = &pubkey_one;
4285 pubkeys[0] = &pubkey_negone;
4297 pubkeys[0] = &pubkey_one;
4298 pubkeys[1] = &pubkey_negone;
4306 pubkeys[2] = &pubkey_one;
4318 pubkeys[1] = &pubkey_one;
4329 unsigned char seckey[32];
4330 unsigned char seckey_tmp[32];
4333 memcpy(seckey_tmp, seckey, 32);
4347 memset(seckey, 0, 32);
4348 memset(seckey_tmp, 0, 32);
4357 memset(seckey, 0xFF, 16);
4358 memset(seckey_tmp, 0, 32);
4383 random_sign(&sigr, &sigs, &key, &msg, getrec?&recid:NULL);
4385 CHECK(recid >= 0 && recid < 4);
4395 for (i = 0; i < 10*
count; i++) {
4401 static int precomputed_nonce_function(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *data,
unsigned int counter) {
4405 memcpy(nonce32, data, 32);
4406 return (counter == 0);
4409 static int nonce_function_test_fail(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *data,
unsigned int counter) {
4417 static int nonce_function_test_retry(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *data,
unsigned int counter) {
4420 memset(nonce32, counter==0 ? 0 : 255, 32);
4427 static const unsigned char order[] = {
4428 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
4429 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
4430 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
4431 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41
4433 memcpy(nonce32, order, 32);
4453 unsigned char extra[32] = {0x00};
4454 unsigned char privkey[32];
4455 unsigned char message[32];
4456 unsigned char privkey2[32];
4459 unsigned char sig[74];
4461 unsigned char pubkeyc[65];
4462 size_t pubkeyclen = 65;
4465 unsigned char seckey[300];
4466 size_t seckeylen = 300;
4483 memset(&pubkey, 0,
sizeof(pubkey));
4487 memcpy(&pubkey_tmp, &pubkey,
sizeof(pubkey));
4503 unsigned char rnd[32];
4504 unsigned char privkey_tmp[32];
4507 memcpy(privkey_tmp, privkey, 32);
4512 CHECK(ret1 == ret2);
4513 CHECK(ret2 == ret3);
4527 unsigned char rnd[32];
4528 unsigned char privkey_tmp[32];
4531 memcpy(privkey_tmp, privkey, 32);
4536 CHECK(ret1 == ret2);
4537 CHECK(ret2 == ret3);
4586 memset(&signature[0], 0,
sizeof(signature[0]));
4600 unsigned char in[65];
4621 unsigned char out[65];
4622 unsigned char firstb;
4631 if ((in[0] != 6) && (in[0] != 7)) {
4632 CHECK(in[0] == out[0]);
4642 if (firstb == 2 || firstb == 3) {
4643 if (in[0] == firstb + 4) {
4659 for (i = 0; i < 10*
count; i++) {
4666 for (i = 0; i < 64*
count; i++) {
4672 static const unsigned char zeroes[32] = {0};
4673 #ifdef ENABLE_OPENSSL_TESTS
4674 static const unsigned char max_scalar[32] = {
4675 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4676 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
4677 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
4678 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40
4685 unsigned char roundtrip_der[2048];
4686 unsigned char compact_der[64];
4687 size_t len_der = 2048;
4688 int parsed_der = 0, valid_der = 0, roundtrips_der = 0;
4691 unsigned char roundtrip_der_lax[2048];
4692 unsigned char compact_der_lax[64];
4693 size_t len_der_lax = 2048;
4694 int parsed_der_lax = 0, valid_der_lax = 0, roundtrips_der_lax = 0;
4696 #ifdef ENABLE_OPENSSL_TESTS
4697 ECDSA_SIG *sig_openssl;
4698 const BIGNUM *r = NULL, *s = NULL;
4699 const unsigned char *sigptr;
4700 unsigned char roundtrip_openssl[2048];
4701 int len_openssl = 2048;
4702 int parsed_openssl, valid_openssl = 0, roundtrips_openssl = 0;
4716 if (parsed_der_lax) {
4720 if (valid_der_lax) {
4722 roundtrips_der_lax = (len_der_lax == siglen) &&
secp256k1_memcmp_var(roundtrip_der_lax, sig, siglen) == 0;
4725 if (certainly_der) {
4726 ret |= (!parsed_der) << 2;
4728 if (certainly_not_der) {
4729 ret |= (parsed_der) << 17;
4732 ret |= (!roundtrips_der) << 3;
4736 ret |= (!roundtrips_der_lax) << 12;
4737 ret |= (len_der != len_der_lax) << 13;
4738 ret |= ((len_der != len_der_lax) || (
secp256k1_memcmp_var(roundtrip_der_lax, roundtrip_der, len_der) != 0)) << 14;
4740 ret |= (roundtrips_der != roundtrips_der_lax) << 15;
4742 ret |= (!parsed_der_lax) << 16;
4745 #ifdef ENABLE_OPENSSL_TESTS
4746 sig_openssl = ECDSA_SIG_new();
4748 parsed_openssl = (d2i_ECDSA_SIG(&sig_openssl, &sigptr, siglen) != NULL);
4749 if (parsed_openssl) {
4750 ECDSA_SIG_get0(sig_openssl, &r, &s);
4751 valid_openssl = !BN_is_negative(r) && !BN_is_negative(s) && BN_num_bits(r) > 0 && BN_num_bits(r) <= 256 && BN_num_bits(s) > 0 && BN_num_bits(s) <= 256;
4752 if (valid_openssl) {
4753 unsigned char tmp[32] = {0};
4754 BN_bn2bin(r, tmp + 32 - BN_num_bytes(r));
4757 if (valid_openssl) {
4758 unsigned char tmp[32] = {0};
4759 BN_bn2bin(s, tmp + 32 - BN_num_bytes(s));
4763 len_openssl = i2d_ECDSA_SIG(sig_openssl, NULL);
4764 if (len_openssl <= 2048) {
4765 unsigned char *ptr = roundtrip_openssl;
4766 CHECK(i2d_ECDSA_SIG(sig_openssl, &ptr) == len_openssl);
4767 roundtrips_openssl = valid_openssl && ((size_t)len_openssl == siglen) && (
secp256k1_memcmp_var(roundtrip_openssl, sig, siglen) == 0);
4771 ECDSA_SIG_free(sig_openssl);
4773 ret |= (parsed_der && !parsed_openssl) << 4;
4774 ret |= (valid_der && !valid_openssl) << 5;
4775 ret |= (roundtrips_openssl && !parsed_der) << 6;
4776 ret |= (roundtrips_der != roundtrips_openssl) << 7;
4777 if (roundtrips_openssl) {
4778 ret |= (len_der != (size_t)len_openssl) << 8;
4779 ret |= ((len_der != (size_t)len_openssl) || (
secp256k1_memcmp_var(roundtrip_der, roundtrip_openssl, len_der) != 0)) << 9;
4787 for (i = 0; i < ptrlen; i++) {
4788 int shift = ptrlen - 1 - i;
4792 ptr[i] = (val >> shift) & 0xFF;
4800 if (action < 1 && *len > 3) {
4803 memmove(sig + pos, sig + pos + 1, *len - pos - 1);
4806 }
else if (action < 2 && *len < 2048) {
4809 memmove(sig + pos + 1, sig + pos, *len - pos);
4813 }
else if (action < 4) {
4826 int nlow[2], nlen[2], nlenlen[2], nhbit[2], nhbyte[2], nzlen[2];
4827 size_t tlen, elen, glen;
4833 *certainly_der = der;
4834 *certainly_not_der = 0;
4837 for (n = 0; n < 2; n++) {
4842 CHECK(nlen[n] <= 232);
4849 if (nzlen[n] > ((nlen[n] == 0 || nhbit[n]) ? 1 : 0)) {
4850 *certainly_not_der = 1;
4852 CHECK(nlen[n] + nzlen[n] <= 300);
4854 nlenlen[n] = nlen[n] + nzlen[n] < 128 ? 0 : (nlen[n] + nzlen[n] < 256 ? 1 : 2);
4860 *certainly_not_der = 1;
4863 CHECK(nlen[n] + nzlen[n] + nlenlen[n] <= 427);
4867 tlen = 2 + nlenlen[0] + nlen[0] + nzlen[0] + 2 + nlenlen[1] + nlen[1] + nzlen[1];
4873 *certainly_not_der = 1;
4881 *certainly_not_der = 1;
4883 CHECK(tlen + glen <= 990);
4886 sig[(*len)++] = 0x30;
4889 sig[(*len)++] = 0x80;
4890 *certainly_not_der = 1;
4892 int tlenlen = tlen < 128 ? 0 : (tlen < 256 ? 1 : 2);
4897 *certainly_not_der = 1;
4902 sig[(*len)++] = tlen;
4905 sig[(*len)++] = 128 + tlenlen;
4912 CHECK(tlen + glen <= 1119);
4914 for (n = 0; n < 2; n++) {
4916 sig[(*len)++] = 0x02;
4917 if (nlenlen[n] == 0) {
4919 sig[(*len)++] = nlen[n] + nzlen[n];
4922 sig[(*len)++] = 128 + nlenlen[n];
4927 while (nzlen[n] > 0) {
4928 sig[(*len)++] = 0x00;
4931 if (nlen[n] == 32 && !nlow[n]) {
4934 for (i = 0; i < 16; i++) {
4935 sig[(*len)++] = 0xFF;
4941 sig[(*len)++] = nhbyte[n];
4960 CHECK(tlen + glen <= 1121);
4966 CHECK(tlen <= 1121);
4967 CHECK(tlen == *len);
4972 for (i = 0; i < 200 *
count; i++) {
4973 unsigned char buffer[2048];
4975 int certainly_der = 0;
4976 int certainly_not_der = 0;
4978 CHECK(buflen <= 2048);
4979 for (j = 0; j < 16; j++) {
4985 certainly_not_der = 0;
4990 fprintf(stderr,
"Failure %x on ", ret);
4991 for (k = 0; k < buflen; k++) {
4992 fprintf(stderr,
"%02x ", buffer[k]);
4994 fprintf(stderr,
"\n");
5024 const unsigned char pubkey_mods_zero[33] = {
5025 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5026 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5027 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
5028 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
5043 const unsigned char pubkey[33] = {
5044 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5045 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5046 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5047 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5062 const unsigned char pubkey[33] = {
5063 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5064 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5065 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5066 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5069 const unsigned char pubkey2[33] = {
5070 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5071 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5072 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
5073 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
5097 const unsigned char pubkey[33] = {
5098 0x02, 0x14, 0x4e, 0x5a, 0x58, 0xef, 0x5b, 0x22,
5099 0x6f, 0xd2, 0xe2, 0x07, 0x6a, 0x77, 0xcf, 0x05,
5100 0xb4, 0x1d, 0xe7, 0x4a, 0x30, 0x98, 0x27, 0x8c,
5101 0x93, 0xe6, 0xe6, 0x3c, 0x0b, 0xc4, 0x73, 0x76,
5104 const unsigned char pubkey2[33] = {
5105 0x02, 0x8a, 0xd5, 0x37, 0xed, 0x73, 0xd9, 0x40,
5106 0x1d, 0xa0, 0x33, 0xd2, 0xdc, 0xf0, 0xaf, 0xae,
5107 0x34, 0xcf, 0x5f, 0x96, 0x4c, 0x73, 0x28, 0x0f,
5108 0x92, 0xc0, 0xf6, 0x9d, 0xd9, 0xb2, 0x09, 0x10,
5111 const unsigned char csr[32] = {
5112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5114 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
5115 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xeb
5139 const unsigned char pubkey[33] = {
5140 0x03, 0xaf, 0x97, 0xff, 0x7d, 0x3a, 0xf6, 0xa0,
5141 0x02, 0x94, 0xbd, 0x9f, 0x4b, 0x2e, 0xd7, 0x52,
5142 0x28, 0xdb, 0x49, 0x2a, 0x65, 0xcb, 0x1e, 0x27,
5143 0x57, 0x9c, 0xba, 0x74, 0x20, 0xd5, 0x1d, 0x20,
5146 const unsigned char csr[32] = {
5147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5149 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
5150 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xee
5173 unsigned char signature[72];
5174 static const unsigned char nonce[32] = {
5175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5180 static const unsigned char nonce2[32] = {
5181 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
5182 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
5183 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
5184 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40
5186 const unsigned char key[32] = {
5187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5192 unsigned char msg[32] = {
5193 0x86, 0x41, 0x99, 0x81, 0x06, 0x23, 0x44, 0x53,
5194 0xaa, 0x5f, 0x9d, 0x6a, 0x31, 0x78, 0xf4, 0xf7,
5195 0xb8, 0x12, 0xe0, 0x0b, 0x81, 0x7a, 0x77, 0x62,
5196 0x65, 0xdf, 0xdd, 0x31, 0xb9, 0x3e, 0x29, 0xa9,
5230 CHECK(ecount == 10);
5232 CHECK(ecount == 11);
5234 CHECK(ecount == 11);
5236 CHECK(ecount == 12);
5238 CHECK(ecount == 13);
5240 CHECK(ecount == 13);
5244 CHECK(ecount == 13);
5260 memset(signature, 255, 64);
5267 for (t = 0; t < 2; t++) {
5268 static const unsigned char zero[32] = {0x00};
5270 unsigned char key[32];
5271 unsigned char msg[32];
5274 const unsigned char *extra;
5275 extra = t == 0 ? NULL : zero;
5279 memset(key, 0xFF, 32);
5301 for(i = 0; i < 256; i++) {
5307 for (j = 0; j < i; j++) {
5314 for(i = 256; i < 512; i++) {
5320 for (j = 0; j < i; j++) {
5329 const unsigned char zeros[32] = {0};
5330 unsigned char nonce[32];
5331 unsigned char nonce2[32];
5332 unsigned char nonce3[32];
5333 unsigned char nonce4[32];
5357 unsigned char privkey[300];
5358 unsigned char seckey[32] = {
5359 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5360 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
5361 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
5362 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41,
5364 size_t outlen = 300;
5375 #ifdef ENABLE_OPENSSL_TESTS
5376 EC_KEY *get_openssl_key(
const unsigned char *key32) {
5377 unsigned char privkey[300];
5379 const unsigned char* pbegin = privkey;
5381 EC_KEY *ec_key = EC_KEY_new_by_curve_name(NID_secp256k1);
5383 CHECK(d2i_ECPrivateKey(&ec_key, &pbegin, privkeylen));
5384 CHECK(EC_KEY_check_key(ec_key));
5388 void test_ecdsa_openssl(
void) {
5396 unsigned int sigsize = 80;
5397 size_t secp_sigsize = 80;
5398 unsigned char message[32];
5399 unsigned char signature[80];
5400 unsigned char key32[32];
5407 ec_key = get_openssl_key(key32);
5408 CHECK(ec_key != NULL);
5409 CHECK(ECDSA_sign(0, message,
sizeof(message), signature, &sigsize, ec_key));
5418 CHECK(ECDSA_verify(0, message,
sizeof(message), signature, secp_sigsize, ec_key) == 1);
5420 EC_KEY_free(ec_key);
5423 void run_ecdsa_openssl(
void) {
5425 for (i = 0; i < 10*
count; i++) {
5426 test_ecdsa_openssl();
5431 #ifdef ENABLE_MODULE_ECDH
5435 #ifdef ENABLE_MODULE_RECOVERY
5439 #ifdef ENABLE_MODULE_EXTRAKEYS
5443 #ifdef ENABLE_MODULE_SCHNORRSIG
5448 unsigned char buf1[6] = {1, 2, 3, 4, 5, 6};
5449 unsigned char buf2[
sizeof(buf1)];
5452 memcpy(buf2, buf1,
sizeof(buf1));
5457 memset(buf2, 0,
sizeof(buf2));
5467 CHECK(r == INT_MAX);
5471 CHECK(r == INT_MAX);
5491 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5492 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5521 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5522 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5551 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5552 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5578 static const secp256k1_ge_storage zero =
SECP256K1_GE_STORAGE_CONST(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
5579 static const secp256k1_ge_storage one =
SECP256K1_GE_STORAGE_CONST(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1);
5581 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5582 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5583 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5584 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5621 setbuf(stdout, NULL);
5624 setbuf(stderr, NULL);
5628 count = strtol(argv[1], NULL, 0);
5641 unsigned char rand32[32];
5653 #ifndef USE_NUM_NONE
5697 #ifdef ENABLE_MODULE_ECDH
5708 #ifdef ENABLE_OPENSSL_TESTS
5709 run_ecdsa_openssl();
5712 #ifdef ENABLE_MODULE_RECOVERY
5717 #ifdef ENABLE_MODULE_EXTRAKEYS
5721 #ifdef ENABLE_MODULE_SCHNORRSIG
5735 printf(
"no problems found\n");
static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b)
Compare two scalars.
static void secp256k1_scalar_mul(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Multiply two scalars (modulo the group order).
static int secp256k1_num_is_one(const secp256k1_num *a)
Check whether a number is one.
static int secp256k1_ge_is_infinity(const secp256k1_ge *a)
Check whether a group element is the point at infinity.
void test_intialized_inf(void)
static SECP256K1_INLINE int secp256k1_scalar_check_overflow(const secp256k1_scalar *a)
SECP256K1_API secp256k1_context * secp256k1_context_preallocated_create(void *prealloc, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object in caller-provided memory.
void run_hmac_sha256_tests(void)
void run_cmov_tests(void)
static int secp256k1_gej_is_infinity(const secp256k1_gej *a)
Check whether a group element is the point at infinity.
int check_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b)
static int secp256k1_num_eq(const secp256k1_num *a, const secp256k1_num *b)
Test whether two number are equal (including sign).
void test_secp256k1_pippenger_bucket_window_inv(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a public key by adding tweak times the generator to it.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Same as secp256k1_ec_seckey_tweak_mul, but DEPRECATED.
static int secp256k1_ecmult_multi_var(const secp256k1_callback *error_callback, const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
Multi-multiply: R = inp_g_sc * G + sum_i ni * Ai.
static void secp256k1_testrand256(unsigned char *b32)
Generate a pseudorandom 32-byte array.
static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr)
Set r equal to the sum of a and b.
static int secp256k1_fe_is_zero(const secp256k1_fe *a)
Verify whether a field element is zero.
void random_fe(secp256k1_fe *x)
SECP256K1_API void secp256k1_context_set_illegal_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
Set a callback function to be called when an illegal argument is passed to an API call...
void test_add_neg_y_diff_x(void)
static int secp256k1_scalar_is_even(const secp256k1_scalar *a)
Check whether a scalar, considered as an nonnegative integer, is even.
void run_ecmult_const_tests(void)
static size_t secp256k1_pippenger_scratch_size(size_t n_points, int bucket_window)
Returns the scratch size required for a given number of points (excluding base point G) without consi...
SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact(const secp256k1_context *ctx, unsigned char *output64, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Serialize an ECDSA signature in compact (64 byte) format.
SECP256K1_API void secp256k1_context_preallocated_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object that has been created in caller-provided memory.
void test_point_times_order(const secp256k1_gej *point)
#define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a)
Check whether a group element's y coordinate is a quadratic residue.
static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a)
Set r equal to the inverse of a (i.e., mirrored around the X axis)
SECP256K1_API int secp256k1_ecdsa_signature_normalize(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sigout, const secp256k1_ecdsa_signature *sigin) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3)
Convert a signature to a normalized lower-S form.
void run_group_decompress(void)
static uint32_t secp256k1_testrand32(void)
Generate a pseudorandom number in the range [0..2**32-1].
static void secp256k1_fe_mul(secp256k1_fe *r, const secp256k1_fe *a, const secp256k1_fe *SECP256K1_RESTRICT b)
Sets a field element to be the product of two others.
static void secp256k1_ecmult_gen(const secp256k1_ecmult_gen_context *ctx, secp256k1_gej *r, const secp256k1_scalar *a)
Multiply with the generator: R = a*G.
static void secp256k1_fe_normalize_var(secp256k1_fe *r)
Normalize a field element, without constant-time guarantee.
static void secp256k1_scratch_destroy(const secp256k1_callback *error_callback, secp256k1_scratch *scratch)
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen)
static void secp256k1_num_set_bin(secp256k1_num *r, const unsigned char *a, unsigned int alen)
Set a number to the value of a binary big-endian string.
static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, secp256k1_scalar *r, secp256k1_scalar *s, const secp256k1_scalar *seckey, const secp256k1_scalar *message, const secp256k1_scalar *nonce, int *recid)
void run_scalar_tests(void)
void test_sqrt(const secp256k1_fe *a, const secp256k1_fe *k)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
Updates the context randomization to protect against side-channel leakage.
static int nonce_function_test_fail(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
#define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a)
void test_random_pubkeys(void)
static void secp256k1_fe_negate(secp256k1_fe *r, const secp256k1_fe *a, int m)
Set a field element equal to the additive inverse of another.
static void secp256k1_testrand_bytes_test(unsigned char *bytes, size_t len)
Generate pseudorandom bytes with long sequences of zero and one bits.
static void secp256k1_scalar_get_num(secp256k1_num *r, const secp256k1_scalar *a)
Convert a scalar to a number.
static int nonce_function_test_retry(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const unsigned char *key, size_t size)
int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed)
Export a private key in DER format.
static void assign_big_endian(unsigned char *ptr, size_t ptrlen, uint32_t val)
static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a)
Convert a field element back from the storage type.
void test_ecmult_constants(void)
static void secp256k1_num_copy(secp256k1_num *r, const secp256k1_num *a)
Copy a number.
int ecdsa_signature_parse_der_lax(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen)
This function is taken from the libsecp256k1 distribution and implements DER parsing for ECDSA signat...
#define SECP256K1_CONTEXT_NONE
static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
Access bits from a scalar.
void run_field_misc(void)
static int secp256k1_ecdsa_sig_parse(secp256k1_scalar *r, secp256k1_scalar *s, const unsigned char *sig, size_t size)
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len)
Set a batch of group elements equal to the inputs given in jacobian coordinates.
static void secp256k1_fe_storage_cmov(secp256k1_fe_storage *r, const secp256k1_fe_storage *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
#define PIPPENGER_MAX_BUCKET_WINDOW
static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32)
static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed)
int(* secp256k1_ecmult_multi_func)(const secp256k1_callback *error_callback, const secp256k1_ecmult_context *, secp256k1_scratch *, secp256k1_gej *, const secp256k1_scalar *, secp256k1_ecmult_multi_callback cb, void *, size_t)
static int secp256k1_scalar_is_zero(const secp256k1_scalar *a)
Check whether a scalar equals zero.
void run_random_pubkeys(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_negate(const secp256k1_context *ctx, unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Negates a secret key in place.
static int secp256k1_scalar_shr_int(secp256k1_scalar *r, int n)
Shift a scalar right by some amount strictly between 0 and 16, returning the low bits that were shift...
static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a)
Set r equal to the inverse of a (i.e., mirrored around the X axis)
static void secp256k1_pubkey_save(secp256k1_pubkey *pubkey, secp256k1_ge *ge)
static void secp256k1_fe_cmov(secp256k1_fe *r, const secp256k1_fe *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
void test_wnaf(const secp256k1_scalar *number, int w)
static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv)
Set r equal to the sum of a and b (with the inverse of b's Z coordinate passed as bzinv)...
void test_ecmult_multi(secp256k1_scratch *scratch, secp256k1_ecmult_multi_func ecmult_multi)
static size_t secp256k1_scratch_checkpoint(const secp256k1_callback *error_callback, const secp256k1_scratch *scratch)
Returns an opaque object used to "checkpoint" a scratch space.
void random_scalar_order(secp256k1_scalar *num)
#define SECP256K1_GEJ_CONST_INFINITY
void random_fe_non_zero(secp256k1_fe *nz)
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Serialize a pubkey object into a serialized byte sequence.
SECP256K1_API size_t secp256k1_context_preallocated_size(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Determine the memory size of a secp256k1 context object to be created in caller-provided memory...
void test_fixed_wnaf(const secp256k1_scalar *number, int w)
static int secp256k1_wnaf_const(int *wnaf, const secp256k1_scalar *scalar, int w, int size)
Convert a number to WNAF notation.
void run_ecmult_constants(void)
static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_scalar *na, const secp256k1_scalar *ng)
Double multiply: R = na*A + ng*G.
static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow)
Set a scalar from a big endian byte array.
A group element of the secp256k1 curve, in jacobian coordinates.
static void secp256k1_fe_set_int(secp256k1_fe *r, int a)
Set a field element equal to a small integer.
size_t alloc_size
amount that has been allocated (i.e.
void(* fn)(const char *text, void *data)
static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a)
Convert a field element to the storage type.
void ge_equals_ge(const secp256k1_ge *a, const secp256k1_ge *b)
static void secp256k1_num_mod_inverse(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *m)
Compute a modular inverse.
#define SECP256K1_CONTEXT_SIGN
void test_num_add_sub(void)
void run_ecdsa_sign_verify(void)
void random_field_element_test(secp256k1_fe *fe)
void test_ecmult_multi_pippenger_max_points(void)
Probabilistically test the function returning the maximum number of possible points for a given scrat...
void scalar_cmov_test(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Same as secp256k1_ec_seckey_tweak_add, but DEPRECATED.
void test_ec_combine(void)
void test_num_negate(void)
static void secp256k1_default_illegal_callback_fn(const char *str, void *data)
void random_sign(secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *key, const secp256k1_scalar *msg, int *recid)
void test_fixed_wnaf_small_helper(int *wnaf, int *wnaf_expected, int w)
static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature *sig, const secp256k1_scalar *r, const secp256k1_scalar *s)
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
void test_ecmult_gen_blind_reset(void)
static void secp256k1_fe_clear(secp256k1_fe *a)
Sets a field element equal to zero, initializing all fields.
static void secp256k1_gej_set_infinity(secp256k1_gej *r)
Set a group element (jacobian) equal to the point at infinity.
static void * secp256k1_scratch_alloc(const secp256k1_callback *error_callback, secp256k1_scratch *scratch, size_t n)
Returns a pointer into the most recently allocated frame, or NULL if there is insufficient available ...
static int secp256k1_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate(const secp256k1_context *ctx, unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Same as secp256k1_ec_seckey_negate, but DEPRECATED.
static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a)
Adds a field element to another.
static void damage_array(unsigned char *sig, size_t *len)
static void secp256k1_fe_mul_int(secp256k1_fe *r, int a)
Multiplies the passed field element with a small integer constant.
void ge_equals_gej(const secp256k1_ge *a, const secp256k1_gej *b)
static int secp256k1_fe_is_odd(const secp256k1_fe *a)
Check the "oddness" of a field element.
void test_num_jacobi(void)
static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr)
Set r equal to the sum of a and b (with b given in affine coordinates).
void run_eckey_edge_case_test(void)
static const secp256k1_scalar secp256k1_scalar_zero
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
Set r equal to the double of a.
int ec_privkey_import_der(const secp256k1_context *ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen)
Import a private key in DER format.
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object (created in dynamically allocated memory).
int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_der, int certainly_not_der)
void fe_storage_cmov_test(void)
void run_ecdh_tests(void)
static const secp256k1_ge secp256k1_ge_const_g
Generator for secp256k1, value 'g' defined in "Standards for Efficient Cryptography" (SEC2) 2...
void run_field_inv_all_var(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute the public key for a secret key.
void test_rand_int(uint32_t range, uint32_t subrange)
#define SECP256K1_EC_UNCOMPRESSED
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift)
Multiply a and b (without taking the modulus!), divide by 2**shift, and round to the nearest integer...
void run_rfc6979_hmac_sha256_tests(void)
void run_field_inv_var(void)
void random_num_order(secp256k1_num *num)
static void secp256k1_testrand256_test(unsigned char *b32)
Generate a pseudorandom 32-byte array with long sequences of zero and one bits.
void run_ec_pubkey_parse_test(void)
static void secp256k1_ge_set_infinity(secp256k1_ge *r)
Set a group element (affine) equal to the point at infinity.
static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the inverse of a scalar (modulo the group order).
void run_scalar_set_b32_seckey_tests(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(const secp256k1_context *ctx, const unsigned char *seckey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Verify an ECDSA secret key.
void run_ecmult_gen_blind(void)
void run_ecdsa_der_parse(void)
#define PIPPENGER_SCRATCH_OBJECTS
static void secp256k1_num_sub(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
Subtract two (signed) numbers.
void run_context_tests(int use_prealloc)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT secp256k1_scratch_space * secp256k1_scratch_space_create(const secp256k1_context *ctx, size_t size) SECP256K1_ARG_NONNULL(1)
Create a secp256k1 scratch space object.
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q, int bits)
Multiply: R = q*A (in constant-time) Here bits should be set to the maximum bitlength of the absolute...
static int ecmult_multi_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *cbdata)
secp256k1_ecmult_gen_context ecmult_gen_ctx
static size_t secp256k1_pippenger_bucket_window_inv(int bucket_window)
Returns the maximum optimal number of points for a bucket_window.
void run_field_convert(void)
static void secp256k1_testrand_init(const char *hexseed)
Initialize the test RNG using (hex encoded) array up to 16 bytes, or randomly if hexseed is NULL...
#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
#define ECMULT_PIPPENGER_THRESHOLD
void run_num_smalltests(void)
void ecmult_const_mult_zero_one(void)
void ge_storage_cmov_test(void)
static secp256k1_context * ctx
void run_ecmult_chain(void)
int is_empty_signature(const secp256k1_ecdsa_signature *sig)
SECP256K1_API int secp256k1_ecdsa_sign(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void *ndata) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create an ECDSA signature.
void test_ecmult_multi_batch_size_helper(void)
static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a)
Set a group element equal to another which is given in jacobian coordinates.
#define WNAF_SIZE_BITS(bits, w)
static void secp256k1_gej_double(secp256k1_gej *r, const secp256k1_gej *a)
Set r equal to the double of a.
static int secp256k1_scalar_is_high(const secp256k1_scalar *a)
Check whether a scalar is higher than the group order divided by 2.
static void secp256k1_num_add(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
Add two (signed) numbers.
static int secp256k1_num_jacobi(const secp256k1_num *a, const secp256k1_num *b)
Compute the jacobi symbol (a|b).
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a public key by multiplying it by a tweak value.
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256 *hash, const unsigned char *data, size_t size)
static int secp256k1_scalar_set_b32_seckey(secp256k1_scalar *r, const unsigned char *bin)
Set a scalar from a big endian byte array and returns 1 if it is a valid seckey and 0 otherwise...
static void secp256k1_num_shift(secp256k1_num *r, int bits)
Right-shift the passed number by bits bits.
static void secp256k1_scalar_sqr(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the square of a scalar (modulo the group order).
static int secp256k1_pippenger_bucket_window(size_t n)
Returns optimal bucket_window (number of bits of a scalar represented by a set of buckets) for a give...
void test_group_decompress(const secp256k1_fe *x)
void run_ecdsa_end_to_end(void)
static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w)
Convert a number to WNAF notation.
static void secp256k1_num_mul(secp256k1_num *r, const secp256k1_num *a, const secp256k1_num *b)
Multiply two (signed) numbers.
void test_constant_wnaf_negate(const secp256k1_scalar *number)
#define ECMULT_MAX_POINTS_PER_BATCH
static int secp256k1_fe_is_quad_var(const secp256k1_fe *a)
Checks whether a field element is a quadratic residue.
void ec_pubkey_parse_pointtest(const unsigned char *input, int xvalid, int yvalid)
void test_ecmult_multi_batching(void)
Run secp256k1_ecmult_multi_var with num points and a scratch space restricted to 1 <= i <= num points...
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_parse(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Parse a variable-length public key into the pubkey object.
static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag)
Conditionally add a power of two to a scalar.
secp256k1_ecmult_context ecmult_ctx
static int secp256k1_ge_set_xquad(secp256k1_ge *r, const secp256k1_fe *x)
Set a group element (affine) equal to the point with the given X coordinate and a Y coordinate that i...
static void secp256k1_scalar_clear(secp256k1_scalar *r)
Clear a scalar to prevent the leak of sensitive data.
A group element of the secp256k1 curve, in affine coordinates.
static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar *r2, const secp256k1_scalar *k)
Find r1 and r2 such that r1+r2*lambda = k, where r1 and r2 or their negations are maximum 128 bits lo...
Opaque data structured that holds a parsed ECDSA signature.
static void secp256k1_fe_normalize_weak(secp256k1_fe *r)
Weakly normalize a field element: reduce its magnitude to 1, but don't fully normalize.
static void secp256k1_ge_clear(secp256k1_ge *r)
Clear a secp256k1_ge to prevent leaking sensitive information.
static uint32_t secp256k1_testrand_bits(int bits)
Generate a pseudorandom number in the range [0..2**bits-1].
static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
void test_scalar_split(const secp256k1_scalar *full)
#define SECP256K1_EC_PARSE_TEST_NINVALID
static void secp256k1_num_negate(secp256k1_num *r)
Change a number's sign.
static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256 *hash, unsigned char *out32)
static size_t secp256k1_strauss_scratch_size(size_t n_points)
void test_fixed_wnaf_small(void)
static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a)
Set r to be equal to lambda times a, where lambda is chosen in a way such that this is very fast...
A scalar modulo the group order of the secp256k1 curve.
SECP256K1_API void secp256k1_context_set_error_callback(secp256k1_context *ctx, void(*fun)(const char *message, void *data), const void *data) SECP256K1_ARG_NONNULL(1)
Set a callback function to be called when an internal consistency check fails.
static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag)
Conditionally negate a number, in constant time.
int main(int argc, char **argv)
static void secp256k1_ecdsa_signature_load(const secp256k1_context *ctx, secp256k1_scalar *r, secp256k1_scalar *s, const secp256k1_ecdsa_signature *sig)
static size_t secp256k1_scratch_max_allocation(const secp256k1_callback *error_callback, const secp256k1_scratch *scratch, size_t n_objects)
Returns the maximum allocation the scratch space will allow.
SECP256K1_API int secp256k1_ecdsa_signature_parse_der(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input, size_t inputlen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Parse a DER ECDSA signature.
void run_sha256_tests(void)
#define STRAUSS_SCRATCH_OBJECTS
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by multiplying it by a tweak.
static void secp256k1_scratch_apply_checkpoint(const secp256k1_callback *error_callback, secp256k1_scratch *scratch, size_t checkpoint)
Applies a check point received from secp256k1_scratch_checkpoint, undoing all allocations since that ...
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
Convert a scalar to a byte array.
static void secp256k1_fe_inv_all_var(secp256k1_fe *r, const secp256k1_fe *a, size_t len)
Calculate the (modular) inverses of a batch of field elements.
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd)
Set a group element (affine) equal to the point with the given X coordinate, and given oddness for Y...
void test_ecdsa_edge_cases(void)
static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the square of another.
#define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static int secp256k1_fe_set_b32(secp256k1_fe *r, const unsigned char *a)
Set a field element equal to 32-byte big endian value.
static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b)
Compare two field elements.
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
static int ecmult_multi_false_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *cbdata)
SECP256K1_API size_t secp256k1_context_preallocated_clone_size(const secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
Determine the memory size of a secp256k1 context object to be copied into caller-provided memory...
SECP256K1_API secp256k1_context * secp256k1_context_clone(const secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
Copy a secp256k1 context object (into dynamically allocated memory).
static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b)
Same as secp256k1_fe_equal, but may be variable time.
void random_group_element_jacobian_test(secp256k1_gej *gej, const secp256k1_ge *ge)
void run_scratch_tests(void)
static int secp256k1_num_cmp(const secp256k1_num *a, const secp256k1_num *b)
Compare the absolute value of two numbers.
SECP256K1_API int secp256k1_ecdsa_signature_serialize_der(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_ecdsa_signature *sig) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Serialize an ECDSA signature in DER format.
void random_scalar_order_test(secp256k1_scalar *num)
void test_ecmult_multi_batch_single(secp256k1_ecmult_multi_func ecmult_multi)
static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b)
Rescale a jacobian point by b which must be non-zero.
static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Add two scalars together (modulo the group order).
void random_scalar_order_b32(unsigned char *b32)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(const secp256k1_context *ctx, secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Negates a public key in place.
void random_group_element_test(secp256k1_ge *ge)
static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v)
Set a scalar to an unsigned integer.
static int secp256k1_ecmult_strauss_batch_single(const secp256k1_callback *error_callback, const secp256k1_ecmult_context *actx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
static size_t secp256k1_pippenger_max_points(const secp256k1_callback *error_callback, secp256k1_scratch *scratch)
Returns the maximum number of points in addition to G that can be used with a given scratch space...
SECP256K1_API int secp256k1_ecdsa_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *input64) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Parse an ECDSA signature in compact (64 bytes) format.
void test_ecmult_target(const secp256k1_scalar *target, int mode)
static void secp256k1_scalar_inverse_var(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the inverse of a scalar (modulo the group order), without constant-time guarantee.
void ecmult_const_random_mult(void)
static void random_ber_signature(unsigned char *sig, size_t *len, int *certainly_der, int *certainly_not_der)
#define SECP256K1_EC_PARSE_TEST_NVALID
void * memcpy(void *a, const void *b, size_t c)
void random_fe_test(secp256k1_fe *x)
static void secp256k1_fe_normalize(secp256k1_fe *r)
Field element module.
#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
SECP256K1_API const secp256k1_context * secp256k1_context_no_precomp
A simple secp256k1 context object with no precomputed tables.
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
void test_ecdsa_sign_verify(void)
static int secp256k1_ecdsa_sig_verify(const secp256k1_ecmult_context *ctx, const secp256k1_scalar *r, const secp256k1_scalar *s, const secp256k1_ge *pubkey, const secp256k1_scalar *message)
static int secp256k1_num_is_zero(const secp256k1_num *a)
Check whether a number is zero.
static int precomputed_nonce_function(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
Dummy nonce generation function that just uses a precomputed nonce, and fails if it is not accepted...
int fe_secp256k1_memcmp_var(const secp256k1_fe *a, const secp256k1_fe *b)
static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
Access bits from a scalar.
void test_ecdsa_end_to_end(void)
static int secp256k1_ecmult_pippenger_batch_single(const secp256k1_callback *error_callback, const secp256k1_ecmult_context *actx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n)
static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe *a)
Convert a field element to a 32-byte big endian value.
static const secp256k1_scalar scalars_near_split_bounds[20]
static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b)
Set r equal to the sum of a and b (with b given in affine coordinates, and not infinity).
static int secp256k1_pubkey_load(const secp256k1_context *ctx, secp256k1_ge *ge, const secp256k1_pubkey *pubkey)
secp256k1_callback error_callback
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_combine(const secp256k1_context *ctx, secp256k1_pubkey *out, const secp256k1_pubkey *const *ins, size_t n) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Add a number of public keys together.
void test_constant_wnaf(const secp256k1_scalar *number, int w)
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
static void secp256k1_num_mod(secp256k1_num *r, const secp256k1_num *m)
Replace a number by its remainder modulo m.
void random_num_negate(secp256k1_num *num)
void random_field_element_magnitude(secp256k1_fe *fe)
void run_ecmult_near_split_bound(void)
static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a)
Set a group element (jacobian) equal to another which is given in affine coordinates.
void ecmult_const_commutativity(void)
void run_endomorphism_tests(void)
static void counting_illegal_callback_fn(const char *str, void *data)
static int secp256k1_ecmult_multi_batch_size_helper(size_t *n_batches, size_t *n_batch_points, size_t max_n_batch_points, size_t n)
void random_num_order_test(secp256k1_num *num)
void ecmult_const_chain_multiply(void)
static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w)
Convert a number to WNAF notation.
static void secp256k1_scalar_order_get_num(secp256k1_num *r)
Get the order of the group as a number.
void test_ecmult_gen_blind(void)
static SECP256K1_INLINE void secp256k1_int_cmov(int *r, const int *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
int gej_xyz_equals_gej(const secp256k1_gej *a, const secp256k1_gej *b)
static secp256k1_scratch * secp256k1_scratch_create(const secp256k1_callback *error_callback, size_t max_size)
void run_ecmult_multi_tests(void)
static int secp256k1_ge_is_valid_var(const secp256k1_ge *a)
Check whether a group element is valid (i.e., on the curve).
SECP256K1_API secp256k1_context * secp256k1_context_preallocated_clone(const secp256k1_context *ctx, void *prealloc) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_WARN_UNUSED_RESULT
Copy a secp256k1 context object into caller-provided memory.
static int secp256k1_fe_sqrt(secp256k1_fe *r, const secp256k1_fe *a)
If a has a square root, it is computed in r and 1 is returned.
static const secp256k1_scalar secp256k1_const_lambda
The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where lambda is: ...
static void secp256k1_scalar_cmov(secp256k1_scalar *r, const secp256k1_scalar *a, int flag)
If flag is true, set *r equal to *a; otherwise leave it.
static const secp256k1_scalar secp256k1_scalar_one
SECP256K1_API void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space *scratch) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 scratch space.
void random_fe_non_square(secp256k1_fe *ns)
void * memmove(void *a, const void *b, size_t c)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by adding tweak to it.
static void secp256k1_fe_inv_var(secp256k1_fe *r, const secp256k1_fe *a)
Potentially faster version of secp256k1_fe_inv, without constant-time guarantee.
static SECP256K1_INLINE void memczero(void *s, size_t len, int flag)
static SECP256K1_INLINE void * checked_malloc(const secp256k1_callback *cb, size_t size)
static void secp256k1_num_get_bin(unsigned char *r, unsigned int rlen, const secp256k1_num *a)
Convert a number's absolute value to a binary big-endian string.
static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the (modular) inverse of another.
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
void run_ec_combine(void)
static void uncounting_illegal_callback_fn(const char *str, void *data)
void run_ecdsa_edge_cases(void)
static int secp256k1_scalar_is_one(const secp256k1_scalar *a)
Check whether a scalar equals one.
void test_rand_bits(int rand32, int bits)
void run_recovery_tests(void)
static int secp256k1_num_is_neg(const secp256k1_num *a)
Check whether a number is strictly negative.
int check_fe_inverse(const secp256k1_fe *a, const secp256k1_fe *ai)
#define SECP256K1_EC_PARSE_TEST_NXVALID
void run_schnorrsig_tests(void)
static uint32_t secp256k1_testrand_int(uint32_t range)
Generate a pseudorandom number in the range [0..range-1].
void run_memczero_test(void)
static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256 *rng)
static int secp256k1_ecdsa_sig_serialize(unsigned char *sig, size_t *size, const secp256k1_scalar *r, const secp256k1_scalar *s)
void run_point_times_order(void)
Opaque data structure that holds a parsed and valid public key.
static void secp256k1_testrand_finish(void)
Print final test information.
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen)
void run_eckey_negate_test(void)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msg32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Verify an ECDSA signature.