Introduce the primitives crate#2756
Conversation
0aab144 to
528f375
Compare
7b1c44c to
3b6a576
Compare
1624e0e to
adc8a22
Compare
|
Just to document, this was one of the crates proposed in #550. |
adc8a22 to
774a51b
Compare
|
After a nights sleep I had a new idea, add a "crypto" feature to This leaves only a single |
59e0d1b to
3e02d6c
Compare
|
Yeah, I think this is the right approach. For future reviewers: the issue is that So I guess, instead we have We would also want to re-export Feature-gating this -- which we definitely want to do, because a design goal of Then in the long term we would try to move some components out from under the feature gate. In particular I'm pretty sure we can serialize/deserialize signatures in Rust quite easily. Public keys are harder but may be worth doing. |
|
While I still think this is the right approach, and getting "make secp optional" basically for free is super awesome I realized this has one massive drawback - it means that |
|
Ok, so where does that leave us?
I guess, if all we need is serialization, that's pretty easy to implement in pure Rust. Do you think that's all we need for However, we would still want the ability to convert these to the "underlying" rust-secp types (or do we?) because sometimes users want that. We could make them do it manually by serializing and deserializing but that's pretty expensive and would have an inaccessible error path on parsing. We should benchmark it at least. Probably we need to pull this into a separate discussion thread. |
Deserialization in Rust would have to be more dumb than what it is today, when we deserialize in |
I went over the whole |
I think we can move forward with this PR and make ser/deser of crypto feature gated stuff part of "stabalize primitives". Although I have no idea how we move forward with the current reviewers. I can either:
|
It's not just validation. We decompress compressed keys. If we wanted to avoid this, it would be pretty complicated because the internal representation would then need to be an enum. |
ccc8a8f to
525cfbe
Compare
|
Let's meet at the Nashville conference and try to do it in sync. |
|
Ah good idea! |
091d614 bitcoin: Remove "std" feature from examples (Tobin C. Harding) Pull request description: The "rand-std" feature enables "std" but we use it in examples still. FTR I added this a while ago thinking the explicitness was clearer but in hindsight I think that was wrong and that it makes usage of our features _less_ clear. No logic changes. (Pulled out of #2756.) ACKs for top commit: storopoli: ACK 091d614 apoelstra: ACK 091d614 Tree-SHA512: d72eec37e3a434a1f850cb4257529fc18540cb5075bc7d3bd494cba59b08404c6c86223361a3c3a3de8d50a1168b656ff1123d28f7d2dcdf05c404caff716b1a
|
What about if we branch off at |
|
Hi @klebs6, I see your bitcoin-primitives crate has not been updated in a while. Is there any chance you would be willing please to transfer the name to us? You could re-release yours with a more project specific prefix? Thanks in advance for the consideration. |
|
This needs |
|
I took a look at the crates in
That's a win. cc @notmandatory |
I think we should branch off of In any case, I like this idea ... though it then means that we have two parallel implementations of primitives and we'd want to start cutting over ASAP to turning the |
|
Another idea, what about if I just rebase this branch haphazardly, then we can use this branch to test downstream, and also to get a state we want to achieve. Then in Nashville we freeze all merging and do the whole thing from scratch so no mistakes are introduced. |
|
Yep, that sounds good to me. |
certainly! i think i can take a look this weekend and make the transfer as we discussed before! |
|
I'm out of loop here and I just quickly scrolled through comments. I think |
|
This is tempting. I think I agree (assuming it's possible; I did a quick check to see if there were methods on The |
|
For |
|
My hope with As a first step though I think we should move everything into |
|
It seems that this |
|
Sounds good. And agreed on taking on |
|
Oh they can't be first, can be at the same time though. |
|
I might try splitting |
|
greetings! i am almost done with refactoring (and preparing for transfer) the current |
Ready! I sent ownership invitations for the crate via Earlier, I factored the contents of the previous Next, I removed the bitcoin_primitives dependency throughout the workspace and added a dependency pointing to the new crates where necessary.
|
|
Thank you!! Invitation accepted. |
|
Madness, thanks @klebs6! Note we should be careful with the version number we use for |
|
@tcharding please, let's not use |
|
Yeah, I think we should just use 0.100.0 or something. On the 5th iteration we're gonna be pretty mad at ourselves for using 1.0.0-beta.N or whatever. And that's assuming we even get the syntax right so that |
|
Fair enough. |
|
Replaced by #2883 |
The
hasheswork is closer to being done and easier to review/merge than this work, it should IMO go in first.We would like to provide a crate that is the
rust-bitcoinprimitives types, this crate should allow users (specificallyrust-miniscript) to depend solely onprimitivesand not onrust-bitcoin.The big picture is that we will then be able to invert the dependency between
miniscriptandbitcoin- makingrust-bitcointhe one-stop-shop for all things Bitcoin (in Rust).The other primary problem we are trying to solve is the upgrade friction the ecosystem feels every time we release
rust-bitcoin. Currently many downstream crates have to upgrade in sync. Withprimitiveswe hope to provide a crate that:Hence reducing some of the friction - time will tell.
Notes on
crypto/secp256k1secp256k1is required for key types. Currently we cannot provide key types in pure rust because serializing and deserializing them requires libsecp, although it is technically possible that we could do all that in pure Rust, as of today we don't and it is a non-trivial amount of work to do so.As such, the
primitivescrate has a dependency onsecp256k1, we feature gate it behind a "crypto" feature. It should be noted however that it is unlikely that there will be many users whom are able useprimitiveswithout enabling the "crypto" feature. This means that theprimitivescrate is not a silver bullet in respect to the upgrade friction mentioned above becausesecp256k1is someways off stabalizing - it does still mean that being smaller it is less likely to change. Whether we will ever manage to do arust-bitcoinrelease without aprimitivesrelease remains to be seen but there is reasonable chance.