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

Chapter 2.2 update: Added commitment unsealing to 2.2.3/2.24 & Mini case-study #132

Merged

Conversation

jachiang
Copy link
Contributor

This update adds the following updates to taptweak chapter 2.2 :

@jachiang
Copy link
Contributor Author

Builds on #131

@jnewbery
Copy link
Contributor

I've had a quick skim and this looks good. I'll do a detailed review soon. Thanks!

@jachiang
Copy link
Contributor Author

I've had a quick skim and this looks good. I'll do a detailed review soon. Thanks!

Cheers @jnewbery

Copy link
Contributor

@bitschmidty bitschmidty left a comment

Choose a reason for hiding this comment

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

Thanks for taking the lead on this, @jachiang

I was able to successfully complete the notebook using the solutions.

2.2-taptweak.ipynb Outdated Show resolved Hide resolved
2.2-taptweak.ipynb Outdated Show resolved Hide resolved
2.2-taptweak.ipynb Outdated Show resolved Hide resolved
"\n",
"First, we commit a contract between Alice and Bob and then demonstrate how this unsafe commitment can be changed.\n",
"\n",
"* The initial committed contract is: `Alice pays 10 BTC to Bob`"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is confusing to have the message sound like a BTC transaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about "Alice agrees to pay 10 BTC to Bob"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that’s better, @jachiang

2.2-taptweak.ipynb Outdated Show resolved Hide resolved
2.2-taptweak.ipynb Show resolved Hide resolved
2.2-taptweak.ipynb Outdated Show resolved Hide resolved
2.2-taptweak.ipynb Outdated Show resolved Hide resolved
"coinbase_address = node.getnewaddress(address_type=\"bech32\")\n",
"node.generatetoaddress(101, coinbase_address)\n",
"balance = node.getbalance()\n",
"assert balance > 1\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps generate_and_send_coins() here. Also not sure we need the balance var or assert statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will open a separate PR to modify generate_and_send_coins() to accept multiple outputs and both addresses and data (op_return).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, this is now tracked here #143.

2.2-taptweak.ipynb Outdated Show resolved Hide resolved
@jachiang
Copy link
Contributor Author

@bitschmidty - Many thanks for your review! I will apply your fixes and suggestions as soon as I can today.

@jachiang
Copy link
Contributor Author

jachiang commented Nov 2, 2019

@bitschmidty Many thanks for your review. All your nits have been addressed.

This PR now builds on the following:

2.2-taptweak.ipynb Outdated Show resolved Hide resolved
2.2-taptweak.ipynb Outdated Show resolved Hide resolved
@bitschmidty
Copy link
Contributor

@jachiang Tested again based on the latest. I resolved the conversion for my items. Thanks for addressing those. Left a couple more comments and also left the unresolved items as well.

@jachiang jachiang force-pushed the 2019-10-2.2-update-minicasestudy branch from 0ca2e9e to b259f1d Compare November 6, 2019 19:05
@jachiang
Copy link
Contributor Author

jachiang commented Nov 6, 2019

@jachiang Tested again based on the latest. I resolved the conversion for my items. Thanks for addressing those. Left a couple more comments and also left the unresolved items as well.

Thanks @bitschmidty for your review. Sorry, what are you referring to as unresolved items?

@jachiang jachiang force-pushed the 2019-10-2.2-update-minicasestudy branch from b259f1d to f538aa8 Compare November 6, 2019 19:39
@jachiang
Copy link
Contributor Author

jachiang commented Nov 6, 2019

* [#132 (comment)](https://github.com/bitcoinops/taproot-workshop/pull/132#discussion_r341773228)

* [#132 (comment)](https://github.com/bitcoinops/taproot-workshop/pull/132#discussion_r341222960)

@jnewbery jnewbery force-pushed the 2019-10-2.2-update-minicasestudy branch from f538aa8 to 1b9dc08 Compare November 8, 2019 22:24
Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Really good stuff @jachiang . Thanks for doing this, and apologies that it's taken me a while to get to it.

I've rebased on master after merging a couple of the earlier PRs, and also added a commit with some suggested nits. Take a look and let me know what you think.

I really like the new stuff in part 1 about pay-to-contract and verifying the commitments. It's a great practical example of a broken commitment scheme and making it secure.

For the case study, I think it'd be more effective if the student built the OP_RETURN and pay-to-contract transactions themselves. Adding a commitment in the transaction is the point of the exercise, so we should bring that to the center of the student's attention. We should move functionality into the background in the framework convenience functions when it's something we don't want the student to pay attention to.

util.py Outdated
@@ -149,7 +149,7 @@ def __getattr__(self, name):
def __setattr__(self, name):
return setattr(self.instance, name)

def generate_and_send_coins(node, address):
def generate_and_send_coins(node, address, data=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to construct the OP_RETURN transaction in the notebook itself rather than have it hidden in the util file. Having the transaction constructed in the notebook is more illustrative of the differences between using OP_RETURN and committing to a value in a pubkey.

"print(\"Transaction weight with OP_RETURN: {}\\n\".format(node.decoderawtransaction(op_return_tx_hex)['weight']))"
]
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest removing this exercise Verify that the contract between Alice and Bob is committed correctly and the final example Construct a CTransaction to spend the pay-to-contract public key. Both of those things have been done before, so I don't think it provides much extra value to the student to go through them again. I think this could just be replaced with a text cell saying that the commitment can be verified like we did in part 1, and that the output to a tweaked pubkey is spendable, like in part 2.

@jnewbery
Copy link
Contributor

@jachiang - are you still working on this? What are your thoughts about moving the OP_RETURN construction into the notebook so it's more visible to the student?

@jachiang
Copy link
Contributor Author

jachiang commented Nov 27, 2019

@jnewbery - apologies for the delay. I agree with constructing OP_RETURN out in the open (it's a simple script too), and will prioritize this for an update this week.

@jachiang jachiang force-pushed the 2019-10-2.2-update-minicasestudy branch from 1b9dc08 to 835225d Compare November 28, 2019 22:36
@jachiang
Copy link
Contributor Author

jachiang commented Nov 28, 2019

@jnewbery - I have included the OP_RETURN construction in part 3) with createrawtransaction. Alternatively, it could be constructed with CTransaction, by setting vouts individually, resulting in more (boilerplate) code. What do you think is better?

Edit: I have added commit "Rewrite 2.2.11 and 2.2.12 with CTransaction" so the reviewer can compare the alternative OP_RETURN construction with CTransaction.

Other updates: Commit review fixups broke example 2.2.5. at "Alice tweaks her key pair". This has now been fixed.

@jachiang jachiang force-pushed the 2019-10-2.2-update-minicasestudy branch from 835225d to 008ba57 Compare November 28, 2019 22:57
@bitschmidty
Copy link
Contributor

@jachiang let me know if/when youd like me to test through the applicable notebooks on this PR

@jnewbery jnewbery force-pushed the 2019-10-2.2-update-minicasestudy branch from 8424485 to 407792b Compare January 3, 2020 22:21
@jnewbery
Copy link
Contributor

jnewbery commented Jan 3, 2020

Rebased on master and added a commit with a few small changes.

@bitschmidty - Chapter 2.2 should be ready for final review.

Copy link
Contributor

@bitschmidty bitschmidty left a comment

Choose a reason for hiding this comment

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

tACK 407792b

@jnewbery jnewbery merged commit 22066f5 into bitcoinops:master Jan 6, 2020
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