Skip to content
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

Upgrade secp dependency #2098

Merged
merged 3 commits into from Oct 12, 2023
Merged

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Oct 2, 2023

Upgrade the secp256k1 dependency to the newly released v0.28.0.

FTR this includes two simple changes:

  • Use Message::from_digest_slice instead of Message::from_slice.
  • Use secp256k1::Keypair instead of secp256k1::KeyPair.

But to stay in line with the keypair change we deprecate and rename the tweaked alias.

In preparation for updating the secp dependency to v0.28.0, which
includes a change of `KeyPair` to `Keypair`, change our identifier usage
to indicate that "keypair" is a single word.

Deprecate the old forms.
Upgrade the `secp256k1` dependency to the newly released `v0.28.0`.

FTR this includes two simple changes:
- Use `Message::from_digest_slice` instead of `Message::from_slice`.
- Use `secp256k1::Keypair` instead of `secp256k1::KeyPair`.
@tcharding tcharding marked this pull request as ready for review October 9, 2023 23:05
@tcharding
Copy link
Member Author

Do you happen to be online at the moment @clarkmoody? We are psyched to get an v0.31.0-rc1 release out today and it needs this PR - no pressure :)

apoelstra
apoelstra previously approved these changes Oct 9, 2023
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6f30ac9

Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just comments so fell free to ignore 😸

Comment on lines +514 to +520
/// Untweaked BIP-340 key pair
pub type UntweakedKeypair = Keypair;

/// Tweaked BIP-340 key pair
#[deprecated(since = "0.31.0", note = "use TweakedKeypair instead")]
#[allow(deprecated)]
pub type TweakedKeyPair = TweakedKeypair;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My 2sats here from a person that does not like type alias are: what is the reason for re-aliasing this type?

Rust docs do not do a really good job of putting documentation on the re-alias type so due to this is not doing really anything it is possible to re-evaluate the type alias here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to re-alias it so that we don't break compilation for people using the existing type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to re-alias it so that we don't break compilation for people using the existing type.

well, we are already breaking people from time to time :) but I see your point

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are trying to minimize or eliminate this. Sometimes it's not possible. But in the case of pure renames of structs or functions, it definitely is possible :).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, my point was just that we are deprecating the value and not removing it. So maybe we can redirect the user directly to the secp type without alias if also others fine this realising confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @vincenzopalazzo, appreciate your input. I had play with this and rendered the docs with various comments on it. The alias does show up with a link to the original type and the deprecation is handled in a clear way also. I think this is ok.

FTR we remove deprecated stuff in the next release or two so this won't be here for long. (I think our policy is deprecate for one release cycle but I may be wrong, it might be two?).

@@ -407,7 +407,8 @@ impl Psbt {
let sighash = cache.legacy_signature_hash(input_index, spk, hash_ty.to_u32())?;
// TODO: After upgrade of secp change this to Message::from_digest(sighash.to_byte_array()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not get the meaning of this TODO, maybe is outdated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we address it now that we have a rust-secp release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, crazy that I missed this, it literally shows up in the diff of the upgrade. Added as a new additional patch.

We have a new API function available with recent version of `secp256k1`
to create a `Message` directly from a sighash byte array.

Use `Message::from_digest(sighash.to_byte_array())` to construct
messages ready to sign.
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 678eee8

@tcharding
Copy link
Member Author

Legend, thanks @vincenzopalazzo

@tcharding tcharding added the P-high High priority label Oct 11, 2023
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 678eee8

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 678eee8.

At a later point, we should also provide From impls from Various sighash types into Message.

@sanket1729 sanket1729 merged commit d67590e into rust-bitcoin:master Oct 12, 2023
29 checks passed
@tcharding
Copy link
Member Author

ACK 678eee8.

At a later point, we should also provide From impls from Various sighash types into Message.

Nice idea, I put it on my simple-afternoon-tasks TODO list.

@tcharding tcharding deleted the 10-02-upgrade-secp branch October 13, 2023 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants