6#ifndef SECP256K1_MODULE_SILENTPAYMENTS_TESTS_H
7#define SECP256K1_MODULE_SILENTPAYMENTS_TESTS_H
9#include "../../../include/secp256k1_silentpayments.h"
10#include "../../unit_test.h"
11#include "../../util.h"
12#include "../../../src/modules/silentpayments/vectors.h"
28 0x02, 0x15, 0x40, 0xae, 0xa8, 0x97, 0x54, 0x7a,
29 0xd4, 0x39, 0xb4, 0xe0, 0xf6, 0x09, 0xe5, 0xf0,
30 0xfa, 0x63, 0xde, 0x89, 0xab, 0x11, 0xed, 0xe3,
31 0x1e, 0x8c, 0xde, 0x4b, 0xe2, 0x19, 0x42, 0x5f,
35 0x02, 0x3e, 0xff, 0xf8, 0x18, 0x51, 0x65, 0xea,
36 0x63, 0xa9, 0x92, 0xb3, 0x9f, 0x31, 0xd8, 0xfd,
37 0x8e, 0x0e, 0x64, 0xae, 0xf9, 0xd3, 0x88, 0x07,
38 0x34, 0x97, 0x37, 0x14, 0xa5, 0x3d, 0x83, 0x11,
44 0x03, 0xbb, 0xc6, 0x3f, 0x12, 0x74, 0x5d, 0x3b,
45 0x9e, 0x9d, 0x24, 0xc6, 0xcd, 0x7a, 0x1e, 0xfe,
46 0xba, 0xd0, 0xa7, 0xf4, 0x69, 0x23, 0x2f, 0xbe,
47 0xcf, 0x31, 0xfb, 0xa7, 0xb4, 0xf7, 0xdd, 0xed,
51 0x03, 0x81, 0xeb, 0x9a, 0x9a, 0x9e, 0xc7, 0x39,
52 0xd5, 0x27, 0xc1, 0x63, 0x1b, 0x31, 0xb4, 0x21,
53 0x56, 0x6f, 0x5c, 0x2a, 0x47, 0xb4, 0xab, 0x5b,
54 0x1f, 0x6a, 0x68, 0x6d, 0xfb, 0x68, 0xea, 0xb7,
59 0x46, 0x0d, 0x68, 0x08, 0x65, 0x64, 0x45, 0xee,
60 0x4d, 0x4e, 0xc0, 0x8e, 0xba, 0x8a, 0x66, 0xea,
61 0x66, 0x8e, 0x4e, 0x12, 0x98, 0x9a, 0x0e, 0x60,
62 0x4b, 0x5c, 0x36, 0x0e, 0x43, 0xf5, 0x5a, 0xfa
65 0x4b, 0x81, 0x34, 0x5d, 0x53, 0x89, 0xba, 0xa3,
66 0xd8, 0x93, 0xe2, 0xfb, 0xe7, 0x08, 0xdd, 0x6d,
67 0x82, 0xdc, 0xd8, 0x49, 0xab, 0x03, 0xc1, 0xdb,
68 0x68, 0xbe, 0xc7, 0xe9, 0x2a, 0x45, 0xfa, 0xc5
71 0xb7, 0xf3, 0xc6, 0x79, 0x30, 0x4a, 0xef, 0x8c,
72 0xc0, 0xc7, 0x61, 0xf1, 0x00, 0x99, 0xdd, 0x7b,
73 0x20, 0x65, 0x20, 0xd7, 0x11, 0x6f, 0xb7, 0x91,
74 0xee, 0x74, 0x54, 0xa2, 0xfc, 0x22, 0x79, 0xf4
77 0x16, 0x9e, 0x1e, 0x83, 0xe9, 0x30, 0x85, 0x33, 0x91,
78 0xbc, 0x6f, 0x35, 0xf6, 0x05, 0xc6, 0x75, 0x4c, 0xfe,
79 0xad, 0x57, 0xcf, 0x83, 0x87, 0x63, 0x9d, 0x3b, 0x40,
80 0x96, 0xc5, 0x4f, 0x18, 0xf4, 0x00, 0x00, 0x00, 0x00
83 0xea, 0xdc, 0x78, 0x16, 0x5f, 0xf1, 0xf8, 0xea,
84 0x94, 0xad, 0x7c, 0xfd, 0xc5, 0x49, 0x90, 0x73,
85 0x8a, 0x4c, 0x53, 0xf6, 0xe0, 0x50, 0x7b, 0x42,
86 0x15, 0x42, 0x01, 0xb8, 0xe5, 0xdf, 0xf3, 0xb1
90 unsigned char label[33];
98const unsigned char*
label_lookup(
const unsigned char* key,
const void* cache_ptr) {
102 if (cache_ptr == NULL) {
115 unsigned char const *seckey_ptrs[1];
120 unsigned char xonly_ser[32];
125 for (i = 0; i < 3; i++) {
128 recipients[i].
index = i;
129 recipient_ptrs[i] = &recipients[i];
130 generated_output_ptrs[i] = &generated_outputs[i];
133 generated_output_ptrs,
140 for (i = 0; i < 3; i++) {
147 unsigned char (*sp_addresses[3])[2][33];
148 unsigned char (*sp_outputs[3])[32];
183 unsigned char (*sp_addresses[2])[2][33];
184 unsigned char const *p[1];
196 for (i = 0; i < 2; i++) {
213 for (i = 0; i < 2; i++) {
219 for (i = 0; i < 2; i++) {
225 op[i] = original_ptr_xpk;
229 rp[i] = original_ptr_rec;
238 unsigned char const *original_ptr = p[0];
267 memset(&taproot.
data[0], 0, 32);
282 memset(&r[1].spend_pubkey, 0,
sizeof(r[1].spend_pubkey));
290 memset(&r[1].scan_pubkey, 0,
sizeof(r[1].scan_pubkey));
298 unsigned char malformed_spend_key[32] = {
299 0x83, 0xe1, 0x79, 0xdf, 0x51, 0xbb, 0xc9, 0x6f,
300 0xfb, 0x59, 0xb6, 0x2e, 0x57, 0xcf, 0x4e, 0x54,
301 0x71, 0x79, 0x04, 0x9c, 0x01, 0x47, 0x00, 0xfe,
302 0x52, 0xef, 0x5f, 0x53, 0x76, 0x39, 0xec, 0xe0
308 for (i = 0; i < 2; i++) {
322 size_t test_num_recipients;
324 for (i = 0; i < total_recipients; i++) {
330 recipients[i].
index = i;
331 recipients_ptrs[i] = &recipients[i];
332 outputs_ptrs[i] = &outputs[i];
346 for (i = 0; i < total_recipients; i++) {
349 unsigned char tweak[32] = {0};
353 test_num_recipients = total_recipients;
358 for (i = 0; i < total_recipients; i++) {
359 recipients_ptrs[i] = &recipients[i];
363 test_num_recipients = total_recipients;
369 free(recipients_ptrs);
377 unsigned char lt[32];
378 unsigned char label_ser[33];
379 const unsigned char expected[33] = {
380 0x03, 0xdc, 0x7f, 0x09, 0x9a, 0xbe, 0x95, 0x7a,
381 0x58, 0x43, 0xd2, 0xb6, 0xbb, 0x35, 0x79, 0x61,
382 0x5c, 0x60, 0x36, 0xa4, 0x9b, 0x86, 0xf4, 0xbe,
383 0x46, 0x38, 0x60, 0x28, 0xa8, 0x1a, 0x77, 0xd4,
397 unsigned char parsed_label_ser[33];
398 static const unsigned char invalid_label_ser[33] = {0};
428 unsigned char neg_spend_label_ser[33];
438 memset(&
s, 0,
sizeof(
s));
442 memset(&l, 0,
sizeof(l));
446 memset(&
s, 0,
sizeof(
s));
464 memset(&malformed_p, 0,
sizeof(malformed_p));
465 memset(&malformed_t, 0,
sizeof(malformed_t));
478 pp_sum_zero[1] = &neg_p;
480 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
486 pp[0] = &malformed_p;
490 tp[0] = &malformed_t;
499 tp[0] = original_ptr;
505 pp[0] = original_ptr;
523 unsigned char output_tweak[32] = {
524 0x96, 0x32, 0xb4, 0x06, 0xeb, 0x56, 0xcc, 0xb2,
525 0x0f, 0xc6, 0xe5, 0x2c, 0x41, 0xd5, 0x73, 0xb2,
526 0xae, 0xa0, 0x45, 0x07, 0x63, 0xf1, 0xf6, 0x22,
527 0xfa, 0x87, 0xc2, 0x4c, 0x7d, 0x80, 0x58, 0x62,
536 unsigned char output_tweak[32] = {
537 0x96, 0x32, 0xb4, 0x06, 0xeb, 0x56, 0xcc, 0xb2,
538 0x0f, 0xc6, 0xe5, 0x2c, 0x41, 0xd5, 0x73, 0xb2,
539 0xae, 0xa0, 0x45, 0x07, 0x63, 0xf1, 0xf6, 0x22,
540 0xfa, 0x87, 0xc2, 0x4c, 0x7d, 0x80, 0x58, 0x62,
542 static const unsigned char zero[32] = {0};
550 output_xonly_ptrs[0] = &output_xonly;
560 CHECK(fp[0]->found_with_label == 1);
562 unsigned char found_label_ser[33];
578 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
579 fp[0] = original_ptr;
584 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
585 tp[0] = original_ptr;
588 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, NULL, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
589 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, NULL, tp, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
590 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, NULL, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
591 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1, NULL, &ps, &p, &
label_lookup, &
labels_cache));
592 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, NULL, &p, &
label_lookup, &
labels_cache));
593 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, NULL, &
label_lookup, &
labels_cache));
594 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 0,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
595 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, &
labels_cache));
598 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &malformed_p, NULL, NULL));
600 memset(&ps, 0,
sizeof(ps));
601 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
605 static const unsigned char sender_seckey[32] = { 1 };
606 static const unsigned char scan_seckey[32] = { 2 };
607 static const unsigned char spend_seckey[32] = { 3 };
608 secp256k1_pubkey sender_pubkey, scan_pubkey, unlabeled_spend_pubkey, labeled_spend_pubkey;
610 const unsigned char *sender_seckeys[1];
621 unsigned char found_label[33];
622 uint32_t n_found_outputs;
627 prevout_pubkeys[0] = &sender_pubkey;
628 sender_seckeys[0] = sender_seckey;
632 memset(&cache, 0,
sizeof(cache));
638 CTX, &labeled_spend_pubkey, &unlabeled_spend_pubkey, &label));
643 recipients[0] = &recipient;
645 generated_outputs[0] = &labeled_output;
649 generated_outputs[0] = &direct_output;
654 tx_outputs[0] = &labeled_output;
655 tx_outputs[1] = &direct_output;
656 found_outputs[0] = &found_output[0];
657 found_outputs[1] = &found_output[1];
659 CTX, found_outputs, &n_found_outputs, tx_outputs, 2, scan_seckey, &prevouts_summary,
661 CHECK(n_found_outputs == 1);
663 CHECK(found_output[0].found_with_label);
676 unsigned char created_output[32];
690 recipients[j].
index = j;
691 recipient_ptrs[j] = &recipients[j];
692 generated_output_ptrs[j] = &generated_outputs[j];
702 keypair_ptrs[i] = &keypairs[i];
708 generated_output_ptrs,
729 size_t n_matches = 0;
762 uint32_t n_found = 0;
763 unsigned char found_output[32];
770 pubkeys[i] = &pubkeys_objs[i];
774 xonly_pubkeys[i] = &xonly_pubkeys_objs[i];
798 tx_outputs[i] = &tx_output_objs[i];
799 found_outputs[i] = &found_output_objs[i];
816 found_outputs, &n_found,
820 &recipient_spend_pubkey,
825#ifdef ENABLE_MODULE_SCHNORRSIG
828 static unsigned char MSG32[32] = {
829 0xab,0x53,0x0a,0x13,0xe4,0x59,0x14,0x98,
830 0x2b,0x79,0xf9,0xb7,0xe3,0xfb,0xa9,0x94,
831 0xcf,0xd1,0xf3,0xfb,0x22,0xf7,0x1c,0xea,
832 0x1a,0xfb,0xf0,0x2b,0x46,0x0c,0x6d,0x1d
835 static unsigned char AUX32[32] = {
836 0x0b,0x3f,0xdd,0xfd,0x67,0xbf,0x76,0xae,
837 0x76,0x39,0xee,0x73,0x5b,0x70,0xff,0x15,
838 0x83,0xfd,0x92,0x48,0xc0,0x57,0xd2,0x86,
839 0x07,0xa2,0x15,0xf4,0x0b,0x0a,0x3e,0xcc
841 for (i = 0; i < n_found; i++) {
842 unsigned char full_seckey[32];
844 unsigned char signature[64];
849 memcpy(found_signatures[i], signature, 64);
853 for (i = 0; i < n_found; i++) {
859#ifdef ENABLE_MODULE_SCHNORRSIG
870 CHECK(!found_outputs[i]->found_with_label);
871 }
else if (found_outputs[i]->found_with_label) {
876 unsigned char found_label_ser[33];
877 const unsigned char *found_label_tweak;
880 CHECK(found_label_tweak != NULL);
891 static const unsigned char tag[] = {
'B',
'I',
'P',
'0',
'3',
'5',
'2',
'/',
'I',
'n',
'p',
'u',
't',
's'};
897 static const unsigned char tag[] = {
'B',
'I',
'P',
'0',
'3',
'5',
'2',
'/',
'S',
'h',
'a',
'r',
'e',
'd',
'S',
'e',
'c',
'r',
'e',
't'};
903 static const unsigned char tag[] = {
'B',
'I',
'P',
'0',
'3',
'5',
'2',
'/',
'L',
'a',
'b',
'e',
'l'};
#define CHECK(cond)
Unconditional failure on condition failure.
static int tweak(const secp256k1_context *ctx, secp256k1_xonly_pubkey *agg_pk, secp256k1_musig_keyagg_cache *cache)
static SECP256K1_INLINE int secp256k1_memcmp_var(const void *s1, const void *s2, size_t n)
Semantics like memcmp.
static SECP256K1_INLINE void secp256k1_write_be32(unsigned char *p, uint32_t x)
static SECP256K1_INLINE void * checked_malloc(const secp256k1_callback *cb, size_t size)
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_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 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 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 elliptic curve secret key.
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 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.
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.
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
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_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 int secp256k1_schnorrsig_sign32(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, const unsigned char *aux_rand32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create a Schnorr signature.
SECP256K1_API int secp256k1_silentpayments_recipient_label_serialize(const secp256k1_context *ctx, unsigned char *out33, const secp256k1_silentpayments_label *label) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Serialize a Silent Payments label.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_prevouts_summary_create(const secp256k1_context *ctx, secp256k1_silentpayments_prevouts_summary *prevouts_summary, const unsigned char *outpoint_smallest36, const secp256k1_xonly_pubkey *const *xonly_pubkeys, size_t n_xonly_pubkeys, const secp256k1_pubkey *const *pubkeys, size_t n_pubkeys) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Compute Silent Payments prevouts summary from prevout public keys and transaction inputs.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_label_parse(const secp256k1_context *ctx, secp256k1_silentpayments_label *label, const unsigned char *in33) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Parse a Silent Payments label.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_sender_create_outputs(const secp256k1_context *ctx, secp256k1_xonly_pubkey **generated_outputs, const secp256k1_silentpayments_recipient **recipients, size_t n_recipients, const unsigned char *outpoint_smallest36, const secp256k1_keypair *const *keypairs, size_t n_keypairs, const unsigned char *const *seckeys, size_t n_seckeys) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Create Silent Payments outputs for recipient(s).
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_create_labeled_spend_pubkey(const secp256k1_context *ctx, secp256k1_pubkey *labeled_spend_pubkey, const secp256k1_pubkey *unlabeled_spend_pubkey, const secp256k1_silentpayments_label *label) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create Silent Payments labeled spend public key.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_scan_outputs(const secp256k1_context *ctx, secp256k1_silentpayments_found_output **found_outputs, uint32_t *n_found_outputs, const secp256k1_xonly_pubkey *const *tx_outputs, size_t n_tx_outputs, const unsigned char *scan_key32, const secp256k1_silentpayments_prevouts_summary *prevouts_summary, const secp256k1_pubkey *unlabeled_spend_pubkey, secp256k1_silentpayments_label_lookup label_lookup, const void *label_context) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(6) SECP256K1_ARG_NONNULL(7) SECP256K1_ARG_NONNULL(8)
Scan for Silent Payments transaction outputs.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_label_create(const secp256k1_context *ctx, secp256k1_silentpayments_label *label, unsigned char *label_tweak32, const unsigned char *scan_key32, uint32_t m) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Create Silent Payments label tweak and label.
#define SECP256K1_SILENTPAYMENTS_RECIPIENT_GROUP_LIMIT
This module provides an implementation for Silent Payments, as specified in BIP352.
static void secp256k1_silentpayments_sha256_init_sharedsecret(secp256k1_sha256 *hash)
Set hash state to the BIP340 tagged hash midstate for "BIP0352/SharedSecret".
static void secp256k1_silentpayments_sha256_init_inputs(secp256k1_sha256 *hash)
Set hash state to the BIP340 tagged hash midstate for "BIP0352/Inputs".
static void secp256k1_silentpayments_sha256_init_label(secp256k1_sha256 *hash)
Set hash state to the BIP340 tagged hash midstate for "BIP0352/Label".
static void test_recipient_sort(void)
static void test_recipient_scan_label_precedes_direct_match(void)
void run_silentpayments_test_vector_receive(const struct bip352_test_vector *test, const struct bip352_receive_subtest *subtest)
static unsigned char SMALLEST_OUTPOINT[36]
static unsigned char CAROL_ADDRESS[2][33]
static unsigned char BOB_OUTPUT[32]
static const struct tf_test_entry tests_silentpayments[]
const unsigned char * label_lookup(const unsigned char *key, const void *cache_ptr)
static unsigned char BOB_ADDRESS[2][33]
static unsigned char ALICE_SECKEY[32]
static void test_label_api(void)
void run_silentpayments_test_vectors(void)
static void test_recipient_api(void)
static unsigned char CAROL_OUTPUT_TWO[32]
static unsigned char MALFORMED_SECKEY[32]
Constants.
static unsigned char CAROL_OUTPUT_ONE[32]
void run_silentpayments_test_vector_send(const struct bip352_test_vector *test)
static void test_send_api(void)
static void test_recipient_sort_helper(unsigned char(*sp_addresses[3])[2][33], unsigned char(*sp_outputs[3])[32])
static void silentpayments_sha256_tag_test(void)
static const struct bip352_test_vector bip352_test_vectors[SECP256K1_SILENTPAYMENTS_NUMBER_TESTVECTORS]
#define MAX_OUTPUTS_PER_TEST_CASE
#define MAX_INPUTS_PER_TEST_CASE
unsigned char found_output_pubkeys[MAX_OUTPUTS_PER_TEST_CASE][32]
unsigned char to_scan_outputs[MAX_OUTPUTS_PER_TEST_CASE][32]
unsigned char scan_seckey[32]
unsigned char found_seckey_tweaks[MAX_OUTPUTS_PER_TEST_CASE][32]
unsigned char spend_seckey[32]
size_t num_to_scan_outputs
unsigned int label_integers[MAX_LABELS_PER_TEST_CASE]
unsigned char found_signatures[MAX_OUTPUTS_PER_TEST_CASE][64]
size_t num_found_output_pubkeys
unsigned char scan_pubkey[33]
unsigned char spend_pubkey[33]
size_t num_recipient_entries
struct bip352_receive_subtest receive_subtests[MAX_RECEIVE_SUBTESTS]
size_t num_receive_subtests
unsigned char recipient_outputs[MAX_PERMUTATIONS_PER_SENDING_TEST_CASE][MAX_OUTPUTS_PER_TEST_CASE][32]
unsigned char xonly_pubkeys[MAX_INPUTS_PER_TEST_CASE][32]
unsigned char outpoint_smallest[36]
size_t num_recipient_outputs
unsigned char plain_pubkeys[MAX_INPUTS_PER_TEST_CASE][33]
unsigned char plain_seckeys[MAX_INPUTS_PER_TEST_CASE][32]
unsigned char taproot_seckeys[MAX_INPUTS_PER_TEST_CASE][32]
size_t num_taproot_inputs
struct bip352_recipient_addressdata recipient_pubkeys[MAX_RECIPIENT_ENTRIES_PER_TEST_CASE]
unsigned char label_tweak[32]
struct label_cache_entry entries[5]
secp256k1_callback error_callback
secp256k1_hash_ctx hash_ctx
Opaque data structure that holds a keypair consisting of a secret and a public key.
Opaque data structure that holds a parsed and valid public key.
Opaque data structure that holds a Silent Payments label.
Opaque data structure that holds Silent Payments prevouts summary data.
The data from a single recipient address.
secp256k1_pubkey scan_pubkey
secp256k1_pubkey spend_pubkey
Opaque data structure that holds a parsed and valid "x-only" public key.
static void counting_callback_fn(const char *str, void *data)
static void test_sha256_tag_midstate(const secp256k1_hash_ctx *hash_ctx, secp256k1_sha256 *sha_tagged, const unsigned char *tag, size_t taglen)
#define CHECK_ILLEGAL(ctx, expr)
static secp256k1_context * CTX
static secp256k1_context * STATIC_CTX
static const unsigned char secp256k1_group_order_bytes[32]