-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add BIP352 module (take 3) #1698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
josibake
wants to merge
12
commits into
bitcoin-core:master
from
josibake:bip352-silentpayments-module-2025
Closed
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bb2c5bf
build: add skeleton for new silentpayments (BIP352) module
theStack 6fe3a7a
silentpayments: sending
josibake 28917fa
silentpayments: recipient label support
theStack 55dce8c
silentpayments: receiving
josibake 14b1bf0
silentpayments: light client scanning
josibake a0b77dc
silentpayments: add examples/silentpayments.c
josibake 9c6d949
silentpayments: add benchmarks for scanning
josibake e759094
tests: add BIP-352 test vectors
josibake 568e3ae
tests: add constant time tests
josibake c7d3827
tests: add sha256 tag test
josibake 29bf593
ci: enable silentpayments module
theStack a0d2a33
docs: update README
josibake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -761,4 +761,37 @@ int secp256k1_silentpayments_recipient_scan_outputs( | |
| return 1; | ||
| } | ||
|
|
||
| int secp256k1_silentpayments_recipient_create_output_pubkeys(const secp256k1_context *ctx, secp256k1_xonly_pubkey **outputs_xonly, const unsigned char *scan_key32, const secp256k1_silentpayments_prevouts_summary *prevouts_summary, const secp256k1_pubkey **spend_pubkeys, size_t n_spend_pubkeys) | ||
| { | ||
| secp256k1_scalar scan_key_scalar; | ||
| secp256k1_ge input_pubkey_ge; | ||
| int combined, valid_scan_key; | ||
| unsigned char shared_secret[33]; | ||
|
|
||
| VERIFY_CHECK(ctx != NULL); | ||
| ARG_CHECK(outputs_xonly != NULL); | ||
| ARG_CHECK(scan_key32 != NULL); | ||
| ARG_CHECK(prevouts_summary != NULL); | ||
| ARG_CHECK(spend_pubkeys != NULL); | ||
| ARG_CHECK(n_spend_pubkeys > 0); | ||
| ARG_CHECK(secp256k1_memcmp_var(&prevouts_summary->data[0], secp256k1_silentpayments_prevouts_summary_magic, 4) == 0); | ||
| /* If there are any issues with the recipient scan key, return early. */ | ||
| valid_scan_key = secp256k1_scalar_set_b32_seckey(&scan_key_scalar, scan_key32); | ||
| secp256k1_declassify(ctx, &valid_scan_key, sizeof(valid_scan_key)); | ||
| if (!valid_scan_key) { | ||
| secp256k1_scalar_clear(&scan_key_scalar); | ||
| return 0; | ||
| } | ||
| secp256k1_ge_from_bytes(&input_pubkey_ge, &prevouts_summary->data[5]); | ||
| combined = (int)prevouts_summary->data[4]; | ||
| if (!combined) { | ||
| secp256k1_scalar input_hash_scalar; | ||
| secp256k1_scalar_set_b32(&input_hash_scalar, &prevouts_summary->data[5 + 64], NULL); | ||
| secp256k1_scalar_mul(&scan_key_scalar, &scan_key_scalar, &input_hash_scalar); | ||
| } | ||
| secp256k1_silentpayments_create_shared_secret(ctx, shared_secret, &input_pubkey_ge, &scan_key_scalar); | ||
| secp256k1_scalar_clear(&scan_key_scalar); | ||
| return secp256k1_silentpayments_create_output_pubkeys(ctx, outputs_xonly, shared_secret, spend_pubkeys, n_spend_pubkeys, 0); | ||
|
Comment on lines
+793
to
+794
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in _recipient_create_output_pubkeys: should also clear out the |
||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for this to not be
const secp256k1_pubkey * const *spend_pubkeys? like_pubkeysin_silentpayments_recipient_prevouts_summary_createor_seckeysin_silentpayments_sender_create_outputsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,
outputs_xonlyis the out-param where we will write the generated xonly public keys. This is the same asfound_outputsin the scanning function andgenerated_outputsin the_create_outputsfunction.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we referring to the same line? I was talking about line 421:
const secp256k1_pubkey **spend_pubkeys.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed a word in the original comment. I edited it. tldr:
Why not
const secp256k1_pubkey **spend_pubkeys->const secp256k1_pubkey * const *spend_pubkeys?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha! Sorry, I misunderstood your original comment. This should be
const secp256k1_pubkey * const *spend_pubkeys, as you suggest.