rust-bitcoin / rust-secp256k1

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

Allow infallible construction of `Signature` #730

Closed yukibtc closed 2 months ago

yukibtc commented 2 months ago

Hi! This PR add 1 constructor and 2 methods to Signature struct:

Kixunil commented 2 months ago

Also the title is misleading since this is not what "zero copy" means. "Zero copy" is just a stupid name for "zero heap allocations" and the original code didn't do any heap allocations in the first place. Further, in hashes we use from_byte_array for array-accepting constructors.

What I believe is non-controversial about this PR: we want some infallible method that accepts an array. I wanted to suggest you to make just that change first but then I remembered about from_byte_array thing.

apoelstra commented 2 months ago

Neat! Concept ACK.

I would like to use to_byte_array and from_byte_array to be consistent with hashes. (I have proposed the same thing for SecretKey in #724.)

yukibtc commented 2 months ago

Also the title is misleading since this is not what "zero copy" means. "Zero copy" is just a stupid name for "zero heap allocations" and the original code didn't do any heap allocations in the first place

Ahh, thanks for the clarification


I've done the changes as suggested.