-
Notifications
You must be signed in to change notification settings - Fork 122
loop: Loop In MuSig2 support #547
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
Conversation
6edbef8 to
086f21a
Compare
sputn1ck
left a comment
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.
Very nice PR, easy to grok changes 💯
086f21a to
9888bcd
Compare
9888bcd to
5d684e7
Compare
sputn1ck
left a comment
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.
This is not a draft anymore right? LGTM 🐐
loopdb/store.go
Outdated
| // path: loopInBucket/loopOutBucket -> swapBucket[hash] | ||
| // -> senderInternalKeyKey | ||
| // value: serialized private key. | ||
| senderInternalKeyKey = []byte("sender-internal-key") |
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.
nit: rename to senderInternalPrivKeyKey
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.
done
server_mock_test.go
Outdated
| } | ||
|
|
||
| var receiverKeyArray [33]byte | ||
| var receiverKeyArray, receriverInternalKeyArray [33]byte |
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.
nit: typo receriverInternalKeyArray
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.
done
5d684e7 to
6fe569f
Compare
|
Added shared key encryption to the stored priv keys. |
|
@sputn1ck: review reminder |
6fe569f to
a491c0d
Compare
GeorgeTsagk
left a comment
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.
➰LGTM➰
minor comments
| // HtlcKeys is a holder of all keys used when constructing the swap HTLC. Since | ||
| // it's used for both loop in and loop out swaps it may hold partial information | ||
| // about the sender or receiver depending on the swap type. | ||
| type HtlcKeys struct { |
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 like this HtlcKeys struct holding all keys
loopdb/store.go
Outdated
| if err != nil { | ||
| return err | ||
| } | ||
| // Store the htlc keys if the contract is recent. |
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.
This comment is not super clear to me
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.
ptal
client.go
Outdated
|
|
||
| import ( | ||
| "context" | ||
| "encoding/hex" |
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.
this commit message has a typo:
loopdb: encrpyt stored..->loopdb: encrypt stored..This technique allows us to encrpyt..->This technique allows us to encrypt..
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, fixed!
|
|
||
| // If this is a MuSig2 swap then we'll generate a brand new key pair | ||
| // and will use that as the internal key for the HTLC. | ||
| if loopdb.CurrentProtocolVersion() >= loopdb.ProtocolVersionMuSig2 { |
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.
What does the >= imply for the order of protocol versions? Anything that comes after ProtocolVersionMuSig2 is gonna share the same code in the block below? If yes, why?
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.
This just means that currently we make the assumption that all further protocol upgrades will include musig2 loopin. If this is not the case we'll simply change it.
a491c0d to
4020b2d
Compare
|
ping @sputn1ck |
sputn1ck
left a comment
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.
LGTM!
This commit adds a new protocol version which will add MuSig2 loop in and loop out using key reveal and extends the existing protocol with new message members to be able to pass around htlc internal public keys. The commit also fixes some minor formatting issues in the server proto.
This commit adds a new struct to hold all HTLC keys and refactors the SwapContract which is used by both loopin and loopout swaps to use this new struct. The newly added internal keys will for now hold the script keys to keep everything equivalent but are already stored and read back if the protocol version is set to MuSig2.
This commit changes how we create loopin swaps if the client activates the experimental MuSig2 features. When creating a new loopin swap the client will create (and store) a new key that will be used as the sender's internal key when constructing the HTLC. The client will send the public part to the server and will also receive (and store) the server's (receiver) internal public key.
This commit adds key reveal to MuSig2 loopin swaps' success path. In this case the client reveals their internal HTLC key to the server when the swap invoice is settled. With this key the server can sweep the swap HTLC without any more interaction from the client. We'll do this every block (after the invoice has been settled).
4020b2d to
cd91f90
Compare
sputn1ck
left a comment
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 like the change to deriving the shared secret
This PR defaults new swaps to MuSig 1.0rc and adds support for MuSig loopin swaps for the success case.
Depends on:
- #546Pull Request Checklist
release_notes.mdif your PR contains major features, breaking changes or bugfixes