7#ifndef SECP256K1_MODULE_SCHNORRSIG_TESTS_H
8#define SECP256K1_MODULE_SCHNORRSIG_TESTS_H
16 unsigned char nonces[2][32];
35 unsigned char tag[13] =
"BIP0340/nonce";
36 unsigned char aux_tag[11] =
"BIP0340/aux";
37 unsigned char algo[13] =
"BIP0340/nonce";
38 size_t algolen =
sizeof(algo);
41 unsigned char nonce[32];
42 unsigned char msg[32];
43 size_t msglen =
sizeof(msg);
44 unsigned char key[32];
46 unsigned char aux_rand[32];
47 unsigned char *args[5];
75 for (i = 0; i <
count; i++) {
93 for (i = 0; i <
count; i++) {
94 unsigned char nonce2[32];
96 size_t msglen_tmp = (msglen + offset) % msglen;
105 algolen_tmp = (algolen + offset) % algolen;
115 unsigned char sk1[32];
116 unsigned char sk2[32];
117 unsigned char sk3[32];
118 unsigned char msg[32];
123 unsigned char sig[64];
153 memset(&zero_pk, 0,
sizeof(zero_pk));
222 unsigned char tag[17] =
"BIP0340/challenge";
234 unsigned char sig[64];
262 const unsigned char sk[32] = {
263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
264 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03
268 const unsigned char pk[32] = {
269 0xF9, 0x30, 0x8A, 0x01, 0x92, 0x58, 0xC3, 0x10,
270 0x49, 0x34, 0x4F, 0x85, 0xF8, 0x9D, 0x52, 0x29,
271 0xB5, 0x31, 0xC8, 0x45, 0x83, 0x6F, 0x99, 0xB0,
272 0x86, 0x01, 0xF1, 0x13, 0xBC, 0xE0, 0x36, 0xF9
274 unsigned char aux_rand[32] = {
275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
280 const unsigned char msg[32] = {
281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
286 const unsigned char sig[64] = {
287 0xE9, 0x07, 0x83, 0x1F, 0x80, 0x84, 0x8D, 0x10,
288 0x69, 0xA5, 0x37, 0x1B, 0x40, 0x24, 0x10, 0x36,
289 0x4B, 0xDF, 0x1C, 0x5F, 0x83, 0x07, 0xB0, 0x08,
290 0x4C, 0x55, 0xF1, 0xCE, 0x2D, 0xCA, 0x82, 0x15,
291 0x25, 0xF6, 0x6A, 0x4A, 0x85, 0xEA, 0x8B, 0x71,
292 0xE4, 0x82, 0xA7, 0x4F, 0x38, 0x2D, 0x2C, 0xE5,
293 0xEB, 0xEE, 0xE8, 0xFD, 0xB2, 0x17, 0x2F, 0x47,
294 0x7D, 0xF4, 0x90, 0x0D, 0x31, 0x05, 0x36, 0xC0
301 const unsigned char sk[32] = {
302 0xB7, 0xE1, 0x51, 0x62, 0x8A, 0xED, 0x2A, 0x6A,
303 0xBF, 0x71, 0x58, 0x80, 0x9C, 0xF4, 0xF3, 0xC7,
304 0x62, 0xE7, 0x16, 0x0F, 0x38, 0xB4, 0xDA, 0x56,
305 0xA7, 0x84, 0xD9, 0x04, 0x51, 0x90, 0xCF, 0xEF
307 const unsigned char pk[32] = {
308 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
309 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
310 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
311 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
313 unsigned char aux_rand[32] = {
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
319 const unsigned char msg[32] = {
320 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
321 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
322 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
323 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
325 const unsigned char sig[64] = {
326 0x68, 0x96, 0xBD, 0x60, 0xEE, 0xAE, 0x29, 0x6D,
327 0xB4, 0x8A, 0x22, 0x9F, 0xF7, 0x1D, 0xFE, 0x07,
328 0x1B, 0xDE, 0x41, 0x3E, 0x6D, 0x43, 0xF9, 0x17,
329 0xDC, 0x8D, 0xCF, 0x8C, 0x78, 0xDE, 0x33, 0x41,
330 0x89, 0x06, 0xD1, 0x1A, 0xC9, 0x76, 0xAB, 0xCC,
331 0xB2, 0x0B, 0x09, 0x12, 0x92, 0xBF, 0xF4, 0xEA,
332 0x89, 0x7E, 0xFC, 0xB6, 0x39, 0xEA, 0x87, 0x1C,
333 0xFA, 0x95, 0xF6, 0xDE, 0x33, 0x9E, 0x4B, 0x0A
340 const unsigned char sk[32] = {
341 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34,
342 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
343 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74,
344 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x14, 0xE5, 0xC9
346 const unsigned char pk[32] = {
347 0xDD, 0x30, 0x8A, 0xFE, 0xC5, 0x77, 0x7E, 0x13,
348 0x12, 0x1F, 0xA7, 0x2B, 0x9C, 0xC1, 0xB7, 0xCC,
349 0x01, 0x39, 0x71, 0x53, 0x09, 0xB0, 0x86, 0xC9,
350 0x60, 0xE1, 0x8F, 0xD9, 0x69, 0x77, 0x4E, 0xB8
352 unsigned char aux_rand[32] = {
353 0xC8, 0x7A, 0xA5, 0x38, 0x24, 0xB4, 0xD7, 0xAE,
354 0x2E, 0xB0, 0x35, 0xA2, 0xB5, 0xBB, 0xBC, 0xCC,
355 0x08, 0x0E, 0x76, 0xCD, 0xC6, 0xD1, 0x69, 0x2C,
356 0x4B, 0x0B, 0x62, 0xD7, 0x98, 0xE6, 0xD9, 0x06
358 const unsigned char msg[32] = {
359 0x7E, 0x2D, 0x58, 0xD8, 0xB3, 0xBC, 0xDF, 0x1A,
360 0xBA, 0xDE, 0xC7, 0x82, 0x90, 0x54, 0xF9, 0x0D,
361 0xDA, 0x98, 0x05, 0xAA, 0xB5, 0x6C, 0x77, 0x33,
362 0x30, 0x24, 0xB9, 0xD0, 0xA5, 0x08, 0xB7, 0x5C
364 const unsigned char sig[64] = {
365 0x58, 0x31, 0xAA, 0xEE, 0xD7, 0xB4, 0x4B, 0xB7,
366 0x4E, 0x5E, 0xAB, 0x94, 0xBA, 0x9D, 0x42, 0x94,
367 0xC4, 0x9B, 0xCF, 0x2A, 0x60, 0x72, 0x8D, 0x8B,
368 0x4C, 0x20, 0x0F, 0x50, 0xDD, 0x31, 0x3C, 0x1B,
369 0xAB, 0x74, 0x58, 0x79, 0xA5, 0xAD, 0x95, 0x4A,
370 0x72, 0xC4, 0x5A, 0x91, 0xC3, 0xA5, 0x1D, 0x3C,
371 0x7A, 0xDE, 0xA9, 0x8D, 0x82, 0xF8, 0x48, 0x1E,
372 0x0E, 0x1E, 0x03, 0x67, 0x4A, 0x6F, 0x3F, 0xB7
379 const unsigned char sk[32] = {
380 0x0B, 0x43, 0x2B, 0x26, 0x77, 0x93, 0x73, 0x81,
381 0xAE, 0xF0, 0x5B, 0xB0, 0x2A, 0x66, 0xEC, 0xD0,
382 0x12, 0x77, 0x30, 0x62, 0xCF, 0x3F, 0xA2, 0x54,
383 0x9E, 0x44, 0xF5, 0x8E, 0xD2, 0x40, 0x17, 0x10
385 const unsigned char pk[32] = {
386 0x25, 0xD1, 0xDF, 0xF9, 0x51, 0x05, 0xF5, 0x25,
387 0x3C, 0x40, 0x22, 0xF6, 0x28, 0xA9, 0x96, 0xAD,
388 0x3A, 0x0D, 0x95, 0xFB, 0xF2, 0x1D, 0x46, 0x8A,
389 0x1B, 0x33, 0xF8, 0xC1, 0x60, 0xD8, 0xF5, 0x17
391 unsigned char aux_rand[32] = {
392 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
393 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
394 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
395 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
397 const unsigned char msg[32] = {
398 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
399 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
400 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
401 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
403 const unsigned char sig[64] = {
404 0x7E, 0xB0, 0x50, 0x97, 0x57, 0xE2, 0x46, 0xF1,
405 0x94, 0x49, 0x88, 0x56, 0x51, 0x61, 0x1C, 0xB9,
406 0x65, 0xEC, 0xC1, 0xA1, 0x87, 0xDD, 0x51, 0xB6,
407 0x4F, 0xDA, 0x1E, 0xDC, 0x96, 0x37, 0xD5, 0xEC,
408 0x97, 0x58, 0x2B, 0x9C, 0xB1, 0x3D, 0xB3, 0x93,
409 0x37, 0x05, 0xB3, 0x2B, 0xA9, 0x82, 0xAF, 0x5A,
410 0xF2, 0x5F, 0xD7, 0x88, 0x81, 0xEB, 0xB3, 0x27,
411 0x71, 0xFC, 0x59, 0x22, 0xEF, 0xC6, 0x6E, 0xA3
418 const unsigned char pk[32] = {
419 0xD6, 0x9C, 0x35, 0x09, 0xBB, 0x99, 0xE4, 0x12,
420 0xE6, 0x8B, 0x0F, 0xE8, 0x54, 0x4E, 0x72, 0x83,
421 0x7D, 0xFA, 0x30, 0x74, 0x6D, 0x8B, 0xE2, 0xAA,
422 0x65, 0x97, 0x5F, 0x29, 0xD2, 0x2D, 0xC7, 0xB9
424 const unsigned char msg[32] = {
425 0x4D, 0xF3, 0xC3, 0xF6, 0x8F, 0xCC, 0x83, 0xB2,
426 0x7E, 0x9D, 0x42, 0xC9, 0x04, 0x31, 0xA7, 0x24,
427 0x99, 0xF1, 0x78, 0x75, 0xC8, 0x1A, 0x59, 0x9B,
428 0x56, 0x6C, 0x98, 0x89, 0xB9, 0x69, 0x67, 0x03
430 const unsigned char sig[64] = {
431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
432 0x00, 0x00, 0x00, 0x3B, 0x78, 0xCE, 0x56, 0x3F,
433 0x89, 0xA0, 0xED, 0x94, 0x14, 0xF5, 0xAA, 0x28,
434 0xAD, 0x0D, 0x96, 0xD6, 0x79, 0x5F, 0x9C, 0x63,
435 0x76, 0xAF, 0xB1, 0x54, 0x8A, 0xF6, 0x03, 0xB3,
436 0xEB, 0x45, 0xC9, 0xF8, 0x20, 0x7D, 0xEE, 0x10,
437 0x60, 0xCB, 0x71, 0xC0, 0x4E, 0x80, 0xF5, 0x93,
438 0x06, 0x0B, 0x07, 0xD2, 0x83, 0x08, 0xD7, 0xF4
444 const unsigned char pk[32] = {
445 0xEE, 0xFD, 0xEA, 0x4C, 0xDB, 0x67, 0x77, 0x50,
446 0xA4, 0x20, 0xFE, 0xE8, 0x07, 0xEA, 0xCF, 0x21,
447 0xEB, 0x98, 0x98, 0xAE, 0x79, 0xB9, 0x76, 0x87,
448 0x66, 0xE4, 0xFA, 0xA0, 0x4A, 0x2D, 0x4A, 0x34
456 const unsigned char pk[32] = {
457 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
458 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
459 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
460 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
462 const unsigned char msg[32] = {
463 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
464 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
465 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
466 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
468 const unsigned char sig[64] = {
469 0xFF, 0xF9, 0x7B, 0xD5, 0x75, 0x5E, 0xEE, 0xA4,
470 0x20, 0x45, 0x3A, 0x14, 0x35, 0x52, 0x35, 0xD3,
471 0x82, 0xF6, 0x47, 0x2F, 0x85, 0x68, 0xA1, 0x8B,
472 0x2F, 0x05, 0x7A, 0x14, 0x60, 0x29, 0x75, 0x56,
473 0x3C, 0xC2, 0x79, 0x44, 0x64, 0x0A, 0xC6, 0x07,
474 0xCD, 0x10, 0x7A, 0xE1, 0x09, 0x23, 0xD9, 0xEF,
475 0x7A, 0x73, 0xC6, 0x43, 0xE1, 0x66, 0xBE, 0x5E,
476 0xBE, 0xAF, 0xA3, 0x4B, 0x1A, 0xC5, 0x53, 0xE2
482 const unsigned char pk[32] = {
483 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
484 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
485 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
486 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
488 const unsigned char msg[32] = {
489 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
490 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
491 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
492 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
494 const unsigned char sig[64] = {
495 0x1F, 0xA6, 0x2E, 0x33, 0x1E, 0xDB, 0xC2, 0x1C,
496 0x39, 0x47, 0x92, 0xD2, 0xAB, 0x11, 0x00, 0xA7,
497 0xB4, 0x32, 0xB0, 0x13, 0xDF, 0x3F, 0x6F, 0xF4,
498 0xF9, 0x9F, 0xCB, 0x33, 0xE0, 0xE1, 0x51, 0x5F,
499 0x28, 0x89, 0x0B, 0x3E, 0xDB, 0x6E, 0x71, 0x89,
500 0xB6, 0x30, 0x44, 0x8B, 0x51, 0x5C, 0xE4, 0xF8,
501 0x62, 0x2A, 0x95, 0x4C, 0xFE, 0x54, 0x57, 0x35,
502 0xAA, 0xEA, 0x51, 0x34, 0xFC, 0xCD, 0xB2, 0xBD
508 const unsigned char pk[32] = {
509 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
510 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
511 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
512 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
514 const unsigned char msg[32] = {
515 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
516 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
517 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
518 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
520 const unsigned char sig[64] = {
521 0x6C, 0xFF, 0x5C, 0x3B, 0xA8, 0x6C, 0x69, 0xEA,
522 0x4B, 0x73, 0x76, 0xF3, 0x1A, 0x9B, 0xCB, 0x4F,
523 0x74, 0xC1, 0x97, 0x60, 0x89, 0xB2, 0xD9, 0x96,
524 0x3D, 0xA2, 0xE5, 0x54, 0x3E, 0x17, 0x77, 0x69,
525 0x96, 0x17, 0x64, 0xB3, 0xAA, 0x9B, 0x2F, 0xFC,
526 0xB6, 0xEF, 0x94, 0x7B, 0x68, 0x87, 0xA2, 0x26,
527 0xE8, 0xD7, 0xC9, 0x3E, 0x00, 0xC5, 0xED, 0x0C,
528 0x18, 0x34, 0xFF, 0x0D, 0x0C, 0x2E, 0x6D, 0xA6
534 const unsigned char pk[32] = {
535 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
536 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
537 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
538 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
540 const unsigned char msg[32] = {
541 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
542 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
543 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
544 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
546 const unsigned char sig[64] = {
547 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
548 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
549 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
550 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
551 0x12, 0x3D, 0xDA, 0x83, 0x28, 0xAF, 0x9C, 0x23,
552 0xA9, 0x4C, 0x1F, 0xEE, 0xCF, 0xD1, 0x23, 0xBA,
553 0x4F, 0xB7, 0x34, 0x76, 0xF0, 0xD5, 0x94, 0xDC,
554 0xB6, 0x5C, 0x64, 0x25, 0xBD, 0x18, 0x60, 0x51
560 const unsigned char pk[32] = {
561 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
562 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
563 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
564 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
566 const unsigned char msg[32] = {
567 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
568 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
569 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
570 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
572 const unsigned char sig[64] = {
573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
577 0x76, 0x15, 0xFB, 0xAF, 0x5A, 0xE2, 0x88, 0x64,
578 0x01, 0x3C, 0x09, 0x97, 0x42, 0xDE, 0xAD, 0xB4,
579 0xDB, 0xA8, 0x7F, 0x11, 0xAC, 0x67, 0x54, 0xF9,
580 0x37, 0x80, 0xD5, 0xA1, 0x83, 0x7C, 0xF1, 0x97
586 const unsigned char pk[32] = {
587 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
588 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
589 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
590 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
592 const unsigned char msg[32] = {
593 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
594 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
595 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
596 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
598 const unsigned char sig[64] = {
599 0x4A, 0x29, 0x8D, 0xAC, 0xAE, 0x57, 0x39, 0x5A,
600 0x15, 0xD0, 0x79, 0x5D, 0xDB, 0xFD, 0x1D, 0xCB,
601 0x56, 0x4D, 0xA8, 0x2B, 0x0F, 0x26, 0x9B, 0xC7,
602 0x0A, 0x74, 0xF8, 0x22, 0x04, 0x29, 0xBA, 0x1D,
603 0x69, 0xE8, 0x9B, 0x4C, 0x55, 0x64, 0xD0, 0x03,
604 0x49, 0x10, 0x6B, 0x84, 0x97, 0x78, 0x5D, 0xD7,
605 0xD1, 0xD7, 0x13, 0xA8, 0xAE, 0x82, 0xB3, 0x2F,
606 0xA7, 0x9D, 0x5F, 0x7F, 0xC4, 0x07, 0xD3, 0x9B
612 const unsigned char pk[32] = {
613 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
614 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
615 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
616 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
618 const unsigned char msg[32] = {
619 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
620 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
621 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
622 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
624 const unsigned char sig[64] = {
625 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
626 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
627 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
628 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFC, 0x2F,
629 0x69, 0xE8, 0x9B, 0x4C, 0x55, 0x64, 0xD0, 0x03,
630 0x49, 0x10, 0x6B, 0x84, 0x97, 0x78, 0x5D, 0xD7,
631 0xD1, 0xD7, 0x13, 0xA8, 0xAE, 0x82, 0xB3, 0x2F,
632 0xA7, 0x9D, 0x5F, 0x7F, 0xC4, 0x07, 0xD3, 0x9B
638 const unsigned char pk[32] = {
639 0xDF, 0xF1, 0xD7, 0x7F, 0x2A, 0x67, 0x1C, 0x5F,
640 0x36, 0x18, 0x37, 0x26, 0xDB, 0x23, 0x41, 0xBE,
641 0x58, 0xFE, 0xAE, 0x1D, 0xA2, 0xDE, 0xCE, 0xD8,
642 0x43, 0x24, 0x0F, 0x7B, 0x50, 0x2B, 0xA6, 0x59
644 const unsigned char msg[32] = {
645 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3,
646 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44,
647 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0,
648 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89
650 const unsigned char sig[64] = {
651 0x6C, 0xFF, 0x5C, 0x3B, 0xA8, 0x6C, 0x69, 0xEA,
652 0x4B, 0x73, 0x76, 0xF3, 0x1A, 0x9B, 0xCB, 0x4F,
653 0x74, 0xC1, 0x97, 0x60, 0x89, 0xB2, 0xD9, 0x96,
654 0x3D, 0xA2, 0xE5, 0x54, 0x3E, 0x17, 0x77, 0x69,
655 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
656 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
657 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B,
658 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41
664 const unsigned char pk[32] = {
665 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
666 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
667 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
668 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFC, 0x30
677static int nonce_function_failing(
unsigned char *nonce32,
const unsigned char *msg,
size_t msglen,
const unsigned char *key32,
const unsigned char *xonly_pk32,
const unsigned char *algo,
size_t algolen,
void *data) {
690static int nonce_function_0(
unsigned char *nonce32,
const unsigned char *msg,
size_t msglen,
const unsigned char *key32,
const unsigned char *xonly_pk32,
const unsigned char *algo,
size_t algolen,
void *data) {
699 memset(nonce32, 0, 32);
704static int nonce_function_overflowing(
unsigned char *nonce32,
const unsigned char *msg,
size_t msglen,
const unsigned char *key32,
const unsigned char *xonly_pk32,
const unsigned char *algo,
size_t algolen,
void *data) {
713 memset(nonce32, 0xFF, 32);
718 unsigned char sk[32];
721 const unsigned char msg[32] =
"this is a msg for a schnorrsig..";
722 unsigned char sig[64];
723 unsigned char sig2[64];
724 unsigned char zeros64[64] = { 0 };
726 unsigned char aux_rand[32];
738 memset(
sig, 1,
sizeof(
sig));
742 memset(&
sig, 1,
sizeof(
sig));
746 memset(&
sig, 1,
sizeof(
sig));
754 extraparams.
ndata = aux_rand;
765 unsigned char sk[32];
766 unsigned char msg[
N_SIGS][32];
777 for (i = 0; i <
N_SIGS; i++) {
789 sig[sig_idx][byte_idx] ^= xorbyte;
791 sig[sig_idx][byte_idx] ^= xorbyte;
794 sig[sig_idx][32+byte_idx] ^= xorbyte;
796 sig[sig_idx][32+byte_idx] ^= xorbyte;
799 msg[sig_idx][byte_idx] ^= xorbyte;
801 msg[sig_idx][byte_idx] ^= xorbyte;
810 memset(&
sig[0][32], 0xFF, 32);
827 unsigned char msg_large[32 * 8];
829 for (i = 0; i <
sizeof(msg_large); i += 32) {
835 msglen = (msglen + (
sizeof(msg_large) - 1)) %
sizeof(msg_large);
842 unsigned char sk[32];
845 unsigned char internal_pk_bytes[32];
847 unsigned char output_pk_bytes[32];
848 unsigned char tweak[32];
850 unsigned char msg[32];
851 unsigned char sig[64];
884 for (i = 0; i <
count; i++) {
static void secp256k1_sha256_initialize_tagged(secp256k1_sha256 *hash, const unsigned char *tag, size_t taglen)
Internal SHA-1 implementation.
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 void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar *a)
Convert a scalar to a byte array.
static void secp256k1_scalar_negate(secp256k1_scalar *r, const secp256k1_scalar *a)
Compute the complement of a scalar (modulo the group order).
static int nonce_function_bip340(unsigned char *nonce32, const unsigned char *msg, size_t msglen, const unsigned char *key32, const unsigned char *xonly_pk32, const unsigned char *algo, size_t algolen, void *data)
static void secp256k1_nonce_function_bip340_sha256_tagged_aux(secp256k1_sha256 *sha)
static void secp256k1_nonce_function_bip340_sha256_tagged(secp256k1_sha256 *sha)
static void secp256k1_schnorrsig_sha256_tagged(secp256k1_sha256 *sha)
void test_schnorrsig_bip_vectors(void)
void test_schnorrsig_sign(void)
static int nonce_function_overflowing(unsigned char *nonce32, const unsigned char *msg, size_t msglen, const unsigned char *key32, const unsigned char *xonly_pk32, const unsigned char *algo, size_t algolen, void *data)
void run_nonce_function_bip340_tests(void)
void test_schnorrsig_bip_vectors_check_verify(const unsigned char *pk_serialized, const unsigned char *msg32, const unsigned char *sig, int expected)
void test_schnorrsig_taproot(void)
static int nonce_function_0(unsigned char *nonce32, const unsigned char *msg, size_t msglen, const unsigned char *key32, const unsigned char *xonly_pk32, const unsigned char *algo, size_t algolen, void *data)
void test_sha256_eq(const secp256k1_sha256 *sha1, const secp256k1_sha256 *sha2)
void test_schnorrsig_bip_vectors_check_signing(const unsigned char *sk, const unsigned char *pk_serialized, unsigned char *aux_rand, const unsigned char *msg32, const unsigned char *expected_sig)
void test_schnorrsig_sign_verify(void)
void run_schnorrsig_tests(void)
void nonce_function_bip340_bitflip(unsigned char **args, size_t n_flip, size_t n_bytes, size_t msglen, size_t algolen)
void test_schnorrsig_sha256_tagged(void)
static int nonce_function_failing(unsigned char *nonce32, const unsigned char *msg, size_t msglen, const unsigned char *key32, const unsigned char *xonly_pk32, const unsigned char *algo, size_t algolen, void *data)
void test_schnorrsig_api(void)
static void secp256k1_rfc6979_hmac_sha256_generate(secp256k1_rfc6979_hmac_sha256 *rng, unsigned char *out, size_t outlen)
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
#define SECP256K1_CONTEXT_SIGN
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_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.
#define SECP256K1_CONTEXT_NONE
#define SECP256K1_CONTEXT_VERIFY
Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and secp256k1_context...
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx)
Destroy a secp256k1 context object (created in dynamically allocated memory).
SECP256K1_API int secp256k1_schnorrsig_sign(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, unsigned char *aux_rand32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create a Schnorr signature.
#define SECP256K1_SCHNORRSIG_EXTRAPARAMS_INIT
SECP256K1_API int secp256k1_schnorrsig_sign_custom(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_keypair *keypair, secp256k1_schnorrsig_extraparams *extraparams) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
Create a Schnorr signature with a more flexible API.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify(const secp256k1_context *ctx, const unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_xonly_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
Verify a Schnorr signature.
Opaque data structure that holds a keypair consisting of a secret and a public key.
A scalar modulo the group order of the secp256k1 curve.
Opaque data structure that holds a parsed and valid "x-only" public key.
static uint32_t secp256k1_testrand_int(uint32_t range)
Generate a pseudorandom number in the range [0..range-1].
static void secp256k1_testrand_flip(unsigned char *b, size_t len)
Flip a single random bit in a byte array.
static void secp256k1_testrand256(unsigned char *b32)
Generate a pseudorandom 32-byte array.
static secp256k1_rfc6979_hmac_sha256 secp256k1_test_rng
static void counting_illegal_callback_fn(const char *str, void *data)