rust-bitcoin / rust-secp256k1

Rust language bindings for Bitcoin secp256k1 library.
Creative Commons Zero v1.0 Universal
347 stars 266 forks source link

Make the signing API use `Into<Message>` #700

Closed tcharding closed 1 week ago

tcharding commented 5 months ago

See https://github.com/rust-bitcoin/rust-bitcoin/issues/2821#issuecomment-2143050338

apoelstra commented 5 months ago

Moved from rust-bitcoin to rust-secp. The rust-secp signing methods, which are all agnostic to what they are signing, should take an Into<Message>.

I took a quick look at the rust-bitcoin signing methods (Psbt::sign was the only one that jumped out at me) and they sign specific things and should presumably take specific types.

liamaharon commented 2 weeks ago

A consequence of this is that the signing methods will require ownership of msg, whereas prior message could be passed as a ref. Is that OK?

apoelstra commented 2 weeks ago

Good catch. Yes, I think this is fine. Messages are 32-byte objects which is small enough that we want to pass them by value anyway.

We should maybe encourage implementors in the docs to make sure that their Into<Message> types are also Copy.