-
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
Implement lexigraphic ordering for PubKey #248
Conversation
I expect this won't compile on Rust 1.29. I think using |
Tests pass on 1.29 on my machine:
I see a Travis check here that's not "completed yet". Is this broken? |
Yeah, CI seems pretty broken :( |
Travis says "Abuse detected" https://travis-ci.org/github/rust-bitcoin/rust-secp256k1/requests This is pretty stupid, let's just switch to github actions. |
Once we get #250 in you'll need to rebase and then we'll be rid of Travis once and for all. |
I think this could break existing code. I don't think it will but we can't know for sure. |
Should we also implement PartialEq in terms of the serialized key? (I remember talking on #secp256k1 if we allow users to assume secp256k1_* objects are comparable or not, I don't remember the answer though hehe) |
@elichai any such existing code was already buggy because it was violating the contract for the upstream public key type |
@elichai as for PartialEq ... it is true that the contract says we're not allowed to compare based on the underlying, so morally we should fix this. But it's also true that in our particular vendored version, comparing equality based or serialize will give identical results to comparing based on the underlying representation. So I guess, I'm indifferent. |
We could ask upstream to give us an equality function. |
@sipa informs me in bitcoin-core/secp256k1#850 (comment) that this PR is incorrect for |
See https://github.com/bitcoin/bitcoin/blob/v0.20.1/src/script/descriptor.cpp#L679. |
@justinmoon can you try force-pushing this and see if that makes CI move? |
I think we should get this PR in even if it doesn't match Core. Our current |
@apoelstra Done |
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.
lets do it
@apoelstra We can implement |
Yep. We should be sure to do both, because it's a footgun to use this |
While implementing a feature in rust-miniscript I ran into surprising behavior with public key ordering in rust-bitcoin. I would expect pubkeys to be lexigraphically ordered by compressed serialization (used by BIP 67), but instead it was based on the internal 64-byte libsecp256k1 representation.
@apoelstra mentioned he was in favor of changing this so I attempted to implement it.