-
Notifications
You must be signed in to change notification settings - Fork 282
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
Add as_mut_ptr to PublicKey #105
Conversation
I think we can do that. Actually we should make both |
I don't think we should use |
Okay I'm late here but couldn't you use PublicKey::from_slice() too? Some off-topic stuff:
*I say probably just because the semantics are not formalizing but people are converging into that direction. Independent of all of this, I still think we should add still |
Cool, thanks for the research! My understanding, last I checked, is that it's not UB to have uninitialized primitive integer types (though just like in C, if you try to read from them that would be UB). Essentially the compiler is allowed to assume that uninitialized memory has any legal value. Where It gets even worse with uninhabited types like But |
Also I don't understand your comment about |
Well for integer types like u8, the docs explicitly say this:
(https://doc.rust-lang.org/nightly/core/mem/union.MaybeUninit.html) As I understand, this moved only recently towards that direction. That's also why they're currently deprecating re |
Things like uninitialized bits in a
Well, rust-lang/rfcs#1892 was opened early 2017. So it's not exactly new either. But it has been moving very slowly. |
I'm working on
rust-secp256k1-zkp
and there's a function that MuSig-combines a bunch of pubkeys into a single pubkey. In principle returning the pubkey could work very similar to howfrom_secret_key
works (https://github.com/rust-bitcoin/rust-secp256k1/compare/master...jonasnick:pk_as_mut_ptr?expand=1#diff-6fb5c8f31a9b0420853a8e3f5af3e391L227). But that doesn't work because we don't have access to thePublicKey
constructor from outside the module because the inner field is private. Instead the same effect is achieved withas_mut_ptr
(jonasnick/rust-secp256k1-zkp@9428b6c#diff-21a76c1f1f03ad91cc16d9ab499374ddR44).