-
Notifications
You must be signed in to change notification settings - Fork 271
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
Change context objects for verification methods #342
Conversation
Can we use preallocated context with all methods used by taproot tweaks? This will significantly simplify the API on the layers above for creating and working with taproot... |
Yes. Even though in recent secp256k1 revisions, the verification context flag is ignored. It doesn't make it a difference, and it will likely be removed in the future.
Why should
Why should |
Unfortunately, all methods are restricted by a type system that requires context to be either Ideally, we want to provide a None context for these methods, but it is not currently supported in rust-secp, and supporting might not be worth it given everything would be static soon. |
Oh it is! We have Line 143 in 48683d8
Not directly related to this PR but note that even with all precomputation being static, we'll still have (real) Signing contexts because they hold randomness for blinding secret key operations. So we wouldn't get rid of the context entirely for now, though we have the global_context feature. edit: |
concept ack just ran into this! |
does signing context generate entropy on creation? testing now but this may be a big issue for using verification from a WASM module with no entropy because the get random number methods may panic. |
For manually generated contexts, this happens only if you randomize them explicitly, see Lines 354 to 380 in 48683d8
For the global context, it depends on the enabled feature: The |
I don't this is exposed at rust-secp level, only that at the sys level. See: https://docs.rs/secp256k1/0.20.3/secp256k1/trait.Context.html#implementors Since the context does not matter (ideally we would want None, but it is unsupported), and we must have one of the implementors of the Context trait. It makes sense to have Verification for cleaner implementation downstream.
Indeed, the current implementation has a Signing + Verification on this. |
The idea is that you can make any rust-secp API function which does not need a special context take no context and under the hood use
Why is it not supported? You can just pass no context.
Why should it be cleaner to require a Sorry, I may be terribly wrong and overlooking something but then please explain. :D I feel we're just talking past each other. |
IMO converting a KeyPair to a Publickey is somewhat similiar to serializing a PublicKey, which uses |
We used to have a Edit: Oh, Tim brought this up already. What is the status of this PR then? |
67db587
to
a8b6f30
Compare
- The current schnorrsig verify methods should operate on verify context as is done throughout the bitcoin core - Scondly, and importantly the XonlyPublicKey::from_keypair now operates without any context objects.
a8b6f30
to
21aa914
Compare
The PR has been updated so that
|
I haven't looked at it yet but Concept ACK, this seems the right thing to do. |
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.
ACK 21aa914
The incorrect context on the verify_schnorr function seems like a pretty serious bug.
7405836 Fix warning about deprecated method use (Dr Maxim Orlovsky) f39b130 CI: do not fail fast (Dr Maxim Orlovsky) f77c571 Making Script method new_* names more consistent (Dr Maxim Orlovsky) 91b68a4 Taproot-related methods for Script type (Dr Maxim Orlovsky) 599c5f9 Generalizing taproot key tweaking for KeyPairs (Dr Maxim Orlovsky) Pull request description: * Adds taproot-related methods to `Script` * Fixes API for existing taproot methods * Generalizes `TapTweak` trait to work with both public keys and key pairs ~~UPD: PR is pending rust-bitcoin/rust-secp256k1#342 ACKs for top commit: sanket1729: ACK 7405836 apoelstra: ACK 7405836 Tree-SHA512: 4a76dfffa1452baadc15e19812831ef9d2e66794c090a8fc123388d7119b2c8a1f0420ce723ad22e01683c8198711fe62e0cdf00c9ad2d2974606383baaf1cb0
as is done throughout the bitcoin core
without any context parameter.