Skip to content

Added Jupyter Chapter 1.2 (Musig Introduction) - #10

Merged
jnewbery merged 5 commits into
bitcoinops:masterfrom
jachiang:PR-10
Sep 18, 2019
Merged

Added Jupyter Chapter 1.2 (Musig Introduction)#10
jnewbery merged 5 commits into
bitcoinops:masterfrom
jachiang:PR-10

Conversation

@jachiang

@jachiang jachiang commented Sep 2, 2019

Copy link
Copy Markdown
Contributor

Previous chapter feedback which has been incorporated in this PR.

@jnewbery

jnewbery commented Sep 4, 2019

Copy link
Copy Markdown
Contributor

rebased on master

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking good. Lots of nits inline.

Some more general points:

  • what tool do you use to make the images/diagrams? Can you commit the source file so the diagrams can be updated later?
  • For future chapters, I suggest you just add the solution file for initial review. That way you won't need to apply nits in more than one place after the first review.
  • Are you happy for me to just add commits that address my nits? That might speed up the review cycle.

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"source": [
"import util\n",
"\n",
"from test_framework.test_framework import BitcoinTestFramework\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unused. Remove

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"import util\n",
"\n",
"from test_framework.test_framework import BitcoinTestFramework\n",
"from test_framework.key import ECKey, ECPubKey, generate_musig_key, generate_schnorr_nonce\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

merge with line below

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"from test_framework.test_framework import BitcoinTestFramework\n",
"from test_framework.key import ECKey, ECPubKey, generate_musig_key, generate_schnorr_nonce\n",
"from test_framework.key import aggregate_schnorr_nonces, aggregate_musig_signatures\n",
"import binascii\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unused. Remove

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"from test_framework.key import ECKey, ECPubKey, generate_musig_key, generate_schnorr_nonce\n",
"from test_framework.key import aggregate_schnorr_nonces, aggregate_musig_signatures\n",
"import binascii\n",
"import hashlib"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move standard library imports above local library imports.

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1.2 Introduction to n-of-n Musig\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style nit: use MuSig, not Musig

Comment thread 1.2-Introduction-to-Musig.ipynb Outdated
"cell_type": "markdown",
"metadata": {},
"source": [
"### 3.1 Programming exercise: Compute aggregated musig signature.\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good if you could show why the aggregate signature is valid for the aggregated pubkey

"for pk, c in c_map.items():\n",
" print(\"Compressed Pubkey: \", pk.get_bytes().hex())\n",
" print(\"Challenge: \", c.hex(), '\\n')\n",
" \n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be good to print the aggregated public key here.

"msg = hashlib.sha256(b'transaction').digest()\n",
"\n",
"# Generate individual signatures.\n",
"sig0 = sec0_c.sign_musig(k0, negated, R_agg, pk_musig, msg)\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd suggest removing the negated argument here. Just negate the k values in the previous cell.

"outputs": [],
"source": [
"# Compute key pairs.\n",
"sec0 = ECKey()\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the name privkey0, etc would be a bit clearer than sec0.

"sig2 = sec2_c.sign_musig(k2, negated, R_agg, pk_musig, msg)\n",
"\n",
"# Aggregate signatures.\n",
"sig_agg = aggregate_musig_signatures([sig0, sig1, sig2])\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be nice if you could make it much more explicit that the signature generated using the MuSig validates correctly.

@jachiang

Copy link
Copy Markdown
Contributor Author

Feedback has been incorporated. Imports (updated) methods from separate musig module. Uses bitcoin (taproot) branch from here.

@jnewbery

Copy link
Copy Markdown
Contributor

rebased on master

@jnewbery

Copy link
Copy Markdown
Contributor

added a commit with lots of nitty changes

@jnewbery
jnewbery merged commit 28adff6 into bitcoinops:master Sep 18, 2019
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.

2 participants