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];
272 memset(&taproot.
data[0], 0, 32);
286 unsigned char const *p2[2];
304 memset(&r[1].spend_pubkey, 0,
sizeof(r[1].spend_pubkey));
312 memset(&r[1].scan_pubkey, 0,
sizeof(r[1].scan_pubkey));
320 unsigned char malformed_spend_key[32] = {
321 0x83, 0xe1, 0x79, 0xdf, 0x51, 0xbb, 0xc9, 0x6f,
322 0xfb, 0x59, 0xb6, 0x2e, 0x57, 0xcf, 0x4e, 0x54,
323 0x71, 0x79, 0x04, 0x9c, 0x01, 0x47, 0x00, 0xfe,
324 0x52, 0xef, 0x5f, 0x53, 0x76, 0x39, 0xec, 0xe0
330 for (i = 0; i < 2; i++) {
344 size_t test_num_recipients;
346 for (i = 0; i < total_recipients; i++) {
352 recipients[i].
index = i;
353 recipients_ptrs[i] = &recipients[i];
354 outputs_ptrs[i] = &outputs[i];
368 for (i = 0; i < total_recipients; i++) {
371 unsigned char tweak[32] = {0};
375 test_num_recipients = total_recipients;
380 for (i = 0; i < total_recipients; i++) {
381 recipients_ptrs[i] = &recipients[i];
385 test_num_recipients = total_recipients;
391 free(recipients_ptrs);
399 unsigned char lt[32];
400 unsigned char label_ser[33];
401 const unsigned char expected[33] = {
402 0x03, 0xdc, 0x7f, 0x09, 0x9a, 0xbe, 0x95, 0x7a,
403 0x58, 0x43, 0xd2, 0xb6, 0xbb, 0x35, 0x79, 0x61,
404 0x5c, 0x60, 0x36, 0xa4, 0x9b, 0x86, 0xf4, 0xbe,
405 0x46, 0x38, 0x60, 0x28, 0xa8, 0x1a, 0x77, 0xd4,
419 unsigned char parsed_label_ser[33];
420 static const unsigned char invalid_label_ser[33] = {0};
450 unsigned char neg_spend_label_ser[33];
460 memset(&
s, 0,
sizeof(
s));
464 memset(&l, 0,
sizeof(l));
468 memset(&
s, 0,
sizeof(
s));
486 memset(&malformed_p, 0,
sizeof(malformed_p));
487 memset(&malformed_t, 0,
sizeof(malformed_t));
500 pp_sum_zero[1] = &neg_p;
502 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
508 pp[0] = &malformed_p;
512 tp[0] = &malformed_t;
521 tp[0] = original_ptr;
527 pp[0] = original_ptr;
548 unsigned char output_tweak[32] = {
549 0x96, 0x32, 0xb4, 0x06, 0xeb, 0x56, 0xcc, 0xb2,
550 0x0f, 0xc6, 0xe5, 0x2c, 0x41, 0xd5, 0x73, 0xb2,
551 0xae, 0xa0, 0x45, 0x07, 0x63, 0xf1, 0xf6, 0x22,
552 0xfa, 0x87, 0xc2, 0x4c, 0x7d, 0x80, 0x58, 0x62,
561 unsigned char output_tweak[32] = {
562 0x96, 0x32, 0xb4, 0x06, 0xeb, 0x56, 0xcc, 0xb2,
563 0x0f, 0xc6, 0xe5, 0x2c, 0x41, 0xd5, 0x73, 0xb2,
564 0xae, 0xa0, 0x45, 0x07, 0x63, 0xf1, 0xf6, 0x22,
565 0xfa, 0x87, 0xc2, 0x4c, 0x7d, 0x80, 0x58, 0x62,
567 static const unsigned char zero[32] = {0};
575 output_xonly_ptrs[0] = &output_xonly;
585 CHECK(fp[0]->found_with_label == 1);
587 unsigned char found_label_ser[33];
603 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
604 fp[0] = original_ptr;
609 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
610 tp[0] = original_ptr;
613 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, NULL, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
614 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, NULL, tp, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
615 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, NULL, 1,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
616 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1, NULL, &ps, &p, &
label_lookup, &
labels_cache));
617 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, NULL, &p, &
label_lookup, &
labels_cache));
618 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, NULL, &
label_lookup, &
labels_cache));
619 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 0,
ALICE_SECKEY, &ps, &p, &
label_lookup, &
labels_cache));
620 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, &
labels_cache));
623 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &malformed_p, NULL, NULL));
625 memset(&ps, 0,
sizeof(ps));
626 CHECK_ILLEGAL(
CTX,
secp256k1_silentpayments_recipient_scan_outputs(
CTX, fp, &n_f, tp, 1,
ALICE_SECKEY, &ps, &p, NULL, NULL));
630 static const unsigned char sender_seckey[32] = { 1 };
631 static const unsigned char scan_seckey[32] = { 2 };
632 static const unsigned char spend_seckey[32] = { 3 };
633 secp256k1_pubkey sender_pubkey, scan_pubkey, unlabeled_spend_pubkey, labeled_spend_pubkey;
635 const unsigned char *sender_seckeys[1];
646 unsigned char found_label[33];
647 uint32_t n_found_outputs;
652 prevout_pubkeys[0] = &sender_pubkey;
653 sender_seckeys[0] = sender_seckey;
657 memset(&cache, 0,
sizeof(cache));
663 CTX, &labeled_spend_pubkey, &unlabeled_spend_pubkey, &label));
668 recipients[0] = &recipient;
670 generated_outputs[0] = &labeled_output;
674 generated_outputs[0] = &direct_output;
679 tx_outputs[0] = &labeled_output;
680 tx_outputs[1] = &direct_output;
681 found_outputs[0] = &found_output[0];
682 found_outputs[1] = &found_output[1];
684 CTX, found_outputs, &n_found_outputs, tx_outputs, 2, scan_seckey, &prevouts_summary,
686 CHECK(n_found_outputs == 1);
688 CHECK(found_output[0].found_with_label);
701 unsigned char created_output[32];
715 recipients[j].
index = j;
716 recipient_ptrs[j] = &recipients[j];
717 generated_output_ptrs[j] = &generated_outputs[j];
727 keypair_ptrs[i] = &keypairs[i];
733 generated_output_ptrs,
754 size_t n_matches = 0;
787 uint32_t n_found = 0;
788 unsigned char found_output[32];
795 pubkeys[i] = &pubkeys_objs[i];
799 xonly_pubkeys[i] = &xonly_pubkeys_objs[i];
823 tx_outputs[i] = &tx_output_objs[i];
824 found_outputs[i] = &found_output_objs[i];
841 found_outputs, &n_found,
845 &recipient_spend_pubkey,
850#ifdef ENABLE_MODULE_SCHNORRSIG
853 static unsigned char MSG32[32] = {
854 0xab,0x53,0x0a,0x13,0xe4,0x59,0x14,0x98,
855 0x2b,0x79,0xf9,0xb7,0xe3,0xfb,0xa9,0x94,
856 0xcf,0xd1,0xf3,0xfb,0x22,0xf7,0x1c,0xea,
857 0x1a,0xfb,0xf0,0x2b,0x46,0x0c,0x6d,0x1d
860 static unsigned char AUX32[32] = {
861 0x0b,0x3f,0xdd,0xfd,0x67,0xbf,0x76,0xae,
862 0x76,0x39,0xee,0x73,0x5b,0x70,0xff,0x15,
863 0x83,0xfd,0x92,0x48,0xc0,0x57,0xd2,0x86,
864 0x07,0xa2,0x15,0xf4,0x0b,0x0a,0x3e,0xcc
866 for (i = 0; i < n_found; i++) {
867 unsigned char full_seckey[32];
869 unsigned char signature[64];
874 memcpy(found_signatures[i], signature, 64);
878 for (i = 0; i < n_found; i++) {
884#ifdef ENABLE_MODULE_SCHNORRSIG
895 CHECK(!found_outputs[i]->found_with_label);
896 }
else if (found_outputs[i]->found_with_label) {
901 unsigned char found_label_ser[33];
902 const unsigned char *found_label_tweak;
905 CHECK(found_label_tweak != NULL);
916 static const unsigned char tag[] = {
'B',
'I',
'P',
'0',
'3',
'5',
'2',
'/',
'I',
'n',
'p',
'u',
't',
's'};
922 static const unsigned char tag[] = {
'B',
'I',
'P',
'0',
'3',
'5',
'2',
'/',
'S',
'h',
'a',
'r',
'e',
'd',
'S',
'e',
'c',
'r',
'e',
't'};
928 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]