-
Notifications
You must be signed in to change notification settings - Fork 111
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
Chapter 2.2 update: Added commitment unsealing to 2.2.3/2.24 & Mini case-study #132
Conversation
Builds on #131 |
I've had a quick skim and this looks good. I'll do a detailed review soon. Thanks! |
Cheers @jnewbery |
There was a problem hiding this 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
"\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`" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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
"coinbase_address = node.getnewaddress(address_type=\"bech32\")\n", | ||
"node.generatetoaddress(101, coinbase_address)\n", | ||
"balance = node.getbalance()\n", | ||
"assert balance > 1\n", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
@bitschmidty - Many thanks for your review! I will apply your fixes and suggestions as soon as I can today. |
b3cade7
to
0ca2e9e
Compare
@bitschmidty Many thanks for your review. All your nits have been addressed. This PR now builds on the following:
|
@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. |
0ca2e9e
to
b259f1d
Compare
Thanks @bitschmidty for your review. Sorry, what are you referring to as unresolved items? |
b259f1d
to
f538aa8
Compare
|
f538aa8
to
1b9dc08
Compare
There was a problem hiding this 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): |
There was a problem hiding this comment.
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.
2.2-taptweak.ipynb
Outdated
"print(\"Transaction weight with OP_RETURN: {}\\n\".format(node.decoderawtransaction(op_return_tx_hex)['weight']))" | ||
] | ||
}, | ||
{ |
There was a problem hiding this comment.
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.
@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? |
@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. |
1b9dc08
to
835225d
Compare
@jnewbery - I have included the OP_RETURN construction in part 3) with 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 Other updates: Commit |
835225d
to
008ba57
Compare
@jachiang let me know if/when youd like me to test through the applicable notebooks on this PR |
8424485
to
407792b
Compare
Rebased on master and added a commit with a few small changes. @bitschmidty - Chapter 2.2 should be ready for final review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 407792b
This update adds the following updates to taptweak chapter 2.2 :