@@ -271,6 +271,58 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipien
271271) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 )
272272 SECP256K1_ARG_NONNULL (6 ) SECP256K1_ARG_NONNULL (7 ) SECP256K1_ARG_NONNULL (8 );
273273
274+ /** Create Silent Payment shared secret.
275+ *
276+ * Given the public input data (A_tweaked = input_hash * A_sum), calculate the shared secret using ECDH:
277+ *
278+ * shared_secret = b_scan * A_tweaked [Recipient, Light client scenario]
279+ *
280+ * The resulting shared secret is needed as input for creating silent payments
281+ * outputs belonging to the same recipient scan public key.
282+ *
283+ * Returns: 1 if shared secret creation was successful. 0 if an error occured.
284+ * Args: ctx: pointer to a context object
285+ * Out: shared_secret33: pointer to the resulting 33-byte shared secret
286+ * In: recipient_scan_key: pointer to the recipient's scan key
287+ * public_data: pointer to the input public key sum, tweaked with the input_hash
288+ * (see `_recipient_compute_public_data`)
289+ */
290+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_create_shared_secret (
291+ const secp256k1_context * ctx ,
292+ unsigned char * shared_secret33 ,
293+ const unsigned char * recipient_scan_key ,
294+ const secp256k1_silentpayments_public_data * public_data
295+ ) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 );
296+
297+ /** Create Silent Payment output public key.
298+ *
299+ * Given a shared_secret, a public key B_spend, and an output counter k,
300+ * calculate the corresponding output public key:
301+ *
302+ * P_output_xonly = B_spend + hash(shared_secret || ser_32(k)) * G
303+ *
304+ * This function is used by the recipient when scanning for outputs without access to the
305+ * transaction outputs (e.g. using BIP158 block filters).
306+ * When scanning with this function, it is the scanners responsibility to determine if the generated
307+ * output exists in a block before proceeding to the next value of `k`.
308+ *
309+ * Returns: 1 if output creation was successful. 0 if an error occured.
310+ * Args: ctx: pointer to a context object
311+ * Out: P_output_xonly: pointer to the resulting output x-only pubkey
312+ * In: shared_secret33: shared secret, derived from either sender's
313+ * or receiver's perspective with routines from above
314+ * receiver_spend_pubkey: pointer to the receiver's spend pubkey (labelled or unlabelled)
315+ * k: output counter (initially set to 0, must be incremented for each
316+ * additional output created or after each output found when scanning)
317+ */
318+ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_silentpayments_recipient_create_output_pubkey (
319+ const secp256k1_context * ctx ,
320+ secp256k1_xonly_pubkey * P_output_xonly ,
321+ const unsigned char * shared_secret33 ,
322+ const secp256k1_pubkey * receiver_spend_pubkey ,
323+ unsigned int k
324+ ) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 );
325+
274326#ifdef __cplusplus
275327}
276328#endif
0 commit comments