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

Add method to arbitrary msg using bip322 #184

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

KonradStaniec
Copy link
Collaborator

@KonradStaniec KonradStaniec commented Jul 17, 2024

ref: https://github.com/babylonchain/pm/issues/48

One of the places where staker program dumps private key is when creating pop for Babylon:

pop, err := app.generatePop(stakerPrivKey)

To remove DumPrivateKey function pop needs to be created in some other way.

Unfortunately, we cannot use https://developer.bitcoin.org/reference/rpc/signmessage.html bitcoind api as this does not work for native segwit addresses (only legacy ones which should be avoided) . See: bitcoin/bitcoin#10542

Fortunately, Babylon supports pop with bip322 signatures. This pr add necessary api to create such signature along with the test. Followup pr will switch creating pop to this functions

Copy link
Contributor

@RafilxTenfen RafilxTenfen left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Copy link
Contributor

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Great work!

}

if !txscript.IsPayToWitnessPubKeyHash(toSpend.TxOut[0].PkScript) {
return nil, fmt.Errorf("")
Copy link
Contributor

Choose a reason for hiding this comment

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

empty error?

// To work properly:
// - wallet must be unlocked
// - address must be under wallet control
// - address must be native segwit address
Copy link
Contributor

Choose a reason for hiding this comment

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

Our system should also support taproot address, right? How can we deal with that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so for now, from what I understand, we cannot support them now as we are forced to use old version of bitcoind with legacy wallets. This is due to using DumpPrivateKey operation which is unsupported in later version.

So the road to support bip86 taproot addresses would be:

  1. remove DumpPrivateKey
  2. bump bitcoind to latest versions (v26+)
  3. start experimenting how to add support for those addresses

One note though, this is not super criticial as:

  • native segwit addresses are most popular ones
  • in my mind staker progam in the future will by default generate new address for new staking operation (new public key) and default generated address by getnewaddress function is native segwit one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added issue to track this: #185

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation! It makes sense

@KonradStaniec KonradStaniec merged commit 6b67265 into dev Jul 18, 2024
2 checks passed
@KonradStaniec KonradStaniec deleted the add-bip322-native-segwit-signature branch July 18, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants