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

Musig2: Update to 1.0.0.rc2 #1913

Merged
merged 3 commits into from
Nov 9, 2022
Merged

Conversation

sputn1ck
Copy link
Collaborator

@sputn1ck sputn1ck commented Nov 1, 2022

This PR adds the changes from jonasnick/bips#74 which adresses the risk described in https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/021000.html .

Will leave it as draft, until the bip PR is merged.

The bench_test.go/BenchmarkPartialVerify are failing, however they also seem to be failing on master.

@sputn1ck sputn1ck requested review from Roasbeef and guggero November 1, 2022 20:34
@coveralls
Copy link

coveralls commented Nov 1, 2022

Pull Request Test Coverage Report for Build 3373590167

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 25 of 32 (78.13%) changed or added relevant lines in 3 files are covered.
  • 9 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-18.1%) to 55.15%

Changes Missing Coverage Covered Lines Changed/Added Lines %
btcec/schnorr/musig2/sign.go 10 13 76.92%
btcec/schnorr/musig2/nonces.go 13 17 76.47%
Files with Coverage Reduction New Missed Lines %
mempool/mempool.go 1 66.75%
btcec/schnorr/musig2/sign.go 2 90.44%
connmgr/connmanager.go 2 86.07%
peer/peer.go 4 73.2%
Totals Coverage Status
Change from base Build 3369294878: -18.1%
Covered Lines: 26549
Relevant Lines: 48140

💛 - Coveralls

@sputn1ck sputn1ck changed the title Musig2 make pubkey mandatory Musig2 Update to 1.0.0 again Nov 1, 2022
@sputn1ck sputn1ck changed the title Musig2 Update to 1.0.0 again Musig2: Update to 1.0.0 again Nov 1, 2022
@sputn1ck sputn1ck changed the title Musig2: Update to 1.0.0 again Musig2: Update to 1.0.0 (again) Nov 1, 2022
@sputn1ck sputn1ck changed the title Musig2: Update to 1.0.0 (again) Musig2: Update to 1.0.0.rc2 Nov 3, 2022
@sputn1ck sputn1ck marked this pull request as ready for review November 3, 2022 14:23
@sputn1ck
Copy link
Collaborator Author

sputn1ck commented Nov 3, 2022

jonasnick/bips#74 is now merged, no new changes to the reference code have been made since my last commits

cc @Roasbeef

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sputn1ck Konstantin Nick
This commit adds the pk option to NonceGen and makes it mandatory.

Reference: jonasnick/bips@a89f857

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sputn1ck Konstantin Nick
This commit adds the public key to the sec nonce and ensures that we're
signing with the right key.

Reference: jonasnick/bips#74

Verified

This commit was signed with the committer’s verified signature. The key has expired.
sputn1ck Konstantin Nick
This commit adds a check that the public key of the private key
that is passed to the Sign function is included in the slice of public
keys.

Reference jonasnick/bips@ea47d52
Copy link
Collaborator

@guggero guggero 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 the update, LGTM 🎉

btcec/schnorr/musig2/context.go Show resolved Hide resolved
0,
1
],
"key_indices": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: avoid these formatting changes (probably done by the IDE) to keep the diff smaller?


// ErrPubkeyInvalid is returned when the pubkey of the WithPublicKey
// option is not passed or of invalid length.
ErrPubkeyInvalid = errors.New("nonce generation requires a valid pubkey")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: use PubKey capitalization in name?

@@ -142,6 +151,14 @@ func WithCustomRand(r io.Reader) NonceGenOption {
}
}

// WithPublicKey is the mandatory public key that will be mixed into the nonce
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if it's obvious from the context or whether we should add "the mandatory public key that corresponds to the signer's private key" or something to that effect to the comment?

@@ -38,6 +38,10 @@ var (
// ErrSecretNonceZero is returned when a secret nonce is passed in a
// zero.
ErrSecretNonceZero = fmt.Errorf("secret nonce is blank")

// ErrSecNoncePubkey is returned when the signing key does not match the
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: capitalization of PubKey and missing full stop.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🥟

Will make another PR to fix the issue with the benchmark.

@Roasbeef Roasbeef merged commit 31ecaff into btcsuite:master Nov 9, 2022
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.

None yet

4 participants