24 0x16, 0x9e, 0x1e, 0x83, 0xe9, 0x30, 0x85, 0x33, 0x91,
25 0xbc, 0x6f, 0x35, 0xf6, 0x05, 0xc6, 0x75, 0x4c, 0xfe,
26 0xad, 0x57, 0xcf, 0x83, 0x87, 0x63, 0x9d, 0x3b, 0x40,
27 0x96, 0xc5, 0x4f, 0x18, 0xf4, 0x00, 0x00, 0x00, 0x00
30 0xa8, 0x90, 0x54, 0xc9, 0x5b, 0xe3, 0xc3, 0x01,
31 0x56, 0x65, 0x74, 0xf2, 0xaa, 0x93, 0xad, 0xe0,
32 0x51, 0x85, 0x09, 0x03, 0xa6, 0x9c, 0xbd, 0xd1,
33 0xd4, 0x7e, 0xae, 0x26, 0x3d, 0x7b, 0xc0, 0x31
36 0x9d, 0x6a, 0xd8, 0x55, 0xce, 0x34, 0x17, 0xef,
37 0x84, 0xe8, 0x36, 0x89, 0x2e, 0x5a, 0x56, 0x39,
38 0x2b, 0xfb, 0xa0, 0x5f, 0xa5, 0xd9, 0x7c, 0xce,
39 0xa3, 0x0e, 0x26, 0x6f, 0x54, 0x0e, 0x08, 0xb3
43 0x02, 0x15, 0x40, 0xae, 0xa8, 0x97, 0x54, 0x7a,
44 0xd4, 0x39, 0xb4, 0xe0, 0xf6, 0x09, 0xe5, 0xf0,
45 0xfa, 0x63, 0xde, 0x89, 0xab, 0x11, 0xed, 0xe3,
46 0x1e, 0x8c, 0xde, 0x4b, 0xe2, 0x19, 0x42, 0x5f, 0x23
49 0x02, 0x5c, 0xc9, 0x85, 0x6d, 0x6f, 0x83, 0x75,
50 0x35, 0x0e, 0x12, 0x39, 0x78, 0xda, 0xac, 0x20,
51 0x0c, 0x26, 0x0c, 0xb5, 0xb5, 0xae, 0x83, 0x10,
52 0x6c, 0xab, 0x90, 0x48, 0x4d, 0xcd, 0x8f, 0xcf, 0x36
56 0x04, 0xb2, 0xa4, 0x11, 0x63, 0x5c, 0x09, 0x77,
57 0x59, 0xaa, 0xcd, 0x0f, 0x00, 0x5a, 0x4c, 0x82,
58 0xc8, 0xc9, 0x28, 0x62, 0xc6, 0xfc, 0x28, 0x4b,
59 0x80, 0xb8, 0xef, 0xeb, 0xc2, 0x0c, 0x3d, 0x17
63 0x03, 0xbb, 0xc6, 0x3f, 0x12, 0x74, 0x5d, 0x3b,
64 0x9e, 0x9d, 0x24, 0xc6, 0xcd, 0x7a, 0x1e, 0xfe,
65 0xba, 0xd0, 0xa7, 0xf4, 0x69, 0x23, 0x2f, 0xbe,
66 0xcf, 0x31, 0xfb, 0xa7, 0xb4, 0xf7, 0xdd, 0xed, 0xa8
69 0x03, 0x81, 0xeb, 0x9a, 0x9a, 0x9e, 0xc7, 0x39,
70 0xd5, 0x27, 0xc1, 0x63, 0x1b, 0x31, 0xb4, 0x21,
71 0x56, 0x6f, 0x5c, 0x2a, 0x47, 0xb4, 0xab, 0x5b,
72 0x1f, 0x6a, 0x68, 0x6d, 0xfb, 0x68, 0xea, 0xb7, 0x16
102 const unsigned char* label33,
103 const void* cache_ptr
108 if (memcmp(cache->
entries[i].
label, label33, 33) == 0) {
116 unsigned char randomize[32];
117 unsigned char serialized_xonly[32];
127 unsigned char bob_address[2][33];
130 uint32_t n_found_outputs;
135 printf(
"Failed to generate randomness\n");
146 tx_input_ptrs[i] = &tx_inputs[i];
149 tx_output_ptrs[i] = &tx_outputs[i];
150 found_output_ptrs[i] = &found_outputs[i];
164 &unlabeled_spend_pubkey,
181 printf(
"Something went wrong, event with negligible probability happened.\n");
192 printf(
"Something went wrong, event with negligible probability happened.\n");
199 &labeled_spend_pubkey,
212 unsigned char (*sp_addresses[
N_OUTPUTS])[2][33];
213 unsigned char seckey[32];
233 printf(
"Failed to generate randomness\n");
239 sender_keypair_ptrs[i] = &sender_keypairs[i];
248 printf(
"Failed to create keypair\n");
263 sp_addresses[1] = &bob_address;
267 &recipients[i].scan_pubkey,
268 (*(sp_addresses[i]))[0],
272 &recipients[i].spend_pubkey,
273 (*(sp_addresses[i]))[1],
277 printf(
"Something went wrong, this is not a valid Silent Payments address.\n");
287 recipients[i].
index = i;
288 recipient_ptrs[i] = &recipients[i];
298 printf(
"Something went wrong, a recipient provided an invalid address.\n");
301 printf(
"Alice created the following outputs for Bob and Carol:\n");
309 print_hex(serialized_xonly,
sizeof(serialized_xonly));
321 secure_erase(&sender_keypairs[i],
sizeof(sender_keypairs[i]));
346 printf(
"This transaction is not valid for Silent Payments, skipping.\n");
353 found_output_ptrs, &n_found_outputs,
357 &unlabeled_spend_pubkey,
361 printf(
"This transaction is not valid for Silent Payments, skipping.\n");
364 if (n_found_outputs > 0) {
367 unsigned char full_seckey[32];
370 printf(
"Bob found the following outputs: \n");
371 for (i = 0; i < n_found_outputs; i++) {
375 &found_outputs[i].output
378 print_hex(serialized_xonly,
sizeof(serialized_xonly));
413 printf(
"Bob did not find any outputs in this transaction.\n");
422 &unlabeled_spend_pubkey,
430 found_output_ptrs, &n_found_outputs,
434 &unlabeled_spend_pubkey,
438 printf(
"This transaction is not valid for Silent Payments, skipping.\n");
441 if (n_found_outputs > 0) {
446 printf(
"Carol found the following outputs: \n");
447 for (i = 0; i < n_found_outputs; i++) {
451 &found_outputs[i].output
454 print_hex(serialized_xonly,
sizeof(serialized_xonly));
457 printf(
"Carol did not find any outputs in this transaction.\n");
static int fill_random(unsigned char *data, size_t size)
static void secure_erase(void *ptr, size_t len)
static void print_hex(unsigned char *data, size_t size)
static int tweak(const secp256k1_context *ctx, secp256k1_xonly_pubkey *agg_pk, secp256k1_musig_keyagg_cache *cache)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 context object (created in dynamically allocated memory).
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
Randomizes the context to provide enhanced protection against side-channel leakage.
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 secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
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
Context flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size,...
#define SECP256K1_EC_COMPRESSED
Flag to pass to secp256k1_ec_pubkey_serialize.
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_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_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.
static unsigned char bob_spend_key[32]
static unsigned char bob_scan_key[32]
static unsigned char smallest_outpoint[36]
const unsigned char * label_lookup(const unsigned char *label33, const void *cache_ptr)
static unsigned char bob_scan_and_spend_pubkeys[2][33]
static unsigned char carol_scan_key[32]
static unsigned char carol_address[2][33]
unsigned char label_tweak[32]
struct label_cache_entry entries[5]
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.
Opaque data structure that holds a parsed and valid "x-only" public key.