Bitcoin

python – How can I adjust my private key in Bitcoin Core?

I’ve done a few Bitcoin Taproot workshops and am starting to figure out what’s going on, but I can’t find anywhere to do the same thing in the Python library with Bitcoin Core that the workshops provide.

I think you need to be clearer about what you want to achieve. If you’d like to dive a little deeper in Python for educational purposes, there’s Taproot code in Python in Bitcoin Core Functional Testing. However, it is not set up as a standalone library that can be interacted with. A Python library with Taproot support (and MuSig2 support) is buidl-python. Other Python libraries such as python-bitcoinlib, ofek’s bit, and darosior’s python-bip380 unfortunately do not support Taproot at the time of this writing (May 2023).

Will Bitcoin Core benefit from this added functionality? Are there any commands for further tweaking, configuring Tapleaf in CSA, hash locking, delaying CSA hash locking, and configuring Tapscript appropriately?

Bitcoin Core, a full node implementation, already supports all Taproot spend confirmations in C++. Bitcoin Core wallet supports Taproot through: tr() The descriptor has been rewritten in C++. OP_CHECKSIGADD(CSA) is supported through: multi_a and sortedmulti_a descriptor within tr() explainer. Hashlocks are not supported at the time of this writing (May 2023). tr() There is a descriptor, but there is a PR release (PR 27255) that adds a Taproot’d Miniscript to the Bitcoin Core wallet to enable it.

I can create a new address, but how do I adjust it using a tab script?

A note on terminology. Adjusting the internal public key will not adjust the address. How to adjust the internal public key is explained in the Bitcoin Optech Taproot workshop here.

I’m also wary about generating my own keys, as the workshop specifically says not to do so. “It has poor randomness and no side-channel protection.” To quote loosely.

For now, it looks like I’ll have to implement these features in a separate Python library, calling bindings to the secp256k1 lib for safe randomness.

If you use Seal or Testnet coins, you don’t have to worry about false randomness and potential coin loss. However, be aware of the randomness of the seed. The private key is not generated from secp256k1, but from the default Core store (random.cpp).

Related Articles

Back to top button