7#if defined HAVE_CONFIG_H
8#include "libsecp256k1-config.h"
27#ifdef SECP256K1_WIDEMUL_INT128
52 unsigned char b32[32];
72 CHECK(fe->magnitude == n);
105 unsigned char b32[32];
118 unsigned char b32[32];
139 unsigned char ctmp[32];
146 void *none_prealloc = NULL;
147 void *sign_prealloc = NULL;
148 void *vrfy_prealloc = NULL;
149 void *both_prealloc = NULL;
161 CHECK(none_prealloc != NULL);
162 CHECK(sign_prealloc != NULL);
163 CHECK(vrfy_prealloc != NULL);
164 CHECK(both_prealloc != NULL);
176 memset(&zero_pubkey, 0,
sizeof(zero_pubkey));
265 CHECK(ecount2 == 10);
267 CHECK(ecount2 == 11);
271 CHECK(ecount2 == 12);
275 CHECK(ecount2 == 13);
281 CHECK(ecount2 == 14);
291 CHECK(ecount2 == 14);
293 CHECK(ecount2 == 14);
347 CHECK(scratch != NULL);
389 memset(&local_scratch, 0,
sizeof(local_scratch));
390 scratch = &local_scratch;
416 static const uint32_t b32[] = {1, 0xffffffff, 0x5e56968f, 0xe0d63129};
417 static const uint64_t b64[] = {1, 0xffffffffffffffff, 0xbcd02462139b3fc3, 0x98b5f80c769693ef};
420 for (i = 0; i <
sizeof(b32) /
sizeof(b32[0]); ++i) {
421 for (shift = 0; shift < 32; ++shift) {
426 for (i = 0; i <
sizeof(b64) /
sizeof(b64[0]); ++i) {
427 for (shift = 0; shift < 64; ++shift) {
437 static const char *inputs[8] = {
438 "",
"abc",
"message digest",
"secure hash algorithm",
"SHA256 is considered to be safe",
439 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
440 "For this sample, this 63-byte string will be used as input data",
441 "This is exactly 64 bytes long, not counting the terminating byte"
443 static const unsigned char outputs[8][32] = {
444 {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},
445 {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},
446 {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},
447 {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},
448 {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},
449 {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},
450 {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},
451 {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}
454 for (i = 0; i < 8; i++) {
455 unsigned char out[32];
461 if (strlen(inputs[i]) > 0) {
473 static const char *keys[6] = {
474 "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b",
476 "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa",
477 "\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",
478 "\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",
479 "\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"
481 static const char *inputs[6] = {
482 "\x48\x69\x20\x54\x68\x65\x72\x65",
483 "\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",
484 "\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",
485 "\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",
486 "\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",
487 "\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"
489 static const unsigned char outputs[6][32] = {
490 {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},
491 {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},
492 {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},
493 {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},
494 {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},
495 {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}
498 for (i = 0; i < 6; i++) {
500 unsigned char out[32];
505 if (strlen(inputs[i]) > 0) {
517 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};
518 static const unsigned char out1[3][32] = {
519 {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},
520 {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},
521 {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}
524 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};
525 static const unsigned char out2[3][32] = {
526 {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},
527 {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},
528 {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}
532 unsigned char out[32];
536 for (i = 0; i < 3; i++) {
543 for (i = 0; i < 3; i++) {
550 for (i = 0; i < 3; i++) {
560 unsigned char tag[32] = { 0 };
561 unsigned char msg[32] = { 0 };
562 unsigned char hash32[32];
563 unsigned char hash_expected[32] = {
564 0x04, 0x7A, 0x5E, 0x17, 0xB5, 0x86, 0x47, 0xC1,
565 0x3C, 0xC6, 0xEB, 0xC0, 0xAA, 0x58, 0x3B, 0x62,
566 0xFB, 0x16, 0x43, 0x32, 0x68, 0x77, 0x40, 0x6C,
567 0xE2, 0x76, 0x55, 0x9A, 0x3B, 0xDE, 0x55, 0xB3
582 memcpy(tag,
"tag", 3);
583 memcpy(msg,
"msg", 3);
594 static const unsigned int rounds[7] = {1, 30, 73, 156, 322, 653, 1316};
597 static const uint32_t mults[6] = {1, 3, 21, 289, 0x9999, 0x80402011};
599 unsigned int usebits = bits > 6 ? 6 : bits;
600 unsigned int maxshift = bits - usebits;
603 uint64_t x[6][27] = {{0}};
604 unsigned int i, shift, m;
607 for (i = 0; i < rounds[usebits]; i++) {
609 CHECK((((uint64_t)r) >> bits) == 0);
610 for (m = 0; m <
sizeof(mults) /
sizeof(mults[0]); m++) {
611 uint32_t rm = r * mults[m];
612 for (shift = 0; shift <= maxshift; shift++) {
613 x[m][shift] |= (((uint64_t)1) << ((rm >> shift) & ((1 << usebits) - 1)));
617 for (m = 0; m <
sizeof(mults) /
sizeof(mults[0]); m++) {
618 for (shift = 0; shift <= maxshift; shift++) {
620 CHECK(((~x[m][shift]) << (64 - (1 << usebits))) == 0);
628 int rounds = (subrange * 2073) / 100;
631 CHECK((range % subrange) == 0);
632 for (i = 0; i < rounds; i++) {
636 x |= (((uint64_t)1) << r);
639 CHECK(((~x) << (64 - subrange)) == 0);
645 for (b = 1; b <= 32; b++) {
651 static const uint32_t ms[] = {1, 3, 17, 1000, 13771, 999999, 33554432};
652 static const uint32_t ss[] = {1, 3, 6, 9, 13, 31, 64};
654 for (m = 0; m <
sizeof(ms) /
sizeof(ms[0]); m++) {
655 for (s = 0; s <
sizeof(ss) /
sizeof(ss[0]); s++) {
672 for (l = 0; l < 6; ++l) w *= (2 - w*x);
680void mulmod256(uint16_t* out,
const uint16_t* a,
const uint16_t* b,
const uint16_t* m) {
689 for (i = 0; i < 32; ++i) {
690 for (j = i <= 15 ? 0 : i - 15; j <= i && j <= 15; j++) {
691 c += (uint64_t)a[j] * b[i - j];
699 for (i = 511; i >= 0; --i) {
700 if ((mul[i >> 4] >> (i & 15)) & 1) {
708 memset(mul + 16, 0, 32);
710 for (i = 255; i >= 0; --i) {
711 if ((mul[i >> 4] >> (i & 15)) & 1) {
719 for (i = 255; i >= 0; --i) {
720 if ((m[i >> 4] >> (i & 15)) & 1) {
727 for (i = mul_bitlen - m_bitlen; i >= 0; --i) {
733 for (j = 0; j < 32; ++j) {
737 for (p = 0; p < 16; ++p) {
738 int bitpos = j * 16 - i + p;
739 if (bitpos >= 0 && bitpos < 256) {
740 sub |= ((m[bitpos >> 4] >> (bitpos & 15)) & 1) << p;
746 mul2[j] = (
cs & 0xFFFF);
751 memcpy(mul, mul2,
sizeof(mul));
755 for (i = (m_bitlen >> 4) + 1; i < 32; ++i) {
758 memcpy(out, mul, 32);
764 memset(out->
v, 0,
sizeof(out->
v));
765 for (i = 0; i < 256; ++i) {
766 out->
v[i / 30] |= (int32_t)(((in[i >> 4]) >> (i & 15)) & 1) << (i % 30);
774 for (i = 0; i < 256; ++i) {
775 out[i >> 4] |= (((in->
v[i / 30]) >> (i % 30)) & 1) << (i & 15);
782 for (i = 0; i < 16; ++i) {
784 if (x->
v[pos] > 0 && x->
v[pos + 1] <= 0x3fffffff) {
785 x->
v[pos] -= 0x40000000;
787 }
else if (x->
v[pos] < 0 && x->
v[pos + 1] >= 0x3fffffff) {
788 x->
v[pos] += 0x40000000;
799 int i, vartime, nonzero;
802 nonzero = (x.
v[0] | x.
v[1] | x.
v[2] | x.
v[3] | x.
v[4] | x.
v[5] | x.
v[6] | x.
v[7] | x.
v[8]) != 0;
810 for (vartime = 0; vartime < 2; ++vartime) {
819 CHECK(tmp[0] == nonzero);
820 for (i = 1; i < 16; ++i)
CHECK(tmp[i] == 0);
827 for (i = 0; i < 16; ++i)
CHECK(tmp[i] == in[i]);
831#ifdef SECP256K1_WIDEMUL_INT128
835 memset(out->
v, 0,
sizeof(out->
v));
836 for (i = 0; i < 256; ++i) {
837 out->
v[i / 62] |= (int64_t)(((in[i >> 4]) >> (i & 15)) & 1) << (i % 62);
845 for (i = 0; i < 256; ++i) {
846 out[i >> 4] |= (((in->
v[i / 62]) >> (i % 62)) & 1) << (i & 15);
852 static const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
854 for (i = 0; i < 8; ++i) {
856 if (x->
v[pos] > 0 && x->
v[pos + 1] <= M62) {
857 x->
v[pos] -= (M62 + 1);
859 }
else if (x->
v[pos] < 0 && x->
v[pos + 1] >= -M62) {
860 x->
v[pos] += (M62 + 1);
867void test_modinv64_uint16(uint16_t* out,
const uint16_t* in,
const uint16_t* mod) {
868 static const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
872 int i, vartime, nonzero;
874 uint16_to_signed62(&x, in);
875 nonzero = (x.
v[0] | x.
v[1] | x.
v[2] | x.
v[3] | x.
v[4]) != 0;
876 uint16_to_signed62(&m.
modulus, mod);
877 mutate_sign_signed62(&m.
modulus);
883 for (vartime = 0; vartime < 2; ++vartime) {
888 signed62_to_uint16(out, &x);
892 CHECK(tmp[0] == nonzero);
893 for (i = 1; i < 16; ++i)
CHECK(tmp[i] == 0);
899 signed62_to_uint16(tmp, &x);
900 for (i = 0; i < 16; ++i)
CHECK(tmp[i] == in[i]);
906int coprime(
const uint16_t* a,
const uint16_t* b) {
907 uint16_t x[16], y[16], t[16];
916 for (i = 0; i < 16; ++i) {
929 if (y[0] != 1)
return 0;
930 for (i = 1; i < 16; ++i) {
931 if (y[i] != 0)
return 0;
938 static const uint16_t CASES[][3][16] = {
940 {{0x1513, 0x5389, 0x54e9, 0x2798, 0x1957, 0x66a0, 0x8057, 0x3477,
941 0x7784, 0x1052, 0x326a, 0x9331, 0x6506, 0xa95c, 0x91f3, 0xfb5e},
942 {0x2bdd, 0x8df4, 0xcc61, 0x481f, 0xdae5, 0x5ca7, 0xf43b, 0x7d54,
943 0x13d6, 0x469b, 0x2294, 0x20f4, 0xb2a4, 0xa2d1, 0x3ff1, 0xfd4b},
944 {0xffd8, 0xd9a0, 0x456e, 0x81bb, 0xbabd, 0x6cea, 0x6dbd, 0x73ab,
945 0xbb94, 0x3d3c, 0xdf08, 0x31c4, 0x3e32, 0xc179, 0x2486, 0xb86b}},
948 {{0x3fb1, 0x903b, 0x4eb7, 0x4813, 0xd863, 0x26bf, 0xd89f, 0xa8a9,
949 0x02fe, 0x57c6, 0x554a, 0x4eab, 0x165e, 0x3d61, 0xee1e, 0x456c},
950 {0x9295, 0x823b, 0x5c1f, 0x5386, 0x48e0, 0x02ff, 0x4c2a, 0xa2da,
951 0xe58f, 0x967c, 0xc97e, 0x3f5a, 0x69fb, 0x52d9, 0x0a86, 0xb4a3},
952 {0x3d30, 0xb893, 0xa809, 0xa7a8, 0x26f5, 0x5b42, 0x55be, 0xf4d0,
953 0x12c2, 0x7e6a, 0xe41a, 0x90c7, 0xebfa, 0xf920, 0x304e, 0x1419}},
955 {{0x8583, 0x5058, 0xbeae, 0xeb69, 0x48bc, 0x52bb, 0x6a9d, 0xcc94,
956 0x2a21, 0x87d5, 0x5b0d, 0x42f6, 0x5b8a, 0x2214, 0xe9d6, 0xa040},
957 {0x7531, 0x27cb, 0x7e53, 0xb739, 0x6a5f, 0x83f5, 0xa45c, 0xcb1d,
958 0x8a87, 0x1c9c, 0x51d7, 0x851c, 0xb9d8, 0x1fbe, 0xc241, 0xd4a3},
959 {0xcdb4, 0x275c, 0x7d22, 0xa906, 0x0173, 0xc054, 0x7fdf, 0x5005,
960 0x7fb8, 0x9059, 0xdf51, 0x99df, 0x2654, 0x8f6e, 0x070f, 0xb347}},
962 {{0x95ed, 0x6c01, 0xd113, 0x5ff1, 0xd7d0, 0x29cc, 0x5817, 0x6120,
963 0xca8e, 0xaad1, 0x25ae, 0x8e84, 0x9af6, 0x30bf, 0xf0ed, 0x1686},
964 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
965 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
966 {0x1631, 0xbf4a, 0x286a, 0x2716, 0x469f, 0x2ac8, 0x1312, 0xe9bc,
967 0x04f4, 0x304b, 0x9931, 0x113b, 0xd932, 0xc8f4, 0x0d0d, 0x01a1}},
969 {{0x9ec3, 0x1919, 0xca84, 0x7c11, 0xf996, 0x06f3, 0x5408, 0x6688,
970 0x1320, 0xdb8a, 0x632a, 0x0dcb, 0x8a84, 0x6bee, 0x9c95, 0xe34e},
971 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
972 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
973 {0x18e5, 0x19b6, 0xdf92, 0x1aaa, 0x09fb, 0x8a3f, 0x52b0, 0x8701,
974 0xac0c, 0x2582, 0xda44, 0x9bcc, 0x6828, 0x1c53, 0xbd8f, 0xbd2c}},
977 {{0x1b37, 0xbdc3, 0x8bcd, 0x25e3, 0x1eae, 0x567d, 0x30b6, 0xf0d8,
978 0x9277, 0x0cf8, 0x9c2e, 0xecd7, 0x631d, 0xe38f, 0xd4f8, 0x5c93},
979 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
980 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
981 {0x1622, 0xe05b, 0xe880, 0x7de9, 0x3e45, 0xb682, 0xee6c, 0x67ed,
982 0xa179, 0x15db, 0x6b0d, 0xa656, 0x7ccb, 0x8ef7, 0xa2ff, 0xe279}},
985 {{0xfeb9, 0xb877, 0xee41, 0x7fa3, 0x87da, 0x94c4, 0x9d04, 0xc5ae,
986 0x5708, 0x0994, 0xfc79, 0x0916, 0xbf32, 0x3ad8, 0xe11c, 0x5ca2},
987 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
988 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
989 {0x0f12, 0x075e, 0xce1c, 0x6f92, 0xc80f, 0xca92, 0x9a04, 0x6126,
990 0x4b6c, 0x57d6, 0xca31, 0x97f3, 0x1f99, 0xf4fd, 0xda4d, 0x42ce}},
992 {{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
993 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
994 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
995 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
996 {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
997 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
999 {{0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1000 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
1001 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1002 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1003 {0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1004 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
1006 {{0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1007 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
1008 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1009 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1010 {0xfe18, 0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1011 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x7fff}},
1013 {{0xfc2e, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1014 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1015 {0xfc2f, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1016 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1017 {0xfc2e, 0xffff, 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
1018 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}},
1020 {{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1021 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
1022 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1023 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1024 {0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1025 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
1027 {{0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1028 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
1029 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1030 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1031 {0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1032 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000}},
1034 {{0x0002, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
1035 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000},
1036 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1037 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1038 {0x20a1, 0x681b, 0x2f46, 0xdfe9, 0x501d, 0x57a4, 0x6e73, 0x5d57,
1039 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0x7fff}},
1041 {{0x4140, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1042 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1043 {0x4141, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1044 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff},
1045 {0x4140, 0xd036, 0x5e8c, 0xbfd2, 0xa03b, 0xaf48, 0xdce6, 0xbaae,
1046 0xfffe, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}}
1052 for (i = 0; (size_t)i <
sizeof(CASES) /
sizeof(CASES[0]); ++i) {
1055 for (j = 0; j < 16; ++j)
CHECK(out[j] == CASES[i][2][j]);
1056#ifdef SECP256K1_WIDEMUL_INT128
1057 test_modinv64_uint16(out, CASES[i][0], CASES[i][1]);
1058 for (j = 0; j < 16; ++j)
CHECK(out[j] == CASES[i][2][j]);
1062 for (i = 0; i < 100 *
count; ++i) {
1064 static const uint16_t ZERO[16] = {0};
1077 for (j = 1; j < 16; ++j) ok |= md[j] != 0;
1079 }
while (!(ok &&
coprime(xd, md)));
1082#ifdef SECP256K1_WIDEMUL_INT128
1083 test_modinv64_uint16(
id, xd, md);
1089#ifdef SECP256K1_WIDEMUL_INT128
1090 test_modinv64_uint16(
id, ZERO, md);
1103 unsigned char c[32];
1120 for (i = 0; i < 256; i += 4) {
1124 for (j = 0; j < 4; j++) {
1141 if (now + i > 256) {
1145 for (j = 0; j < now; j++) {
1159 for (i = 0; i < 100; ++i) {
1162 int expected = r.
d[0] % (1 << shift);
1164 CHECK(expected == low);
1184 for (i = 0; i < bit; i++) {
1265 unsigned char b32[32];
1275 memset(b32, 0,
sizeof(b32));
1277 memset(b32, 0xFF,
sizeof(b32));
1283 for (i = 0; i < 128 *
count; i++) {
1286 for (i = 0; i <
count; i++) {
1305 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
1306 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
1326 unsigned char chal[33][2][32] = {
1327 {{0xff, 0xff, 0x03, 0x07, 0x00, 0x00, 0x00, 0x00,
1328 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
1329 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
1330 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff},
1331 {0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00,
1332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
1333 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1334 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff}},
1335 {{0xef, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00,
1336 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
1337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1339 {0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
1341 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
1342 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x80, 0xff}},
1343 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1344 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
1345 0x80, 0x00, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x00,
1346 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00},
1347 {0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x80,
1348 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xe0,
1349 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00,
1350 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff}},
1351 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1352 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1353 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1354 0x00, 0x1e, 0xf8, 0xff, 0xff, 0xff, 0xfd, 0xff},
1355 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
1356 0x00, 0x00, 0x00, 0xf8, 0xff, 0x03, 0x00, 0xe0,
1357 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xff,
1358 0xf3, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}},
1359 {{0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00,
1360 0x00, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
1361 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0x00,
1362 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff},
1363 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00,
1364 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1365 0xff, 0x1f, 0x00, 0x00, 0x80, 0xff, 0xff, 0x3f,
1366 0x00, 0xfe, 0xff, 0xff, 0xff, 0xdf, 0xff, 0xff}},
1367 {{0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xfc, 0x9f,
1368 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
1369 0xff, 0x0f, 0xfc, 0xff, 0x7f, 0x00, 0x00, 0x00,
1370 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1371 {0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1372 0x00, 0x00, 0xf8, 0xff, 0x0f, 0xc0, 0xff, 0xff,
1373 0xff, 0x1f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff,
1374 0xff, 0xff, 0xff, 0x07, 0x80, 0xff, 0xff, 0xff}},
1375 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00,
1376 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1377 0xf7, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0x00,
1378 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf0},
1379 {0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff,
1380 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1381 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
1382 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1383 {{0x00, 0xf8, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00,
1384 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1385 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1386 0xff, 0xff, 0x03, 0xc0, 0xff, 0x0f, 0xfc, 0xff},
1387 {0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xff, 0xff,
1388 0xff, 0x01, 0x00, 0x00, 0x00, 0x3f, 0x00, 0xc0,
1389 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1390 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1391 {{0x8f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1392 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff,
1393 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1394 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1395 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1396 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1397 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1398 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1399 {{0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
1400 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1401 0xff, 0xff, 0x03, 0x00, 0x80, 0x00, 0x00, 0x80,
1402 0xff, 0xff, 0xff, 0x00, 0x00, 0x80, 0xff, 0x7f},
1403 {0xff, 0xcf, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
1404 0x00, 0xc0, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff,
1405 0xbf, 0xff, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
1406 0x80, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00}},
1407 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff,
1408 0xff, 0xff, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
1409 0xff, 0xff, 0xff, 0x00, 0x80, 0x00, 0x00, 0x80,
1410 0xff, 0x01, 0xfc, 0xff, 0x01, 0x00, 0xfe, 0xff},
1411 {0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00,
1412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
1414 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00}},
1415 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1416 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1417 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1418 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
1419 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1420 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0xff,
1421 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
1422 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1423 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1424 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1426 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x00},
1427 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
1428 0xfc, 0xff, 0xff, 0x3f, 0xf0, 0xff, 0xff, 0x3f,
1429 0x00, 0x00, 0xf8, 0x07, 0x00, 0x00, 0x00, 0xff,
1430 0xff, 0xff, 0xff, 0xff, 0x0f, 0x7e, 0x00, 0x00}},
1431 {{0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1432 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1433 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1434 0xff, 0xff, 0x1f, 0x00, 0x00, 0xfe, 0x07, 0x00},
1435 {0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff,
1436 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1437 0xff, 0xfb, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00,
1438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60}},
1439 {{0xff, 0x01, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00,
1440 0x80, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03,
1441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1442 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1443 {0xff, 0xff, 0x1f, 0x00, 0xf0, 0xff, 0xff, 0xff,
1444 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1445 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1446 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00}},
1447 {{0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
1448 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1449 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1450 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1451 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1452 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
1453 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
1454 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff}},
1455 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1456 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1457 0xc0, 0xff, 0xff, 0xcf, 0xff, 0x1f, 0x00, 0x00,
1458 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80},
1459 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1460 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1461 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x7e,
1462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1463 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1464 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff,
1465 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
1466 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00},
1467 {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1468 0xff, 0xff, 0x7f, 0x00, 0x80, 0x00, 0x00, 0x00,
1469 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1470 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff}},
1471 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1472 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1473 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1474 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1475 {0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1476 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x80,
1477 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
1478 0xff, 0x7f, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0xfe}},
1479 {{0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xff,
1480 0xff, 0x03, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00,
1481 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1482 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07},
1483 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1484 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
1485 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff,
1486 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}},
1487 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1488 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1489 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1490 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1491 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1492 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1493 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1494 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40}},
1495 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1497 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1498 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
1499 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1500 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1501 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1502 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1503 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1504 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1505 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1506 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1507 {0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1508 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1509 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1510 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1511 {{0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xc0,
1512 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1513 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff,
1514 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f},
1515 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00,
1516 0xf0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x00,
1517 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff,
1518 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff}},
1519 {{0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1520 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1521 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1522 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1523 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1524 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1525 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1526 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}},
1527 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1528 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1529 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1530 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1531 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1532 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1533 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1534 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1535 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1536 0x7e, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
1537 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
1538 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1539 {0xff, 0x01, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1540 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x80,
1541 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00,
1542 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}},
1543 {{0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x00,
1544 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1545 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1546 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff},
1547 {0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff,
1548 0xff, 0xff, 0x3f, 0x00, 0xf8, 0xff, 0xff, 0xff,
1549 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1550 0xff, 0x3f, 0x00, 0x00, 0xc0, 0xf1, 0x7f, 0x00}},
1551 {{0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1552 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff,
1553 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
1554 0x80, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x00},
1555 {0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
1556 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1557 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1f,
1558 0x00, 0x00, 0xfc, 0xff, 0xff, 0x01, 0xff, 0xff}},
1559 {{0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1560 0x80, 0x00, 0x00, 0x80, 0xff, 0x03, 0xe0, 0x01,
1561 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff,
1562 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00},
1563 {0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
1564 0xfe, 0xff, 0xff, 0xf0, 0x07, 0x00, 0x3c, 0x80,
1565 0xff, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff,
1566 0xff, 0xff, 0x07, 0xe0, 0xff, 0x00, 0x00, 0x00}},
1567 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
1568 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1569 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf8,
1570 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80},
1571 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1572 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x80, 0x00,
1573 0x00, 0x00, 0x00, 0xc0, 0x7f, 0xfe, 0xff, 0x1f,
1574 0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0xfe, 0xff}},
1575 {{0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 0x00,
1576 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x83,
1577 0xff, 0xff, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
1578 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xf0},
1579 {0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff,
1580 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00,
1581 0xf8, 0x07, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff,
1582 0xff, 0xc7, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff}},
1583 {{0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1584 0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1585 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x03, 0xfb,
1586 0xfa, 0x8a, 0x7d, 0xdf, 0x13, 0x86, 0xe2, 0x03},
1587 {0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1588 0x82, 0xc9, 0xfa, 0xb0, 0x68, 0x04, 0xa0, 0x00,
1589 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x03, 0xfb,
1590 0xfa, 0x8a, 0x7d, 0xdf, 0x13, 0x86, 0xe2, 0x03}}
1592 unsigned char res[33][2][32] = {
1593 {{0x0c, 0x3b, 0x0a, 0xca, 0x8d, 0x1a, 0x2f, 0xb9,
1594 0x8a, 0x7b, 0x53, 0x5a, 0x1f, 0xc5, 0x22, 0xa1,
1595 0x07, 0x2a, 0x48, 0xea, 0x02, 0xeb, 0xb3, 0xd6,
1596 0x20, 0x1e, 0x86, 0xd0, 0x95, 0xf6, 0x92, 0x35},
1597 {0xdc, 0x90, 0x7a, 0x07, 0x2e, 0x1e, 0x44, 0x6d,
1598 0xf8, 0x15, 0x24, 0x5b, 0x5a, 0x96, 0x37, 0x9c,
1599 0x37, 0x7b, 0x0d, 0xac, 0x1b, 0x65, 0x58, 0x49,
1600 0x43, 0xb7, 0x31, 0xbb, 0xa7, 0xf4, 0x97, 0x15}},
1601 {{0xf1, 0xf7, 0x3a, 0x50, 0xe6, 0x10, 0xba, 0x22,
1602 0x43, 0x4d, 0x1f, 0x1f, 0x7c, 0x27, 0xca, 0x9c,
1603 0xb8, 0xb6, 0xa0, 0xfc, 0xd8, 0xc0, 0x05, 0x2f,
1604 0xf7, 0x08, 0xe1, 0x76, 0xdd, 0xd0, 0x80, 0xc8},
1605 {0xe3, 0x80, 0x80, 0xb8, 0xdb, 0xe3, 0xa9, 0x77,
1606 0x00, 0xb0, 0xf5, 0x2e, 0x27, 0xe2, 0x68, 0xc4,
1607 0x88, 0xe8, 0x04, 0xc1, 0x12, 0xbf, 0x78, 0x59,
1608 0xe6, 0xa9, 0x7c, 0xe1, 0x81, 0xdd, 0xb9, 0xd5}},
1609 {{0x96, 0xe2, 0xee, 0x01, 0xa6, 0x80, 0x31, 0xef,
1610 0x5c, 0xd0, 0x19, 0xb4, 0x7d, 0x5f, 0x79, 0xab,
1611 0xa1, 0x97, 0xd3, 0x7e, 0x33, 0xbb, 0x86, 0x55,
1612 0x60, 0x20, 0x10, 0x0d, 0x94, 0x2d, 0x11, 0x7c},
1613 {0xcc, 0xab, 0xe0, 0xe8, 0x98, 0x65, 0x12, 0x96,
1614 0x38, 0x5a, 0x1a, 0xf2, 0x85, 0x23, 0x59, 0x5f,
1615 0xf9, 0xf3, 0xc2, 0x81, 0x70, 0x92, 0x65, 0x12,
1616 0x9c, 0x65, 0x1e, 0x96, 0x00, 0xef, 0xe7, 0x63}},
1617 {{0xac, 0x1e, 0x62, 0xc2, 0x59, 0xfc, 0x4e, 0x5c,
1618 0x83, 0xb0, 0xd0, 0x6f, 0xce, 0x19, 0xf6, 0xbf,
1619 0xa4, 0xb0, 0xe0, 0x53, 0x66, 0x1f, 0xbf, 0xc9,
1620 0x33, 0x47, 0x37, 0xa9, 0x3d, 0x5d, 0xb0, 0x48},
1621 {0x86, 0xb9, 0x2a, 0x7f, 0x8e, 0xa8, 0x60, 0x42,
1622 0x26, 0x6d, 0x6e, 0x1c, 0xa2, 0xec, 0xe0, 0xe5,
1623 0x3e, 0x0a, 0x33, 0xbb, 0x61, 0x4c, 0x9f, 0x3c,
1624 0xd1, 0xdf, 0x49, 0x33, 0xcd, 0x72, 0x78, 0x18}},
1625 {{0xf7, 0xd3, 0xcd, 0x49, 0x5c, 0x13, 0x22, 0xfb,
1626 0x2e, 0xb2, 0x2f, 0x27, 0xf5, 0x8a, 0x5d, 0x74,
1627 0xc1, 0x58, 0xc5, 0xc2, 0x2d, 0x9f, 0x52, 0xc6,
1628 0x63, 0x9f, 0xba, 0x05, 0x76, 0x45, 0x7a, 0x63},
1629 {0x8a, 0xfa, 0x55, 0x4d, 0xdd, 0xa3, 0xb2, 0xc3,
1630 0x44, 0xfd, 0xec, 0x72, 0xde, 0xef, 0xc0, 0x99,
1631 0xf5, 0x9f, 0xe2, 0x52, 0xb4, 0x05, 0x32, 0x58,
1632 0x57, 0xc1, 0x8f, 0xea, 0xc3, 0x24, 0x5b, 0x94}},
1633 {{0x05, 0x83, 0xee, 0xdd, 0x64, 0xf0, 0x14, 0x3b,
1634 0xa0, 0x14, 0x4a, 0x3a, 0x41, 0x82, 0x7c, 0xa7,
1635 0x2c, 0xaa, 0xb1, 0x76, 0xbb, 0x59, 0x64, 0x5f,
1636 0x52, 0xad, 0x25, 0x29, 0x9d, 0x8f, 0x0b, 0xb0},
1637 {0x7e, 0xe3, 0x7c, 0xca, 0xcd, 0x4f, 0xb0, 0x6d,
1638 0x7a, 0xb2, 0x3e, 0xa0, 0x08, 0xb9, 0xa8, 0x2d,
1639 0xc2, 0xf4, 0x99, 0x66, 0xcc, 0xac, 0xd8, 0xb9,
1640 0x72, 0x2a, 0x4a, 0x3e, 0x0f, 0x7b, 0xbf, 0xf4}},
1641 {{0x8c, 0x9c, 0x78, 0x2b, 0x39, 0x61, 0x7e, 0xf7,
1642 0x65, 0x37, 0x66, 0x09, 0x38, 0xb9, 0x6f, 0x70,
1643 0x78, 0x87, 0xff, 0xcf, 0x93, 0xca, 0x85, 0x06,
1644 0x44, 0x84, 0xa7, 0xfe, 0xd3, 0xa4, 0xe3, 0x7e},
1645 {0xa2, 0x56, 0x49, 0x23, 0x54, 0xa5, 0x50, 0xe9,
1646 0x5f, 0xf0, 0x4d, 0xe7, 0xdc, 0x38, 0x32, 0x79,
1647 0x4f, 0x1c, 0xb7, 0xe4, 0xbb, 0xf8, 0xbb, 0x2e,
1648 0x40, 0x41, 0x4b, 0xcc, 0xe3, 0x1e, 0x16, 0x36}},
1649 {{0x0c, 0x1e, 0xd7, 0x09, 0x25, 0x40, 0x97, 0xcb,
1650 0x5c, 0x46, 0xa8, 0xda, 0xef, 0x25, 0xd5, 0xe5,
1651 0x92, 0x4d, 0xcf, 0xa3, 0xc4, 0x5d, 0x35, 0x4a,
1652 0xe4, 0x61, 0x92, 0xf3, 0xbf, 0x0e, 0xcd, 0xbe},
1653 {0xe4, 0xaf, 0x0a, 0xb3, 0x30, 0x8b, 0x9b, 0x48,
1654 0x49, 0x43, 0xc7, 0x64, 0x60, 0x4a, 0x2b, 0x9e,
1655 0x95, 0x5f, 0x56, 0xe8, 0x35, 0xdc, 0xeb, 0xdc,
1656 0xc7, 0xc4, 0xfe, 0x30, 0x40, 0xc7, 0xbf, 0xa4}},
1657 {{0xd4, 0xa0, 0xf5, 0x81, 0x49, 0x6b, 0xb6, 0x8b,
1658 0x0a, 0x69, 0xf9, 0xfe, 0xa8, 0x32, 0xe5, 0xe0,
1659 0xa5, 0xcd, 0x02, 0x53, 0xf9, 0x2c, 0xe3, 0x53,
1660 0x83, 0x36, 0xc6, 0x02, 0xb5, 0xeb, 0x64, 0xb8},
1661 {0x1d, 0x42, 0xb9, 0xf9, 0xe9, 0xe3, 0x93, 0x2c,
1662 0x4c, 0xee, 0x6c, 0x5a, 0x47, 0x9e, 0x62, 0x01,
1663 0x6b, 0x04, 0xfe, 0xa4, 0x30, 0x2b, 0x0d, 0x4f,
1664 0x71, 0x10, 0xd3, 0x55, 0xca, 0xf3, 0x5e, 0x80}},
1665 {{0x77, 0x05, 0xf6, 0x0c, 0x15, 0x9b, 0x45, 0xe7,
1666 0xb9, 0x11, 0xb8, 0xf5, 0xd6, 0xda, 0x73, 0x0c,
1667 0xda, 0x92, 0xea, 0xd0, 0x9d, 0xd0, 0x18, 0x92,
1668 0xce, 0x9a, 0xaa, 0xee, 0x0f, 0xef, 0xde, 0x30},
1669 {0xf1, 0xf1, 0xd6, 0x9b, 0x51, 0xd7, 0x77, 0x62,
1670 0x52, 0x10, 0xb8, 0x7a, 0x84, 0x9d, 0x15, 0x4e,
1671 0x07, 0xdc, 0x1e, 0x75, 0x0d, 0x0c, 0x3b, 0xdb,
1672 0x74, 0x58, 0x62, 0x02, 0x90, 0x54, 0x8b, 0x43}},
1673 {{0xa6, 0xfe, 0x0b, 0x87, 0x80, 0x43, 0x67, 0x25,
1674 0x57, 0x5d, 0xec, 0x40, 0x50, 0x08, 0xd5, 0x5d,
1675 0x43, 0xd7, 0xe0, 0xaa, 0xe0, 0x13, 0xb6, 0xb0,
1676 0xc0, 0xd4, 0xe5, 0x0d, 0x45, 0x83, 0xd6, 0x13},
1677 {0x40, 0x45, 0x0a, 0x92, 0x31, 0xea, 0x8c, 0x60,
1678 0x8c, 0x1f, 0xd8, 0x76, 0x45, 0xb9, 0x29, 0x00,
1679 0x26, 0x32, 0xd8, 0xa6, 0x96, 0x88, 0xe2, 0xc4,
1680 0x8b, 0xdb, 0x7f, 0x17, 0x87, 0xcc, 0xc8, 0xf2}},
1681 {{0xc2, 0x56, 0xe2, 0xb6, 0x1a, 0x81, 0xe7, 0x31,
1682 0x63, 0x2e, 0xbb, 0x0d, 0x2f, 0x81, 0x67, 0xd4,
1683 0x22, 0xe2, 0x38, 0x02, 0x25, 0x97, 0xc7, 0x88,
1684 0x6e, 0xdf, 0xbe, 0x2a, 0xa5, 0x73, 0x63, 0xaa},
1685 {0x50, 0x45, 0xe2, 0xc3, 0xbd, 0x89, 0xfc, 0x57,
1686 0xbd, 0x3c, 0xa3, 0x98, 0x7e, 0x7f, 0x36, 0x38,
1687 0x92, 0x39, 0x1f, 0x0f, 0x81, 0x1a, 0x06, 0x51,
1688 0x1f, 0x8d, 0x6a, 0xff, 0x47, 0x16, 0x06, 0x9c}},
1689 {{0x33, 0x95, 0xa2, 0x6f, 0x27, 0x5f, 0x9c, 0x9c,
1690 0x64, 0x45, 0xcb, 0xd1, 0x3c, 0xee, 0x5e, 0x5f,
1691 0x48, 0xa6, 0xaf, 0xe3, 0x79, 0xcf, 0xb1, 0xe2,
1692 0xbf, 0x55, 0x0e, 0xa2, 0x3b, 0x62, 0xf0, 0xe4},
1693 {0x14, 0xe8, 0x06, 0xe3, 0xbe, 0x7e, 0x67, 0x01,
1694 0xc5, 0x21, 0x67, 0xd8, 0x54, 0xb5, 0x7f, 0xa4,
1695 0xf9, 0x75, 0x70, 0x1c, 0xfd, 0x79, 0xdb, 0x86,
1696 0xad, 0x37, 0x85, 0x83, 0x56, 0x4e, 0xf0, 0xbf}},
1697 {{0xbc, 0xa6, 0xe0, 0x56, 0x4e, 0xef, 0xfa, 0xf5,
1698 0x1d, 0x5d, 0x3f, 0x2a, 0x5b, 0x19, 0xab, 0x51,
1699 0xc5, 0x8b, 0xdd, 0x98, 0x28, 0x35, 0x2f, 0xc3,
1700 0x81, 0x4f, 0x5c, 0xe5, 0x70, 0xb9, 0xeb, 0x62},
1701 {0xc4, 0x6d, 0x26, 0xb0, 0x17, 0x6b, 0xfe, 0x6c,
1702 0x12, 0xf8, 0xe7, 0xc1, 0xf5, 0x2f, 0xfa, 0x91,
1703 0x13, 0x27, 0xbd, 0x73, 0xcc, 0x33, 0x31, 0x1c,
1704 0x39, 0xe3, 0x27, 0x6a, 0x95, 0xcf, 0xc5, 0xfb}},
1705 {{0x30, 0xb2, 0x99, 0x84, 0xf0, 0x18, 0x2a, 0x6e,
1706 0x1e, 0x27, 0xed, 0xa2, 0x29, 0x99, 0x41, 0x56,
1707 0xe8, 0xd4, 0x0d, 0xef, 0x99, 0x9c, 0xf3, 0x58,
1708 0x29, 0x55, 0x1a, 0xc0, 0x68, 0xd6, 0x74, 0xa4},
1709 {0x07, 0x9c, 0xe7, 0xec, 0xf5, 0x36, 0x73, 0x41,
1710 0xa3, 0x1c, 0xe5, 0x93, 0x97, 0x6a, 0xfd, 0xf7,
1711 0x53, 0x18, 0xab, 0xaf, 0xeb, 0x85, 0xbd, 0x92,
1712 0x90, 0xab, 0x3c, 0xbf, 0x30, 0x82, 0xad, 0xf6}},
1713 {{0xc6, 0x87, 0x8a, 0x2a, 0xea, 0xc0, 0xa9, 0xec,
1714 0x6d, 0xd3, 0xdc, 0x32, 0x23, 0xce, 0x62, 0x19,
1715 0xa4, 0x7e, 0xa8, 0xdd, 0x1c, 0x33, 0xae, 0xd3,
1716 0x4f, 0x62, 0x9f, 0x52, 0xe7, 0x65, 0x46, 0xf4},
1717 {0x97, 0x51, 0x27, 0x67, 0x2d, 0xa2, 0x82, 0x87,
1718 0x98, 0xd3, 0xb6, 0x14, 0x7f, 0x51, 0xd3, 0x9a,
1719 0x0b, 0xd0, 0x76, 0x81, 0xb2, 0x4f, 0x58, 0x92,
1720 0xa4, 0x86, 0xa1, 0xa7, 0x09, 0x1d, 0xef, 0x9b}},
1721 {{0xb3, 0x0f, 0x2b, 0x69, 0x0d, 0x06, 0x90, 0x64,
1722 0xbd, 0x43, 0x4c, 0x10, 0xe8, 0x98, 0x1c, 0xa3,
1723 0xe1, 0x68, 0xe9, 0x79, 0x6c, 0x29, 0x51, 0x3f,
1724 0x41, 0xdc, 0xdf, 0x1f, 0xf3, 0x60, 0xbe, 0x33},
1725 {0xa1, 0x5f, 0xf7, 0x1d, 0xb4, 0x3e, 0x9b, 0x3c,
1726 0xe7, 0xbd, 0xb6, 0x06, 0xd5, 0x60, 0x06, 0x6d,
1727 0x50, 0xd2, 0xf4, 0x1a, 0x31, 0x08, 0xf2, 0xea,
1728 0x8e, 0xef, 0x5f, 0x7d, 0xb6, 0xd0, 0xc0, 0x27}},
1729 {{0x62, 0x9a, 0xd9, 0xbb, 0x38, 0x36, 0xce, 0xf7,
1730 0x5d, 0x2f, 0x13, 0xec, 0xc8, 0x2d, 0x02, 0x8a,
1731 0x2e, 0x72, 0xf0, 0xe5, 0x15, 0x9d, 0x72, 0xae,
1732 0xfc, 0xb3, 0x4f, 0x02, 0xea, 0xe1, 0x09, 0xfe},
1733 {0x00, 0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3d, 0xbc,
1734 0xad, 0x16, 0x0c, 0xb6, 0xe7, 0x7c, 0x8b, 0x39,
1735 0x9a, 0x43, 0xbb, 0xe3, 0xc2, 0x55, 0x15, 0x14,
1736 0x75, 0xac, 0x90, 0x9b, 0x7f, 0x9a, 0x92, 0x00}},
1737 {{0x8b, 0xac, 0x70, 0x86, 0x29, 0x8f, 0x00, 0x23,
1738 0x7b, 0x45, 0x30, 0xaa, 0xb8, 0x4c, 0xc7, 0x8d,
1739 0x4e, 0x47, 0x85, 0xc6, 0x19, 0xe3, 0x96, 0xc2,
1740 0x9a, 0xa0, 0x12, 0xed, 0x6f, 0xd7, 0x76, 0x16},
1741 {0x45, 0xaf, 0x7e, 0x33, 0xc7, 0x7f, 0x10, 0x6c,
1742 0x7c, 0x9f, 0x29, 0xc1, 0xa8, 0x7e, 0x15, 0x84,
1743 0xe7, 0x7d, 0xc0, 0x6d, 0xab, 0x71, 0x5d, 0xd0,
1744 0x6b, 0x9f, 0x97, 0xab, 0xcb, 0x51, 0x0c, 0x9f}},
1745 {{0x9e, 0xc3, 0x92, 0xb4, 0x04, 0x9f, 0xc8, 0xbb,
1746 0xdd, 0x9e, 0xc6, 0x05, 0xfd, 0x65, 0xec, 0x94,
1747 0x7f, 0x2c, 0x16, 0xc4, 0x40, 0xac, 0x63, 0x7b,
1748 0x7d, 0xb8, 0x0c, 0xe4, 0x5b, 0xe3, 0xa7, 0x0e},
1749 {0x43, 0xf4, 0x44, 0xe8, 0xcc, 0xc8, 0xd4, 0x54,
1750 0x33, 0x37, 0x50, 0xf2, 0x87, 0x42, 0x2e, 0x00,
1751 0x49, 0x60, 0x62, 0x02, 0xfd, 0x1a, 0x7c, 0xdb,
1752 0x29, 0x6c, 0x6d, 0x54, 0x53, 0x08, 0xd1, 0xc8}},
1753 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1754 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1755 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1756 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1757 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1758 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1759 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1760 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
1761 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1762 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1763 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1764 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1765 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1766 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1767 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1768 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1769 {{0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1770 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1771 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1772 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92},
1773 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1774 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1775 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1776 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1777 {{0x28, 0x56, 0xac, 0x0e, 0x4f, 0x98, 0x09, 0xf0,
1778 0x49, 0xfa, 0x7f, 0x84, 0xac, 0x7e, 0x50, 0x5b,
1779 0x17, 0x43, 0x14, 0x89, 0x9c, 0x53, 0xa8, 0x94,
1780 0x30, 0xf2, 0x11, 0x4d, 0x92, 0x14, 0x27, 0xe8},
1781 {0x39, 0x7a, 0x84, 0x56, 0x79, 0x9d, 0xec, 0x26,
1782 0x2c, 0x53, 0xc1, 0x94, 0xc9, 0x8d, 0x9e, 0x9d,
1783 0x32, 0x1f, 0xdd, 0x84, 0x04, 0xe8, 0xe2, 0x0a,
1784 0x6b, 0xbe, 0xbb, 0x42, 0x40, 0x67, 0x30, 0x6c}},
1785 {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1786 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1787 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
1788 0x40, 0x2d, 0xa1, 0x73, 0x2f, 0xc9, 0xbe, 0xbd},
1789 {0x27, 0x59, 0xc7, 0x35, 0x60, 0x71, 0xa6, 0xf1,
1790 0x79, 0xa5, 0xfd, 0x79, 0x16, 0xf3, 0x41, 0xf0,
1791 0x57, 0xb4, 0x02, 0x97, 0x32, 0xe7, 0xde, 0x59,
1792 0xe2, 0x2d, 0x9b, 0x11, 0xea, 0x2c, 0x35, 0x92}},
1793 {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1794 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
1795 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
1796 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x40},
1797 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1798 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1799 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1800 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}},
1801 {{0x1c, 0xc4, 0xf7, 0xda, 0x0f, 0x65, 0xca, 0x39,
1802 0x70, 0x52, 0x92, 0x8e, 0xc3, 0xc8, 0x15, 0xea,
1803 0x7f, 0x10, 0x9e, 0x77, 0x4b, 0x6e, 0x2d, 0xdf,
1804 0xe8, 0x30, 0x9d, 0xda, 0xe8, 0x9a, 0x65, 0xae},
1805 {0x02, 0xb0, 0x16, 0xb1, 0x1d, 0xc8, 0x57, 0x7b,
1806 0xa2, 0x3a, 0xa2, 0xa3, 0x38, 0x5c, 0x8f, 0xeb,
1807 0x66, 0x37, 0x91, 0xa8, 0x5f, 0xef, 0x04, 0xf6,
1808 0x59, 0x75, 0xe1, 0xee, 0x92, 0xf6, 0x0e, 0x30}},
1809 {{0x8d, 0x76, 0x14, 0xa4, 0x14, 0x06, 0x9f, 0x9a,
1810 0xdf, 0x4a, 0x85, 0xa7, 0x6b, 0xbf, 0x29, 0x6f,
1811 0xbc, 0x34, 0x87, 0x5d, 0xeb, 0xbb, 0x2e, 0xa9,
1812 0xc9, 0x1f, 0x58, 0xd6, 0x9a, 0x82, 0xa0, 0x56},
1813 {0xd4, 0xb9, 0xdb, 0x88, 0x1d, 0x04, 0xe9, 0x93,
1814 0x8d, 0x3f, 0x20, 0xd5, 0x86, 0xa8, 0x83, 0x07,
1815 0xdb, 0x09, 0xd8, 0x22, 0x1f, 0x7f, 0xf1, 0x71,
1816 0xc8, 0xe7, 0x5d, 0x47, 0xaf, 0x8b, 0x72, 0xe9}},
1817 {{0x83, 0xb9, 0x39, 0xb2, 0xa4, 0xdf, 0x46, 0x87,
1818 0xc2, 0xb8, 0xf1, 0xe6, 0x4c, 0xd1, 0xe2, 0xa9,
1819 0xe4, 0x70, 0x30, 0x34, 0xbc, 0x52, 0x7c, 0x55,
1820 0xa6, 0xec, 0x80, 0xa4, 0xe5, 0xd2, 0xdc, 0x73},
1821 {0x08, 0xf1, 0x03, 0xcf, 0x16, 0x73, 0xe8, 0x7d,
1822 0xb6, 0x7e, 0x9b, 0xc0, 0xb4, 0xc2, 0xa5, 0x86,
1823 0x02, 0x77, 0xd5, 0x27, 0x86, 0xa5, 0x15, 0xfb,
1824 0xae, 0x9b, 0x8c, 0xa9, 0xf9, 0xf8, 0xa8, 0x4a}},
1825 {{0x8b, 0x00, 0x49, 0xdb, 0xfa, 0xf0, 0x1b, 0xa2,
1826 0xed, 0x8a, 0x9a, 0x7a, 0x36, 0x78, 0x4a, 0xc7,
1827 0xf7, 0xad, 0x39, 0xd0, 0x6c, 0x65, 0x7a, 0x41,
1828 0xce, 0xd6, 0xd6, 0x4c, 0x20, 0x21, 0x6b, 0xc7},
1829 {0xc6, 0xca, 0x78, 0x1d, 0x32, 0x6c, 0x6c, 0x06,
1830 0x91, 0xf2, 0x1a, 0xe8, 0x43, 0x16, 0xea, 0x04,
1831 0x3c, 0x1f, 0x07, 0x85, 0xf7, 0x09, 0x22, 0x08,
1832 0xba, 0x13, 0xfd, 0x78, 0x1e, 0x3f, 0x6f, 0x62}},
1833 {{0x25, 0x9b, 0x7c, 0xb0, 0xac, 0x72, 0x6f, 0xb2,
1834 0xe3, 0x53, 0x84, 0x7a, 0x1a, 0x9a, 0x98, 0x9b,
1835 0x44, 0xd3, 0x59, 0xd0, 0x8e, 0x57, 0x41, 0x40,
1836 0x78, 0xa7, 0x30, 0x2f, 0x4c, 0x9c, 0xb9, 0x68},
1837 {0xb7, 0x75, 0x03, 0x63, 0x61, 0xc2, 0x48, 0x6e,
1838 0x12, 0x3d, 0xbf, 0x4b, 0x27, 0xdf, 0xb1, 0x7a,
1839 0xff, 0x4e, 0x31, 0x07, 0x83, 0xf4, 0x62, 0x5b,
1840 0x19, 0xa5, 0xac, 0xa0, 0x32, 0x58, 0x0d, 0xa7}},
1841 {{0x43, 0x4f, 0x10, 0xa4, 0xca, 0xdb, 0x38, 0x67,
1842 0xfa, 0xae, 0x96, 0xb5, 0x6d, 0x97, 0xff, 0x1f,
1843 0xb6, 0x83, 0x43, 0xd3, 0xa0, 0x2d, 0x70, 0x7a,
1844 0x64, 0x05, 0x4c, 0xa7, 0xc1, 0xa5, 0x21, 0x51},
1845 {0xe4, 0xf1, 0x23, 0x84, 0xe1, 0xb5, 0x9d, 0xf2,
1846 0xb8, 0x73, 0x8b, 0x45, 0x2b, 0x35, 0x46, 0x38,
1847 0x10, 0x2b, 0x50, 0xf8, 0x8b, 0x35, 0xcd, 0x34,
1848 0xc8, 0x0e, 0xf6, 0xdb, 0x09, 0x35, 0xf0, 0xda}},
1849 {{0xdb, 0x21, 0x5c, 0x8d, 0x83, 0x1d, 0xb3, 0x34,
1850 0xc7, 0x0e, 0x43, 0xa1, 0x58, 0x79, 0x67, 0x13,
1851 0x1e, 0x86, 0x5d, 0x89, 0x63, 0xe6, 0x0a, 0x46,
1852 0x5c, 0x02, 0x97, 0x1b, 0x62, 0x43, 0x86, 0xf5},
1853 {0xdb, 0x21, 0x5c, 0x8d, 0x83, 0x1d, 0xb3, 0x34,
1854 0xc7, 0x0e, 0x43, 0xa1, 0x58, 0x79, 0x67, 0x13,
1855 0x1e, 0x86, 0x5d, 0x89, 0x63, 0xe6, 0x0a, 0x46,
1856 0x5c, 0x02, 0x97, 0x1b, 0x62, 0x43, 0x86, 0xf5}}
1859 for (i = 0; i < 33; i++) {
1890 unsigned char bin[32];
1900 unsigned char bin[32];
1911 while (--tries >= 0) {
1939 static const unsigned char b32[32] = {
1940 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1941 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
1942 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
1943 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40
1946 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1947 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1950 0x00010203UL, 0x04050607UL, 0x11121314UL, 0x15161718UL,
1951 0x22232425UL, 0x26272829UL, 0x33343536UL, 0x37383940UL
1954 unsigned char b322[32];
1971 t.magnitude = a->magnitude;
1972 t.normalized = a->normalized;
1984 for (i = 0; i < 5*
count; i++) {
1997 CHECK(x.normalized && x.magnitude == 1);
2004 CHECK(!q.normalized && q.magnitude == z.magnitude);
2013 CHECK(q.normalized && q.magnitude == 1);
2015 for (j = 0; j < 6; j++) {
2020 CHECK((q.normalized != (j&1)) && q.magnitude == ((j&1) ? z.magnitude : 1));
2065 for (i = 1; i <= 512; ++i) {
2076 CHECK((v == 0) == (k == NULL));
2097 for (i = 1; i <= 100; i++) {
2106 for (i = 0; i < 10; i++) {
2109 for (j = 0; j <
count; j++) {
2124 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE,
2125 0xBAAEDCE6, 0xAF48A03B, 0xBFD25E8C, 0xD0364140
2129 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
2130 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFC2E
2198 {
SECP256K1_FE_CONST(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffffc2e),
2199 SECP256K1_FE_CONST(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0xfffffc2e)},
2202 SECP256K1_FE_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7ffffe18)},
2205 SECP256K1_FE_CONST(0xbcb223fe, 0xdc24a059, 0xd838091d, 0xd2253530, 0xffffffff, 0xffffffff, 0xffffffff, 0x434dd931)},
2207 {
SECP256K1_FE_CONST(0xe34e9c95, 0x6bee8a84, 0x0dcb632a, 0xdb8a1320, 0x66885408, 0x06f3f996, 0x7c11ca84, 0x19199ec3),
2208 SECP256K1_FE_CONST(0xbd2cbd8f, 0x1c536828, 0x9bccda44, 0x2582ac0c, 0x870152b0, 0x8a3f09fb, 0x1aaadf92, 0x19b618e5)}
2219 {
SECP256K1_SCALAR_CONST(0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0xbaaedce6, 0xaf48a03b, 0xbfd25e8c, 0xd0364140),
2220 SECP256K1_SCALAR_CONST(0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0xbaaedce6, 0xaf48a03b, 0xbfd25e8c, 0xd0364140)},
2223 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x5d576e73, 0x57a4501d, 0xdfe92f46, 0x681b20a1)},
2226 SECP256K1_SCALAR_CONST(0x50a51ac8, 0x34b9ec24, 0x4b0dff66, 0x5588b13e, 0x9984d5b3, 0xcf80ef0f, 0xd6a23766, 0xa3ee9f22)},
2228 {
SECP256K1_SCALAR_CONST(0xcb9f1d35, 0xdd4416c2, 0xcd71bf3f, 0x6365da66, 0x3c9b3376, 0x8feb7ae9, 0x32a5ef60, 0x19199ec3),
2229 SECP256K1_SCALAR_CONST(0x1d7c7bba, 0xf1893d53, 0xb834bd09, 0x36b411dc, 0x42c2e42f, 0xec72c428, 0x5e189791, 0x8e9bc708)}
2231 int i, var, testrand;
2232 unsigned char b32[32];
2235 memset(b32, 0,
sizeof(b32));
2237 for (i = 0; (size_t)i <
sizeof(fe_cases)/
sizeof(fe_cases[0]); ++i) {
2238 for (var = 0; var <= 1; ++var) {
2245 for (i = 0; (size_t)i <
sizeof(scalar_cases)/
sizeof(scalar_cases[0]); ++i) {
2246 for (var = 0; var <= 1; ++var) {
2254 for (i = 0; i < 1000; ++i) {
2256 b32[30] = (i >> 8) & 0xff;
2259 for (var = 0; var <= 1; ++var) {
2265 for (var = 0; var <= 1; ++var) {
2271 for (testrand = 0; testrand <= 1; ++testrand) {
2272 for (i = 0; i < 64 *
count; ++i) {
2276 for (var = 0; var <= 1; ++var) {
2351 for (i = 0; i < runs; i++) {
2355 if (i >= runs - 2) {
2358 if (i >= runs - 1) {
2369 for (j = 0; j < 4; j++) {
2387 for (i1 = 0; i1 < 1 + 4 * runs; i1++) {
2389 for (i2 = 0; i2 < 1 + 4 * runs; i2++) {
2429 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 == ((i2 + 3)%4)/2)) {
2446 if ((i1 == 0 && i2 == 0) || ((i1 + 3)/4 == (i2 + 3)/4 && ((i1 + 3)%4)/2 != ((i2 + 3)%4)/2)) {
2468 for (i = 0; i < 4 * runs + 1; i++) {
2469 gej_shuffled[i] = gej[i];
2471 for (i = 0; i < 4 * runs + 1; i++) {
2475 gej_shuffled[i] = gej_shuffled[swap];
2476 gej_shuffled[swap] = t;
2479 for (i = 0; i < 4 * runs + 1; i++) {
2490 for (i = 0; i < 4 * runs + 1; i++) {
2500 for (i = 0; i < 4 * runs + 1; i++) {
2511 for (i = 0; i < 4 * runs + 1; i++) {
2584 0x8d24cd95, 0x0a355af1, 0x3c543505, 0x44238d30,
2585 0x0643d79f, 0x05a59614, 0x2f8ec030, 0xd58977cb,
2586 0x001e337a, 0x38093dcd, 0x6c0f386d, 0x0b1293a8,
2587 0x4d72c879, 0xd7681924, 0x44e6d2f3, 0x9190117d
2590 0xc7b74206, 0x1f788cd9, 0xabd0937d, 0x164a0d86,
2591 0x95f6ff75, 0xf19a4ce9, 0xd013bd7b, 0xbf92d2a7,
2592 0xffe1cc85, 0xc7f6c232, 0x93f0c792, 0xf4ed6c57,
2593 0xb28d3786, 0x2897e6db, 0xbb192d0b, 0x6e6feab2
2596 0x671a63c0, 0x3efdad4c, 0x389a7798, 0x24356027,
2597 0xb3d69010, 0x278625c3, 0x5c86d390, 0x184a8f7a,
2598 0x5f6409c2, 0x2ce01f2b, 0x511fd375, 0x25071d08,
2599 0xda651801, 0x70e95caf, 0x8f0d893c, 0xbed8fbbe
2621 for (i = 0; i <
count * 32; i++) {
2637 for (i = 1; i <= 6; i++) {
2644 d[i - 1] = &data[i - 1];
2655 for (i = 0; i <
count * 8; i++) {
2668 int res_quad, res_even, res_odd;
2676 CHECK(res_quad == res_even);
2677 CHECK(res_quad == res_odd);
2726 for (i = 0; i <
count * 4; i++) {
2738 0x8b30bbe9, 0xae2a9906, 0x96b22f67, 0x0709dff3,
2739 0x727fd8bc, 0x04d3362c, 0x6c7bf458, 0xe2846004,
2740 0xa357ae91, 0x5c4a6528, 0x1309edf2, 0x0504740f,
2741 0x0eb33439, 0x90216b4f, 0x81063cb6, 0x5f2f7e0f
2745 0x84cc5452, 0xf7fde1ed, 0xb4d38a8c, 0xe9b1b84c,
2746 0xcef31f14, 0x6e569be9, 0x705d357a, 0x42985407
2749 0xa1e58d22, 0x553dcd42, 0xb2398062, 0x5d4c57a9,
2750 0x6e9323d4, 0x2b3152e5, 0xca2c3990, 0xedc7c9de
2765 for (i = 0; i < 200*
count; i++) {
2781 0xD6E96687, 0xF9B10D09, 0x2A6F3543, 0x9D86CEBE,
2782 0xA4535D0D, 0x409F5358, 0x6440BD74, 0xB933E830,
2783 0xB95CBCA2, 0xC77DA786, 0x539BE8FD, 0x53354D2D,
2784 0x3B4F566A, 0xE6580454, 0x07ED6015, 0xEE1B2A88
2807 unsigned char pub[65];
2841 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fc),
2842 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fd),
2843 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6fe),
2844 SECP256K1_SCALAR_CONST(0xd938a566, 0x7f479e3e, 0xb5b3c7fa, 0xefdb3749, 0x3aa0585c, 0xc5ea2367, 0xe1b660db, 0x0209e6ff),
2845 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632d),
2846 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632e),
2847 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf7632f),
2848 SECP256K1_SCALAR_CONST(0x2c9c52b3, 0x3fa3cf1f, 0x5ad9e3fd, 0x77ed9ba5, 0xb294b893, 0x3722e9a5, 0x00e698ca, 0x4cf76330),
2849 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b209f),
2850 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a0),
2851 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a1),
2852 SECP256K1_SCALAR_CONST(0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xd576e735, 0x57a4501d, 0xdfe92f46, 0x681b20a2),
2853 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede11),
2854 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede12),
2855 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede13),
2856 SECP256K1_SCALAR_CONST(0xd363ad4c, 0xc05c30e0, 0xa5261c02, 0x88126459, 0xf85915d7, 0x7825b696, 0xbeebc5c2, 0x833ede14),
2857 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a42),
2858 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a43),
2859 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a44),
2860 SECP256K1_SCALAR_CONST(0x26c75a99, 0x80b861c1, 0x4a4c3805, 0x1024c8b4, 0x704d760e, 0xe95e7cd3, 0xde1bfdb1, 0xce2c5a45)
2886 }
else if (mode == 1) {
2905 for (i = 0; i < 4*
count; ++i) {
2918 0x7603CB59, 0xB0EF6C63, 0xFE608479, 0x2A0C378C,
2919 0xDB3233A8, 0x0F8A9A09, 0xA877DEAD, 0x31B38C45
2921 for (i = 0; i < 500; i++) {
2938 0x6d986544, 0x57ff52b8, 0xcf1b8126, 0x5b802a5b,
2939 0xa97f9263, 0xb1e88044, 0x93351325, 0x91bc450a,
2940 0x535c59f7, 0x325e5d2b, 0xc391fbe8, 0x3c12787c,
2941 0x337e4a98, 0xe82a9011, 0x0123ba37, 0xdd769c7d
2945 0x649d4f77, 0xc4242df7, 0x7f2079c9, 0x14530327,
2946 0xa31b876a, 0xd2d8ce2a, 0x2236d5c6, 0xd7b2029b
2950 0x23773684, 0x4d209dc7, 0x098a786f, 0x20d06fcd,
2951 0x070a38bf, 0xc11ac651, 0x03004319, 0x1e2a8786,
2952 0xed8c3b8e, 0xc06dd57b, 0xd06ea66e, 0x45492b0f,
2953 0xb84e4e1b, 0xfb77e21f, 0x96baae2a, 0x63dec956
3008 0x4968d524, 0x2abf9b7a, 0x466abbcf, 0x34b11b6d,
3009 0xcd83d307, 0x827bed62, 0x05fad0ce, 0x18fae63b
3012 0x5494c15d, 0x32099706, 0xc2395f94, 0x348745fd,
3013 0x757ce30e, 0x4e8c90fb, 0xa2bad184, 0xf883c69f,
3014 0x5d195d20, 0xe191bf7f, 0x1be3e55f, 0x56a80196,
3015 0x6071ad01, 0xf1462f66, 0xc997fa94, 0xdb858435
3022 for (i = 0; i < 100; ++i) {
3045 *sc = data->
sc[idx];
3046 *pt = data->
pt[idx];
3075 for (ncount = 0; ncount <
count; ncount++) {
3119 for (ncount = 0; ncount <
count; ncount++) {
3122 size_t sizes[] = { 2, 10, 32 };
3124 for (j = 0; j < 3; j++) {
3125 for (i = 0; i < 32; i++) {
3133 for (j = 0; j < 3; j++) {
3134 for (i = 0; i < 32; i++) {
3143 for (j = 0; j < 3; j++) {
3145 for (i = 0; i < 16; i++) {
3149 pt[2 * i + 1] = ptg;
3156 for (i = 0; i < 16; i++) {
3172 for (i = 1; i < 32; i++) {
3185 for (ncount = 0; ncount <
count; ncount++) {
3190 for (i = 0; i < 20; i++) {
3206 for (ncount = 0; ncount <
count; ncount++) {
3214 for (i = 0; i < 20; i++) {
3229 for (ncount = 0; ncount < 20; ncount++) {
3245 const size_t TOP = 8;
3254 for(t0i = 0; t0i < TOP; t0i++) {
3255 for(t1i = 0; t1i < TOP; t1i++) {
3267 for(s0i = 0; s0i < TOP; s0i++) {
3268 for(s1i = 0; s1i < TOP; s1i++) {
3340 size_t n_points_supported;
3341 int bucket_window = 0;
3343 for(; scratch_size < max_size; scratch_size+=256) {
3348 CHECK(scratch != NULL);
3351 if (n_points_supported == 0) {
3370 size_t n_batches, n_batch_points, max_n_batch_points, n;
3372 max_n_batch_points = 0;
3376 max_n_batch_points = 1;
3379 CHECK(n_batches == 0);
3380 CHECK(n_batch_points == 0);
3382 max_n_batch_points = 2;
3385 CHECK(n_batches == 3);
3386 CHECK(n_batch_points == 2);
3391 CHECK(n_batches == 1);
3397 CHECK(n_batches == 2);
3400 max_n_batch_points = 1;
3403 CHECK(n_batches == SIZE_MAX);
3404 CHECK(n_batch_points == 1);
3406 max_n_batch_points = 2;
3409 CHECK(n_batches == SIZE_MAX/2 + 1);
3410 CHECK(n_batch_points == 2);
3435 for(i = 0; i < n_points; i++) {
3466 for(i = 1; i <= n_points; i++) {
3517 for (i = bits-1; i >= 0; i--) {
3521 CHECK(zeroes == -1 || zeroes >= w-1);
3523 CHECK((v & 1) == 1);
3524 CHECK(v <= (1 << (w-1)) - 1);
3525 CHECK(v >= -(1 << (w-1)) - 1);
3527 CHECK(zeroes != -1);
3552 CHECK(sign1 == sign2);
3558 int wnaf[256] = {0};
3567 for (i = 0; i < 16; ++i) {
3578 CHECK(v > -(1 << w));
3579 CHECK(v < (1 << w));
3598 int wnaf[256] = {0};
3605 for (i = 0; i < 16; ++i) {
3613 CHECK(v == 0 || v & 1);
3614 CHECK(v > -(1 << w));
3615 CHECK(v < (1 << w));
3636 CHECK(wnaf[i] == 0);
3638 for (i = 7; i >= 0; --i) {
3639 CHECK(wnaf[i] == wnaf_expected[i]);
3645 int wnaf[256] = {0};
3664 CHECK(wnaf[0] == 1);
3668 int wnaf_expected[8] = { 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf };
3675 int wnaf_expected[8] = { -1, -1, -1, -1, -1, -1, -1, 0xf };
3682 int wnaf_expected[8] = { 1, 0, 1, 0, 1, 0, 1, 0 };
3689 int wnaf_expected[8] = { -0xf, 0, 0xf, -0xf, 0, 0xf, 1, 0 };
3729 for (i = 0; i <
count; i++) {
3751 for (i = 0; i < 36; i++ ) {
3754 for (j = 0; j < i; j++) {
3762 for (i = 1; i <= 36; i++ ) {
3766 for (j = 0; j < i; j++) {
3784 unsigned char seed32[32];
3818 for (i = 0; i < 10; i++) {
3826 const unsigned char zero[32] = {0};
3827 unsigned char tmp[32];
3862 for (i = 0; i < 100U *
count; ++i) {
3873 unsigned char pubkeyc[65];
3880 for (pubkeyclen = 3; pubkeyclen <= 65; pubkeyclen++) {
3883 memcpy(&pubkeyc[1], input, 64);
3884 VG_UNDEF(&pubkeyc[pubkeyclen], 65 - pubkeyclen);
3885 for (i = 0; i < 256; i++) {
3892 ysign = (input[63] & 1) + 2;
3894 xpass = xvalid && (pubkeyclen == 33) && ((i & 254) == 2);
3896 ypass = xvalid && yvalid && ((i & 4) == ((pubkeyclen == 65) << 2)) &&
3897 ((i == 4) || ((i & 251) == ysign)) && ((pubkeyclen == 33) || (pubkeyclen == 65));
3898 if (xpass || ypass) {
3900 unsigned char pubkeyo[65];
3902 memset(&pubkey, 0,
sizeof(pubkey));
3913 CHECK((pubkeyclen != 33) || (pubkeyo[0] == pubkeyc[0]));
3916 CHECK(pubkeyo[0] == ysign);
3918 memset(&pubkey, 0,
sizeof(pubkey));
3927 CHECK(pubkeyo[0] == 4);
3933 memset(&pubkey, 0xfe,
sizeof(pubkey));
3948#define SECP256K1_EC_PARSE_TEST_NVALID (12)
3952 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x52,
3953 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3954 0x00, 0x00, 0x64, 0xef, 0xa1, 0x7b, 0x77, 0x61, 0xe1, 0xe4, 0x27, 0x06, 0x98, 0x9f, 0xb4, 0x83,
3955 0xb8, 0xd2, 0xd4, 0x9b, 0xf7, 0x8f, 0xae, 0x98, 0x03, 0xf0, 0x99, 0xb8, 0x34, 0xed, 0xeb, 0x00
3959 0x7a, 0xe9, 0x6a, 0x2b, 0x65, 0x7c, 0x07, 0x10, 0x6e, 0x64, 0x47, 0x9e, 0xac, 0x34, 0x34, 0xe9,
3960 0x9c, 0xf0, 0x49, 0x75, 0x12, 0xf5, 0x89, 0x95, 0xc1, 0x39, 0x6c, 0x28, 0x71, 0x95, 0x01, 0xee,
3961 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
3962 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
3966 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3967 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
3968 0x0e, 0x99, 0x4b, 0x14, 0xea, 0x72, 0xf8, 0xc3, 0xeb, 0x95, 0xc7, 0x1e, 0xf6, 0x92, 0x57, 0x5e,
3969 0x77, 0x50, 0x58, 0x33, 0x2d, 0x7e, 0x52, 0xd0, 0x99, 0x5c, 0xf8, 0x03, 0x88, 0x71, 0xb6, 0x7d,
3973 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3974 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2c,
3975 0xf1, 0x66, 0xb4, 0xeb, 0x15, 0x8d, 0x07, 0x3c, 0x14, 0x6a, 0x38, 0xe1, 0x09, 0x6d, 0xa8, 0xa1,
3976 0x88, 0xaf, 0xa7, 0xcc, 0xd2, 0x81, 0xad, 0x2f, 0x66, 0xa3, 0x07, 0xfb, 0x77, 0x8e, 0x45, 0xb2,
3980 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3981 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3982 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
3983 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
3987 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3988 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
3989 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
3990 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
3994 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
3995 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
3996 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
3997 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
4001 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
4002 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
4003 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4004 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
4008 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
4009 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
4010 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4011 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
4015 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
4016 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
4017 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4018 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
4022 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
4023 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
4024 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4025 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
4029 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
4030 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
4031 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4032 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
4035#define SECP256K1_EC_PARSE_TEST_NXVALID (4)
4039 0x1f, 0xe1, 0xe5, 0xef, 0x3f, 0xce, 0xb5, 0xc1, 0x35, 0xab, 0x77, 0x41, 0x33, 0x3c, 0xe5, 0xa6,
4040 0xe8, 0x0d, 0x68, 0x16, 0x76, 0x53, 0xf6, 0xb2, 0xb2, 0x4b, 0xcb, 0xcf, 0xaa, 0xaf, 0xf5, 0x07,
4041 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4042 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
4046 0xcb, 0xb0, 0xde, 0xab, 0x12, 0x57, 0x54, 0xf1, 0xfd, 0xb2, 0x03, 0x8b, 0x04, 0x34, 0xed, 0x9c,
4047 0xb3, 0xfb, 0x53, 0xab, 0x73, 0x53, 0x91, 0x12, 0x99, 0x94, 0xa5, 0x35, 0xd9, 0x25, 0xf6, 0x73,
4048 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4049 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
4053 0x14, 0x6d, 0x3b, 0x65, 0xad, 0xd9, 0xf5, 0x4c, 0xcc, 0xa2, 0x85, 0x33, 0xc8, 0x8e, 0x2c, 0xbc,
4054 0x63, 0xf7, 0x44, 0x3e, 0x16, 0x58, 0x78, 0x3a, 0xb4, 0x1f, 0x8e, 0xf9, 0x7c, 0x2a, 0x10, 0xb5,
4055 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4056 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
4060 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4061 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
4062 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4063 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03
4066#define SECP256K1_EC_PARSE_TEST_NINVALID (7)
4070 0x0a, 0x2d, 0x2b, 0xa9, 0x35, 0x07, 0xf1, 0xdf, 0x23, 0x37, 0x70, 0xc2, 0xa7, 0x97, 0x96, 0x2c,
4071 0xc6, 0x1f, 0x6d, 0x15, 0xda, 0x14, 0xec, 0xd4, 0x7d, 0x8d, 0x27, 0xae, 0x1c, 0xd5, 0xf8, 0x53,
4072 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4073 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
4077 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4078 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
4079 0x42, 0x18, 0xf2, 0x0a, 0xe6, 0xc6, 0x46, 0xb3, 0x63, 0xdb, 0x68, 0x60, 0x58, 0x22, 0xfb, 0x14,
4080 0x26, 0x4c, 0xa8, 0xd2, 0x58, 0x7f, 0xdd, 0x6f, 0xbc, 0x75, 0x0d, 0x58, 0x7e, 0x76, 0xa7, 0xee,
4084 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4085 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x30,
4086 0xbd, 0xe7, 0x0d, 0xf5, 0x19, 0x39, 0xb9, 0x4c, 0x9c, 0x24, 0x97, 0x9f, 0xa7, 0xdd, 0x04, 0xeb,
4087 0xd9, 0xb3, 0x57, 0x2d, 0xa7, 0x80, 0x22, 0x90, 0x43, 0x8a, 0xf2, 0xa6, 0x81, 0x89, 0x54, 0x41,
4091 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4092 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
4093 0xf4, 0x84, 0x14, 0x5c, 0xb0, 0x14, 0x9b, 0x82, 0x5d, 0xff, 0x41, 0x2f, 0xa0, 0x52, 0xa8, 0x3f,
4094 0xcb, 0x72, 0xdb, 0x61, 0xd5, 0x6f, 0x37, 0x70, 0xce, 0x06, 0x6b, 0x73, 0x49, 0xa2, 0xaa, 0x28,
4098 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4099 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xfc, 0x2e,
4100 0x0b, 0x7b, 0xeb, 0xa3, 0x4f, 0xeb, 0x64, 0x7d, 0xa2, 0x00, 0xbe, 0xd0, 0x5f, 0xad, 0x57, 0xc0,
4101 0x34, 0x8d, 0x24, 0x9e, 0x2a, 0x90, 0xc8, 0x8f, 0x31, 0xf9, 0x94, 0x8b, 0xb6, 0x5d, 0x52, 0x07,
4105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4107 0x8f, 0x53, 0x7e, 0xef, 0xdf, 0xc1, 0x60, 0x6a, 0x07, 0x27, 0xcd, 0x69, 0xb4, 0xa7, 0x33, 0x3d,
4108 0x38, 0xed, 0x44, 0xe3, 0x93, 0x2a, 0x71, 0x79, 0xee, 0xcb, 0x4b, 0x6f, 0xba, 0x93, 0x60, 0xdc,
4112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4114 0x70, 0xac, 0x81, 0x10, 0x20, 0x3e, 0x9f, 0x95, 0xf8, 0xd8, 0x32, 0x96, 0x4b, 0x58, 0xcc, 0xc2,
4115 0xc7, 0x12, 0xbb, 0x1c, 0x6c, 0xd5, 0x8e, 0x86, 0x11, 0x34, 0xb4, 0x8f, 0x45, 0x6c, 0x9b, 0x53
4118 const unsigned char pubkeyc[66] = {
4120 0x04, 0x79, 0xBE, 0x66, 0x7E, 0xF9, 0xDC, 0xBB, 0xAC, 0x55, 0xA0, 0x62, 0x95, 0xCE, 0x87, 0x0B,
4121 0x07, 0x02, 0x9B, 0xFC, 0xDB, 0x2D, 0xCE, 0x28, 0xD9, 0x59, 0xF2, 0x81, 0x5B, 0x16, 0xF8, 0x17,
4122 0x98, 0x48, 0x3A, 0xDA, 0x77, 0x26, 0xA3, 0xC4, 0x65, 0x5D, 0xA4, 0xFB, 0xFC, 0x0E, 0x11, 0x08,
4123 0xA8, 0xFD, 0x17, 0xB4, 0x48, 0xA6, 0x85, 0x54, 0x19, 0x9C, 0x47, 0xD0, 0x8F, 0xFB, 0x10, 0xD4,
4126 unsigned char sout[65];
4127 unsigned char shortkey[2];
4139 memset(&pubkey, 0xfe,
sizeof(pubkey));
4149 for (i = 0; i < 256 ; i++) {
4150 memset(&pubkey, 0xfe,
sizeof(pubkey));
4162 for (i = 0; i < 65536 ; i++) {
4163 memset(&pubkey, 0xfe,
sizeof(pubkey));
4165 shortkey[0] = i & 255;
4166 shortkey[1] = i >> 8;
4174 memset(&pubkey, 0xfe,
sizeof(pubkey));
4187 memset(&pubkey, 0xfe,
sizeof(pubkey));
4196 memset(&pubkey, 0xfe,
sizeof(pubkey));
4205 memset(&pubkey, 0xfe,
sizeof(pubkey));
4214 memset(&pubkey, 0,
sizeof(pubkey));
4261 CHECK(ecount2 == 10);
4276 const unsigned char orderc[32] = {
4277 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4278 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
4279 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
4280 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41
4283 unsigned char ctmp[33];
4284 unsigned char ctmp2[33];
4299 memset(ctmp, 255, 32);
4301 memset(&pubkey, 1,
sizeof(pubkey));
4307 memset(ctmp, 0, 32);
4309 memset(&pubkey, 1,
sizeof(pubkey));
4317 memset(&pubkey, 0,
sizeof(pubkey));
4322 pubkey_one = pubkey;
4324 memcpy(ctmp, orderc, 32);
4327 memset(&pubkey, 1,
sizeof(pubkey));
4335 memset(&pubkey, 0,
sizeof(pubkey));
4340 pubkey_negone = pubkey;
4342 memset(ctmp2, 0, 32);
4345 memcpy(&pubkey2, &pubkey,
sizeof(pubkey));
4353 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4356 memcpy(ctmp, orderc, 32);
4357 memset(ctmp2, 0, 32);
4363 memcpy(ctmp, orderc, 32);
4368 memcpy(ctmp, orderc, 32);
4372 memcpy(ctmp, orderc, 32);
4376 memcpy(ctmp, orderc, 32);
4382 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4385 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4389 memcpy(ctmp, orderc, 32);
4391 memset(ctmp2, 0, 32);
4398 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4418 memset(&pubkey, 0, 32);
4422 memcpy(&pubkey, &pubkey2,
sizeof(pubkey));
4423 memset(&pubkey2, 0, 32);
4434 memset(ctmp2, 0, 32);
4441 memset(ctmp2, 0, 32);
4448 memset(ctmp2, 0, 32);
4454 memset(ctmp2, 0, 32);
4463 memset(&pubkey, 1,
sizeof(pubkey));
4469 pubkeys[0] = &pubkey_one;
4488 pubkeys[0] = &pubkey_negone;
4500 pubkeys[0] = &pubkey_one;
4501 pubkeys[1] = &pubkey_negone;
4509 pubkeys[2] = &pubkey_one;
4521 pubkeys[1] = &pubkey_one;
4532 unsigned char seckey[32];
4533 unsigned char seckey_tmp[32];
4536 memcpy(seckey_tmp, seckey, 32);
4550 memset(seckey, 0, 32);
4551 memset(seckey_tmp, 0, 32);
4560 memset(seckey, 0xFF, 16);
4561 memset(seckey_tmp, 0, 32);
4590 CHECK(recid >= 0 && recid < 4);
4602 for (i = 0; i < 10*
count; i++) {
4608static int precomputed_nonce_function(
unsigned char *nonce32,
const unsigned char *msg32,
const unsigned char *key32,
const unsigned char *algo16,
void *data,
unsigned int counter) {
4612 memcpy(nonce32, data, 32);
4613 return (counter == 0);
4616static 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) {
4624static 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) {
4627 memset(nonce32, counter==0 ? 0 : 255, 32);
4634 static const unsigned char order[] = {
4635 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
4636 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
4637 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
4638 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x41
4640 memcpy(nonce32, order, 32);
4660 unsigned char extra[32] = {0x00};
4661 unsigned char privkey[32];
4662 unsigned char message[32];
4663 unsigned char privkey2[32];
4666 unsigned char sig[74];
4668 unsigned char pubkeyc[65];
4669 size_t pubkeyclen = 65;
4672 unsigned char seckey[300];
4673 size_t seckeylen = 300;
4690 memset(&pubkey, 0,
sizeof(pubkey));
4694 memcpy(&pubkey_tmp, &pubkey,
sizeof(pubkey));
4710 unsigned char rnd[32];
4711 unsigned char privkey_tmp[32];
4714 memcpy(privkey_tmp, privkey, 32);
4719 CHECK(ret1 == ret2);
4720 CHECK(ret2 == ret3);
4734 unsigned char rnd[32];
4735 unsigned char privkey_tmp[32];
4738 memcpy(privkey_tmp, privkey, 32);
4743 CHECK(ret1 == ret2);
4744 CHECK(ret2 == ret3);
4793 memset(&signature[0], 0,
sizeof(signature[0]));
4807 unsigned char in[65];
4828 unsigned char out[65];
4829 unsigned char firstb;
4838 if ((in[0] != 6) && (in[0] != 7)) {
4839 CHECK(in[0] == out[0]);
4849 if (firstb == 2 || firstb == 3) {
4850 if (in[0] == firstb + 4) {
4865 unsigned char pk1_ser[33] = {
4867 0x58, 0x84, 0xb3, 0xa2, 0x4b, 0x97, 0x37, 0x88, 0x92, 0x38, 0xa6, 0x26, 0x62, 0x52, 0x35, 0x11,
4868 0xd0, 0x9a, 0xa1, 0x1b, 0x80, 0x0b, 0x5e, 0x93, 0x80, 0x26, 0x11, 0xef, 0x67, 0x4b, 0xd9, 0x23
4870 const unsigned char pk2_ser[33] = {
4872 0xde, 0x36, 0x0e, 0x87, 0x59, 0x8f, 0x3c, 0x01, 0x36, 0x2a, 0x2a, 0xb8, 0xc6, 0xf4, 0x5e, 0x4d,
4873 0xb2, 0xc2, 0xd5, 0x03, 0xa7, 0xf9, 0xf1, 0x4f, 0xa8, 0xfa, 0x95, 0xa8, 0xe9, 0x69, 0x76, 0x1c
4894 memset(&pk_tmp, 0,
sizeof(pk_tmp));
4915 for (i = 0; i < 10*
count; i++) {
4922 for (i = 0; i < 64*
count; i++) {
4928 static const unsigned char zeroes[32] = {0};
4933 unsigned char roundtrip_der[2048];
4934 unsigned char compact_der[64];
4935 size_t len_der = 2048;
4936 int parsed_der = 0, valid_der = 0, roundtrips_der = 0;
4939 unsigned char roundtrip_der_lax[2048];
4940 unsigned char compact_der_lax[64];
4941 size_t len_der_lax = 2048;
4942 int parsed_der_lax = 0, valid_der_lax = 0, roundtrips_der_lax = 0;
4955 if (parsed_der_lax) {
4959 if (valid_der_lax) {
4964 if (certainly_der) {
4965 ret |= (!parsed_der) << 2;
4967 if (certainly_not_der) {
4968 ret |= (parsed_der) << 17;
4971 ret |= (!roundtrips_der) << 3;
4975 ret |= (!roundtrips_der_lax) << 12;
4976 ret |= (len_der != len_der_lax) << 13;
4977 ret |= ((len_der != len_der_lax) || (
secp256k1_memcmp_var(roundtrip_der_lax, roundtrip_der, len_der) != 0)) << 14;
4979 ret |= (roundtrips_der != roundtrips_der_lax) << 15;
4981 ret |= (!parsed_der_lax) << 16;
4989 for (i = 0; i < ptrlen; i++) {
4990 int shift = ptrlen - 1 - i;
4994 ptr[i] = (val >> shift) & 0xFF;
5002 if (action < 1 && *len > 3) {
5005 memmove(
sig + pos,
sig + pos + 1, *len - pos - 1);
5008 }
else if (action < 2 && *len < 2048) {
5011 memmove(
sig + pos + 1,
sig + pos, *len - pos);
5015 }
else if (action < 4) {
5028 int nlow[2], nlen[2], nlenlen[2], nhbit[2], nhbyte[2], nzlen[2];
5029 size_t tlen, elen, glen;
5035 *certainly_der = der;
5036 *certainly_not_der = 0;
5039 for (n = 0; n < 2; n++) {
5044 CHECK(nlen[n] <= 232);
5051 if (nzlen[n] > ((nlen[n] == 0 || nhbit[n]) ? 1 : 0)) {
5052 *certainly_not_der = 1;
5054 CHECK(nlen[n] + nzlen[n] <= 300);
5056 nlenlen[n] = nlen[n] + nzlen[n] < 128 ? 0 : (nlen[n] + nzlen[n] < 256 ? 1 : 2);
5062 *certainly_not_der = 1;
5065 CHECK(nlen[n] + nzlen[n] + nlenlen[n] <= 427);
5069 tlen = 2 + nlenlen[0] + nlen[0] + nzlen[0] + 2 + nlenlen[1] + nlen[1] + nzlen[1];
5075 *certainly_not_der = 1;
5083 *certainly_not_der = 1;
5085 CHECK(tlen + glen <= 990);
5088 sig[(*len)++] = 0x30;
5091 sig[(*len)++] = 0x80;
5092 *certainly_not_der = 1;
5094 int tlenlen = tlen < 128 ? 0 : (tlen < 256 ? 1 : 2);
5099 *certainly_not_der = 1;
5104 sig[(*len)++] = tlen;
5107 sig[(*len)++] = 128 + tlenlen;
5114 CHECK(tlen + glen <= 1119);
5116 for (n = 0; n < 2; n++) {
5118 sig[(*len)++] = 0x02;
5119 if (nlenlen[n] == 0) {
5121 sig[(*len)++] = nlen[n] + nzlen[n];
5124 sig[(*len)++] = 128 + nlenlen[n];
5129 while (nzlen[n] > 0) {
5130 sig[(*len)++] = 0x00;
5133 if (nlen[n] == 32 && !nlow[n]) {
5136 for (i = 0; i < 16; i++) {
5137 sig[(*len)++] = 0xFF;
5143 sig[(*len)++] = nhbyte[n];
5162 CHECK(tlen + glen <= 1121);
5168 CHECK(tlen <= 1121);
5169 CHECK(tlen == *len);
5174 for (i = 0; i < 200 *
count; i++) {
5175 unsigned char buffer[2048];
5177 int certainly_der = 0;
5178 int certainly_not_der = 0;
5180 CHECK(buflen <= 2048);
5181 for (j = 0; j < 16; j++) {
5187 certainly_not_der = 0;
5192 fprintf(stderr,
"Failure %x on ", ret);
5193 for (k = 0; k < buflen; k++) {
5194 fprintf(stderr,
"%02x ", buffer[k]);
5196 fprintf(stderr,
"\n");
5226 const unsigned char pubkey_mods_zero[33] = {
5227 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5228 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5229 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
5230 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
5245 const unsigned char pubkey[33] = {
5246 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5264 const unsigned char pubkey[33] = {
5265 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5271 const unsigned char pubkey2[33] = {
5272 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5273 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5274 0xfe, 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0,
5275 0x3b, 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41,
5299 const unsigned char pubkey[33] = {
5300 0x02, 0x14, 0x4e, 0x5a, 0x58, 0xef, 0x5b, 0x22,
5301 0x6f, 0xd2, 0xe2, 0x07, 0x6a, 0x77, 0xcf, 0x05,
5302 0xb4, 0x1d, 0xe7, 0x4a, 0x30, 0x98, 0x27, 0x8c,
5303 0x93, 0xe6, 0xe6, 0x3c, 0x0b, 0xc4, 0x73, 0x76,
5306 const unsigned char pubkey2[33] = {
5307 0x02, 0x8a, 0xd5, 0x37, 0xed, 0x73, 0xd9, 0x40,
5308 0x1d, 0xa0, 0x33, 0xd2, 0xdc, 0xf0, 0xaf, 0xae,
5309 0x34, 0xcf, 0x5f, 0x96, 0x4c, 0x73, 0x28, 0x0f,
5310 0x92, 0xc0, 0xf6, 0x9d, 0xd9, 0xb2, 0x09, 0x10,
5313 const unsigned char csr[32] = {
5314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5316 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
5317 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xeb
5341 const unsigned char pubkey[33] = {
5342 0x03, 0xaf, 0x97, 0xff, 0x7d, 0x3a, 0xf6, 0xa0,
5343 0x02, 0x94, 0xbd, 0x9f, 0x4b, 0x2e, 0xd7, 0x52,
5344 0x28, 0xdb, 0x49, 0x2a, 0x65, 0xcb, 0x1e, 0x27,
5345 0x57, 0x9c, 0xba, 0x74, 0x20, 0xd5, 0x1d, 0x20,
5348 const unsigned char csr[32] = {
5349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5351 0x45, 0x51, 0x23, 0x19, 0x50, 0xb7, 0x5f, 0xc4,
5352 0x40, 0x2d, 0xa1, 0x72, 0x2f, 0xc9, 0xba, 0xee
5375 unsigned char signature[72];
5376 static const unsigned char nonce[32] = {
5377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5378 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5382 static const unsigned char nonce2[32] = {
5383 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
5384 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
5385 0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,
5386 0xBF,0xD2,0x5E,0x8C,0xD0,0x36,0x41,0x40
5388 const unsigned char key[32] = {
5389 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5390 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
5394 unsigned char msg[32] = {
5395 0x86, 0x41, 0x99, 0x81, 0x06, 0x23, 0x44, 0x53,
5396 0xaa, 0x5f, 0x9d, 0x6a, 0x31, 0x78, 0xf4, 0xf7,
5397 0xb8, 0x12, 0xe0, 0x0b, 0x81, 0x7a, 0x77, 0x62,
5398 0x65, 0xdf, 0xdd, 0x31, 0xb9, 0x3e, 0x29, 0xa9,
5432 CHECK(ecount == 10);
5434 CHECK(ecount == 11);
5436 CHECK(ecount == 11);
5438 CHECK(ecount == 12);
5440 CHECK(ecount == 13);
5442 CHECK(ecount == 13);
5446 CHECK(ecount == 13);
5462 memset(signature, 255, 64);
5469 for (t = 0; t < 2; t++) {
5470 static const unsigned char zero[32] = {0x00};
5472 unsigned char key[32];
5473 unsigned char msg[32];
5476 const unsigned char *extra;
5477 extra = t == 0 ? NULL : zero;
5481 memset(key, 0xFF, 32);
5503 for(i = 0; i < 256; i++) {
5509 for (j = 0; j < i; j++) {
5516 for(i = 256; i < 512; i++) {
5522 for (j = 0; j < i; j++) {
5531 const unsigned char zeros[32] = {0};
5532 unsigned char nonce[32];
5533 unsigned char nonce2[32];
5534 unsigned char nonce3[32];
5535 unsigned char nonce4[32];
5559 unsigned char privkey[300];
5560 unsigned char seckey[32] = {
5561 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5562 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
5563 0xba, 0xae, 0xdc, 0xe6, 0xaf, 0x48, 0xa0, 0x3b,
5564 0xbf, 0xd2, 0x5e, 0x8c, 0xd0, 0x36, 0x41, 0x41,
5566 size_t outlen = 300;
5577#ifdef ENABLE_MODULE_ECDH
5581#ifdef ENABLE_MODULE_MULTISET
5585#ifdef ENABLE_MODULE_RECOVERY
5589#ifdef ENABLE_MODULE_SCHNORR
5593#ifdef ENABLE_MODULE_EXTRAKEYS
5597#ifdef ENABLE_MODULE_SCHNORRSIG
5602 unsigned char buf1[6] = {1, 2, 3, 4, 5, 6};
5603 unsigned char buf2[
sizeof(buf1)];
5606 memcpy(buf2, buf1,
sizeof(buf1));
5611 memset(buf2, 0,
sizeof(buf2));
5621 CHECK(r == INT_MAX);
5625 CHECK(r == INT_MAX);
5645 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5646 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5675 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5676 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5705 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5706 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5732 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);
5733 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);
5735 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5736 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5737 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL,
5738 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL
5775 setbuf(stdout, NULL);
5778 setbuf(stderr, NULL);
5782 count = strtol(argv[1], NULL, 0);
5784 const char* env = getenv(
"SECP256K1_TEST_ITERS");
5785 if (env && strlen(env) > 0) {
5786 count = strtol(env, NULL, 0);
5790 fputs(
"An iteration count of 0 or less is not allowed.\n", stderr);
5791 return EXIT_FAILURE;
5804 unsigned char rand32[32];
5857#ifdef ENABLE_MODULE_ECDH
5870#ifdef ENABLE_MODULE_MULTISET
5874#ifdef ENABLE_MODULE_RECOVERY
5879#ifdef ENABLE_MODULE_SCHNORR
5884#ifdef ENABLE_MODULE_EXTRAKEYS
5888#ifdef ENABLE_MODULE_SCHNORRSIG
5902 printf(
"no problems found\n");
void run_ecdh_tests(void)
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)
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_eckey_pubkey_parse(secp256k1_ge *elem, const unsigned char *pub, size_t size)
static int secp256k1_eckey_pubkey_serialize(secp256k1_ge *elem, unsigned char *pub, size_t *size, int compressed)
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 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_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 secp256k1_wnaf_const(int *wnaf, const secp256k1_scalar *scalar, int w, int size)
Convert a number to WNAF notation.
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_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const unsigned char *seed32)
#define STRAUSS_SCRATCH_OBJECTS
static size_t secp256k1_pippenger_bucket_window_inv(int bucket_window)
Returns the maximum optimal number of points for a bucket_window.
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.
static int secp256k1_wnaf_fixed(int *wnaf, const secp256k1_scalar *s, int w)
Convert a number to WNAF notation.
static int secp256k1_ecmult_wnaf(int *wnaf, int len, const secp256k1_scalar *a, int w)
Convert a number to WNAF notation.
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 size_t secp256k1_strauss_scratch_size(size_t n_points)
#define ECMULT_PIPPENGER_THRESHOLD
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...
#define ECMULT_MAX_POINTS_PER_BATCH
#define PIPPENGER_MAX_BUCKET_WINDOW
#define PIPPENGER_SCRATCH_OBJECTS
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)
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...
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_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)
#define WNAF_SIZE_BITS(bits, w)
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 void secp256k1_fe_normalize_weak(secp256k1_fe *r)
Weakly normalize a field element: reduce its magnitude to 1, but don't fully normalize.
static int secp256k1_fe_is_quad_var(const secp256k1_fe *a)
Checks whether a field element is a quadratic residue.
static int secp256k1_fe_equal_var(const secp256k1_fe *a, const secp256k1_fe *b)
Same as secp256k1_fe_equal, but may be variable time.
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 void secp256k1_fe_normalize_var(secp256k1_fe *r)
Normalize a field element, without constant-time guarantee.
static void secp256k1_fe_clear(secp256k1_fe *a)
Sets a field element equal to zero, initializing all fields.
static void secp256k1_fe_inv(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the (modular) inverse of another.
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.
static void secp256k1_fe_mul_int(secp256k1_fe *r, int a)
Multiplies the passed field element with a small integer constant.
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 int secp256k1_fe_is_odd(const secp256k1_fe *a)
Check the "oddness" of a field element.
static void secp256k1_fe_set_int(secp256k1_fe *r, int a)
Set a field element equal to a small integer.
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 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_is_zero(const secp256k1_fe *a)
Verify whether a field element is zero.
static void secp256k1_fe_from_storage(secp256k1_fe *r, const secp256k1_fe_storage *a)
Convert a field element back from the storage type.
static int secp256k1_fe_normalizes_to_zero_var(secp256k1_fe *r)
Verify whether a field element represents zero i.e.
static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a)
Sets a field element to be the square of another.
static void secp256k1_fe_add(secp256k1_fe *r, const secp256k1_fe *a)
Adds a field element to another.
static void secp256k1_fe_normalize(secp256k1_fe *r)
Field element module.
static void secp256k1_fe_to_storage(secp256k1_fe_storage *r, const secp256k1_fe *a)
Convert a field element to the storage type.
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 int secp256k1_fe_normalizes_to_zero(secp256k1_fe *r)
Verify whether a field element represents zero i.e.
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.
static int secp256k1_fe_cmp_var(const secp256k1_fe *a, const secp256k1_fe *b)
Compare two field elements.
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
static const secp256k1_fe secp256k1_fe_one
#define SECP256K1_GEJ_CONST_INFINITY
#define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr)
Set r equal to the double of a.
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).
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.
static void secp256k1_gej_set_infinity(secp256k1_gej *r)
Set a group element (jacobian) equal to the point at infinity.
static int secp256k1_gej_is_infinity(const secp256k1_gej *a)
Check whether a group element is the point at infinity.
static void secp256k1_ge_clear(secp256k1_ge *r)
Clear a secp256k1_ge to prevent leaking sensitive information.
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.
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).
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_ge_is_valid_var(const secp256k1_ge *a)
Check whether a group element is valid (i.e., on the curve).
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 void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b)
Rescale a jacobian point by b which must be non-zero.
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.
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_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a)
Set a group element equal to another which is given in jacobian coordinates.
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)
static int secp256k1_ge_is_infinity(const secp256k1_ge *a)
Check whether a group element is the point at infinity.
static void secp256k1_ge_set_infinity(secp256k1_ge *r)
Set a group element (affine) equal to the point at infinity.
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_gej_double(secp256k1_gej *r, const secp256k1_gej *a)
Set r equal to the double of a.
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.
#define SECP256K1_GE_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)
Set a group element equal to another which is given in jacobian coordinates.
static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a)
Check whether a group element's y coordinate is a quadratic residue.
#define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
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 const secp256k1_ge secp256k1_ge_const_g
Generator for secp256k1, value 'g' defined in "Standards for Efficient Cryptography" (SEC2) 2....
int ec_privkey_export_der(const secp256k1_context *ctx, uint8_t *privkey, size_t *privkeylen, const uint8_t *key32, bool compressed)
This serializes to a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 http://www....
int ec_privkey_import_der(const secp256k1_context *ctx, uint8_t *out32, const uint8_t *privkey, size_t privkeylen)
These functions are taken from the libsecp256k1 distribution and are very ugly.
static void secp256k1_modinv32_var(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo)
static void secp256k1_modinv32(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo)
static void secp256k1_modinv64(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo)
static void secp256k1_modinv64_var(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo)
void run_multiset_tests(void)
int ecdsa_signature_parse_der_lax(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const uint8_t *input, size_t inputlen)
This function is taken from the libsecp256k1 distribution and implements DER parsing for ECDSA signat...
void run_recovery_tests(void)
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 void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow)
Set a scalar from a big endian byte array.
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 int secp256k1_scalar_is_even(const secp256k1_scalar *a)
Check whether a scalar, considered as an nonnegative integer, is even.
static int secp256k1_scalar_is_zero(const secp256k1_scalar *a)
Check whether a scalar equals zero.
static void secp256k1_scalar_set_int(secp256k1_scalar *r, unsigned int v)
Set a scalar to an unsigned integer.
static int secp256k1_scalar_eq(const secp256k1_scalar *a, const secp256k1_scalar *b)
Compare two scalars.
static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
Convert a scalar to a byte array.
static int secp256k1_scalar_cond_negate(secp256k1_scalar *a, int flag)
Conditionally negate a number, in constant time.
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.
static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
Access bits from a scalar.
static int secp256k1_scalar_add(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b)
Add two scalars together (modulo the group order).
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_scalar_is_one(const secp256k1_scalar *a)
Check whether a scalar equals one.
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
static int secp256k1_scalar_is_high(const secp256k1_scalar *a)
Check whether a scalar is higher than the group order divided by 2.
static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count)
Access bits from a scalar.
static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the inverse of a scalar (modulo the group order).
static void secp256k1_scalar_cadd_bit(secp256k1_scalar *r, unsigned int bit, int flag)
Conditionally add a power of two to a scalar.
static void secp256k1_scalar_clear(secp256k1_scalar *r)
Clear a scalar to prevent the leak of sensitive data.
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...
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...
#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0)
static SECP256K1_INLINE int secp256k1_scalar_check_overflow(const secp256k1_scalar *a)
static const secp256k1_scalar secp256k1_scalar_zero
static const secp256k1_scalar secp256k1_scalar_one
static const secp256k1_scalar secp256k1_const_lambda
The Secp256k1 curve has an endomorphism, where lambda * (x, y) = (beta * x, y), where lambda is:
void run_schnorr_tests(void)
void run_schnorrsig_tests(void)
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_scratch_destroy(const secp256k1_callback *error_callback, secp256k1_scratch *scratch)
static secp256k1_scratch * secp256k1_scratch_create(const secp256k1_callback *error_callback, size_t max_size)
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.
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 size_t secp256k1_scratch_checkpoint(const secp256k1_callback *error_callback, const secp256k1_scratch *scratch)
Returns an opaque object used to "checkpoint" a scratch space.
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen)
static void secp256k1_hmac_sha256_finalize(secp256k1_hmac_sha256 *hash, unsigned char *out32)
static void secp256k1_hmac_sha256_initialize(secp256k1_hmac_sha256 *hash, const unsigned char *key, size_t size)
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
static void secp256k1_rfc6979_hmac_sha256_initialize(secp256k1_rfc6979_hmac_sha256 *rng, const unsigned char *key, size_t keylen)
static void secp256k1_rfc6979_hmac_sha256_finalize(secp256k1_rfc6979_hmac_sha256 *rng)
static void secp256k1_hmac_sha256_write(secp256k1_hmac_sha256 *hash, const unsigned char *data, size_t size)
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
static SECP256K1_INLINE int secp256k1_ctz64_var(uint64_t x)
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
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.
static SECP256K1_INLINE int secp256k1_ctz32_var(uint32_t x)
static SECP256K1_INLINE int secp256k1_ctz64_var_debruijn(uint64_t x)
static SECP256K1_INLINE int secp256k1_ctz32_var_debruijn(uint32_t x)
static SECP256K1_INLINE void * checked_malloc(const secp256k1_callback *cb, size_t size)
static SECP256K1_INLINE void secp256k1_memczero(void *s, size_t len, int flag)
static void secp256k1_ecdsa_signature_save(secp256k1_ecdsa_signature *sig, const secp256k1_scalar *r, const secp256k1_scalar *s)
static int secp256k1_pubkey_load(const secp256k1_context *ctx, secp256k1_ge *ge, const secp256k1_pubkey *pubkey)
static void secp256k1_pubkey_save(secp256k1_pubkey *pubkey, secp256k1_ge *ge)
static void secp256k1_default_illegal_callback_fn(const char *str, void *data)
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)
static void secp256k1_ecdsa_signature_load(const secp256k1_context *ctx, secp256k1_scalar *r, secp256k1_scalar *s, const secp256k1_ecdsa_signature *sig)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by multiplying it by a tweak.
#define SECP256K1_CONTEXT_SIGN
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.
SECP256K1_API const secp256k1_context * secp256k1_context_no_precomp
A simple secp256k1 context object with no precomputed tables.
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.
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.
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.
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 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.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_cmp(const secp256k1_context *ctx, const secp256k1_pubkey *pubkey1, const secp256k1_pubkey *pubkey2) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compare two public keys using lexicographic (of compressed serialization) order.
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.
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
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.
SECP256K1_API int secp256k1_ecdsa_sign(const secp256k1_context *ctx, secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, 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.
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.
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.
#define SECP256K1_CONTEXT_NONE
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.
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.
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.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_tagged_sha256(const secp256k1_context *ctx, unsigned char *hash32, const unsigned char *tag, size_t taglen, const unsigned char *msg, size_t msglen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Compute a tagged hash as defined in BIP-340.
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Verify an ECDSA signature.
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.
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).
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) 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_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Same as secp256k1_ec_seckey_tweak_add, but DEPRECATED.
#define SECP256K1_EC_UNCOMPRESSED
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Same as secp256k1_ec_seckey_tweak_mul, but DEPRECATED.
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.
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.
SECP256K1_API void secp256k1_scratch_space_destroy(const secp256k1_context *ctx, secp256k1_scratch_space *scratch) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 scratch space.
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_tweak_add(const secp256k1_context *ctx, unsigned char *seckey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a secret key by adding tweak to it.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const unsigned char *tweak32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Tweak a public key by multiplying it by a tweak value.
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object (created in dynamically allocated memory).
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.
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_preallocated_create(void *prealloc, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object in caller-provided memory.
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.
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.
void(* fn)(const char *text, void *data)
secp256k1_callback error_callback
secp256k1_ecmult_gen_context ecmult_gen_ctx
secp256k1_ecmult_context ecmult_ctx
Opaque data structured that holds a parsed ECDSA signature.
A group element of the secp256k1 curve, in affine coordinates.
A group element of the secp256k1 curve, in jacobian coordinates.
secp256k1_modinv32_signed30 modulus
secp256k1_modinv64_signed62 modulus
Opaque data structure that holds a parsed and valid public key.
A scalar modulo the group order of the secp256k1 curve.
size_t alloc_size
amount that has been allocated (i.e.
static uint32_t secp256k1_testrand_int(uint32_t range)
Generate a pseudorandom number in the range [0..range-1].
static uint32_t secp256k1_testrand32(void)
Generate a pseudorandom number in the range [0..2**32-1].
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_testrand256(unsigned char *b32)
Generate a pseudorandom 32-byte array.
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.
static void secp256k1_testrand_finish(void)
Print final test information.
static void secp256k1_testrand256_test(unsigned char *b32)
Generate a pseudorandom 32-byte array with long sequences of zero and one bits.
static uint32_t secp256k1_testrand_bits(int bits)
Generate a pseudorandom number in the range [0..2**bits-1].
void test_ecmult_multi_batching(void)
Run secp256k1_ecmult_multi_var with num points and a scratch space restricted to 1 <= i <= num points...
void random_scalar_order(secp256k1_scalar *num)
void run_group_decompress(void)
void run_random_pubkeys(void)
static secp256k1_context * ctx
void test_intialized_inf(void)
void test_ecmult_target(const secp256k1_scalar *target, int mode)
void test_inverse_field(secp256k1_fe *out, const secp256k1_fe *x, int var)
void run_modinv_tests(void)
int test_ecdsa_der_parse(const unsigned char *sig, size_t siglen, int certainly_der, int certainly_not_der)
void test_ecmult_multi_batch_size_helper(void)
void run_ec_pubkey_parse_test(void)
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_test_retry(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter)
#define SECP256K1_EC_PARSE_TEST_NINVALID
void run_endomorphism_tests(void)
void run_sha256_tests(void)
void ecmult_const_random_mult(void)
void run_eckey_edge_case_test(void)
void test_ecmult_gen_blind_reset(void)
void run_ec_combine(void)
int main(int argc, char **argv)
void test_secp256k1_pippenger_bucket_window_inv(void)
void run_cmov_tests(void)
void run_field_convert(void)
void test_ecdsa_end_to_end(void)
#define SECP256K1_EC_PARSE_TEST_NVALID
void run_field_misc(void)
void test_sqrt(const secp256k1_fe *a, const secp256k1_fe *k)
void random_field_element_magnitude(secp256k1_fe *fe)
void mulmod256(uint16_t *out, const uint16_t *a, const uint16_t *b, const uint16_t *m)
void random_scalar_order_test(secp256k1_scalar *num)
void test_point_times_order(const secp256k1_gej *point)
static void random_ber_signature(unsigned char *sig, size_t *len, int *certainly_der, int *certainly_not_der)
void test_ecmult_multi(secp256k1_scratch *scratch, secp256k1_ecmult_multi_func ecmult_multi)
void random_sign(secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *key, const secp256k1_scalar *msg, int *recid)
void ecmult_const_chain_multiply(void)
static void assign_big_endian(unsigned char *ptr, size_t ptrlen, uint32_t val)
void random_group_element_test(secp256k1_ge *ge)
void test_modinv32_uint16(uint16_t *out, const uint16_t *in, const uint16_t *mod)
void scalar_cmov_test(void)
void run_hmac_sha256_tests(void)
void ge_equals_ge(const secp256k1_ge *a, const secp256k1_ge *b)
void test_rand_int(uint32_t range, uint32_t subrange)
void random_fe_test(secp256k1_fe *x)
void ge_equals_gej(const secp256k1_ge *a, const secp256k1_gej *b)
void test_wnaf(const secp256k1_scalar *number, int w)
int is_empty_signature(const secp256k1_ecdsa_signature *sig)
void random_fe_non_zero(secp256k1_fe *nz)
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.
void test_add_neg_y_diff_x(void)
void run_ecdsa_sign_verify(void)
static const secp256k1_scalar scalar_minus_one
void random_group_element_jacobian_test(secp256k1_gej *gej, const secp256k1_ge *ge)
int coprime(const uint16_t *a, const uint16_t *b)
void run_ecmult_constants(void)
void random_scalar_order_b32(unsigned char *b32)
void run_pubkey_comparison(void)
int gej_xyz_equals_gej(const secp256k1_gej *a, const secp256k1_gej *b)
void test_random_pubkeys(void)
void test_ecdsa_sign_verify(void)
void ge_storage_cmov_test(void)
void run_inverse_tests(void)
void ecmult_const_mult_zero_one(void)
void test_ecmult_constants(void)
void run_ecdsa_end_to_end(void)
void ecmult_const_commutativity(void)
void test_constant_wnaf(const secp256k1_scalar *number, int w)
void ec_pubkey_parse_pointtest(const unsigned char *input, int xvalid, int yvalid)
void test_ecmult_gen_blind(void)
static int ecmult_multi_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *cbdata)
void fe_storage_cmov_test(void)
void run_ecmult_near_split_bound(void)
void test_fixed_wnaf(const secp256k1_scalar *number, int w)
void test_ecdsa_edge_cases(void)
void test_inverse_scalar(secp256k1_scalar *out, const secp256k1_scalar *x, int var)
void test_group_decompress(const secp256k1_fe *x)
void test_fixed_wnaf_small_helper(int *wnaf, int *wnaf_expected, int w)
void run_ecmult_gen_blind(void)
void run_scalar_set_b32_seckey_tests(void)
void run_secp256k1_memczero_test(void)
static void counting_illegal_callback_fn(const char *str, void *data)
void random_fe_non_square(secp256k1_fe *ns)
void run_point_times_order(void)
static void uncounting_illegal_callback_fn(const char *str, void *data)
void test_scalar_split(const secp256k1_scalar *full)
static const secp256k1_scalar scalars_near_split_bounds[20]
void run_eckey_negate_test(void)
void uint16_to_signed30(secp256k1_modinv32_signed30 *out, const uint16_t *in)
void random_fe(secp256k1_fe *x)
void test_fixed_wnaf_small(void)
void test_ecmult_multi_pippenger_max_points(void)
Probabilistically test the function returning the maximum number of possible points for a given scrat...
void run_ecmult_multi_tests(void)
void run_ecdsa_edge_cases(void)
void test_ecmult_multi_batch_single(secp256k1_ecmult_multi_func ecmult_multi)
int fe_secp256k1_memcmp_var(const secp256k1_fe *a, const secp256k1_fe *b)
void test_constant_wnaf_negate(const secp256k1_scalar *number)
void run_rfc6979_hmac_sha256_tests(void)
static int ecmult_multi_false_callback(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *cbdata)
void run_tagged_sha256_tests(void)
int check_fe_equal(const secp256k1_fe *a, const secp256k1_fe *b)
void run_ecmult_chain(void)
void run_ecdsa_der_parse(void)
void mutate_sign_signed30(secp256k1_modinv32_signed30 *x)
uint64_t modinv2p64(uint64_t x)
void random_field_element_test(secp256k1_fe *fe)
void run_scratch_tests(void)
void run_context_tests(int use_prealloc)
void signed30_to_uint16(uint16_t *out, const secp256k1_modinv32_signed30 *in)
void test_ec_combine(void)
void run_ecmult_const_tests(void)
#define SECP256K1_EC_PARSE_TEST_NXVALID
static void damage_array(unsigned char *sig, size_t *len)
void test_rand_bits(int rand32, int bits)
void run_scalar_tests(void)
static const secp256k1_fe fe_minus_one