-
Notifications
You must be signed in to change notification settings - Fork 293
Followups to #716 (add musig2 API) #794
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
Merged
apoelstra
merged 15 commits into
rust-bitcoin:master
from
apoelstra:2025-05_musig2-followups
Jun 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f5f90af
fmt: stop blacklisting secp256k1-sys; just fmt whole crate
apoelstra 07922fd
musig: fix a couple FFI bindings
apoelstra 7c56bcc
clippy: whitelist a bunch of lints
apoelstra 9615ec8
context: whitelist new compiler warning
apoelstra 4dd861f
stop using deprecated thread_rng
apoelstra 3b0232a
musig: fix all the doctests
apoelstra 00c8c75
musig: remove outdated doc references to ZeroSession error
apoelstra 6d938d3
musig: add missing Panics sections to docs
apoelstra ec66003
musig: remove SessionSecretRand::new constructor
apoelstra c492c75
key: move pubkey_sort to method on Secp256k1; rename
apoelstra dc04575
musig: a couple small improvements of byte array APIs
apoelstra ebdaec7
musig: clarify doc comment about aggregate nonce proxy
apoelstra 40a8b65
musig: explicitly panic when given an empty slice of pubkeys to aggre…
apoelstra 8a43317
musig: add a bunch of unit tests
apoelstra d611a4f
musig: weaken/simplify warnings about nonce reuse
apoelstra 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
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
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.
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.
I think it might still be UB if we're creating
&mut
rather than using raw pointers. I think we really needSyncUnsafeCell
.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.
Can we focus on #806 instead which will entirely remove this?
If you are really concerned about soundness then we can try to fold that into this upcoming release -- but all this PR does is whitelist the clippy lint. If we think the existing code is actually unsound then we should have a separate issue to track that. (But my feeling is that it's probably fine in practice so it's ok to continue with our intended removal of this code and not worry about backporting.)
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.
I suggest we look at how hard it is to replace with
SyncUnsafeCell
and if it's easy enough we replace it. Also IIRC the only sound way to use static muts is to use raw pointers to them only (obtained using raw pointer operator) withcore::ptr::*
operations.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.
"How hard it is" appears to be "impossible" since the whole
SyncUnsafeCell
API is unstable.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.
Well, we can easily write our own
struct SyncUnsafeCell<T>(UnsafeCell<T>); unsafe impl<T> Sync for UnsafeCell<T> {}
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.
Oh! I misunderstood your point -- I thought you were proposing we replace an
UnsafeCell
with aSyncUnsafeCell
(and couldn't figure out how that would make unsound code sound).Actually you're just proposing we replace no cell at all with an
UnsafeCell
, which needs to beSync
or else the compiler won't allow it in astatic
.I'm not totally convinced you're correct, but it seems easy to do and definitely won't make things worse. So we might as well try.
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.
Correct. I remembered now that the assignment calls the drop impl on
Option
which takes&mut self
so it's implicitly creating a mutable reference to a static which IIRC is UB, so I'm quite convinced we have to do this. Sure, we could rewrite it to useptr::write
instead but I think the explicitness ofUnsafeCell
beats it.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, yes, good catch.
I wonder whether we should file a bug/feature request to clippy requesting that any assignments to
static mut
types which areDrop
be linted. Since they are probably UB.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.
Moved to #820. I believe that is the last followup from this PR.