-
Notifications
You must be signed in to change notification settings - Fork 281
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
discv5: protocol version v5.1 #157
Conversation
Looking at the wire protocol document it doesn't appear to specify the computation of the |
I'm realizing that the new documents don't mention the |
Yeah, sorry, I need to update the images. In a discussion a couple weeks ago, we realized that the checksum is silly because the obfuscation layer hides away the plaintext protocol identifier, and the recipient node won't be able to decrypt the packet header if it is sent to the wrong node. |
Yes |
I've generated the following test vectors that I'd be interested in validating since they represent my collective interpretation of the spec as documented in this PR, #152, as well as potentially some inference in areas where neither fully documents something yet.
|
This change defines the first stable (non-draft) spec version of discv5.
Consider this case. There is a handshake in progress between The At this stage there are two possibilities.
The
Since the
This is a subtle enough case that it seems potentially worth documenting in some sort of implementers guide since an implementation that chooses the other route will result in both |
I'm finally updating the spec with the header masking, and two new ideas came up:
|
Damn, it looks like I wiped out the definitions of |
Another thing we could still change: feed the dest-id into id-signature. I'm suggesting this because I got mildly concerned that the removal of the encrypted auth-response might create an MITM risk. In the 5.0 handshake, we encrypted the id-signature with a separate session secret, but this was removed and the signature is now sent clear text (technically within the Consider communication A -> X -> B, with X being the MITM node. Preconditions:
Communication flow:
So, no MITM possible. But can X replay the id-signature somehow to authenticate as A to a different node C? Technically not, because X can't influence the id-nonce sent by node C. But it feels too shaky with all those malleable parts. I think it might be safer to put B's ID into the signature to ensure this can't happen, if only to make the id-signature an even more specific statement. |
@fjl Do you have Geth fork with all in it? |
Also remove weird special case text about resends.
I've just pushed the last spec update. Thank you so much for all your amazing feedback on this pull request. I have tried to address all of the issues you guys have raised. Here's the list of changes in the last couple commits:
We need to stop changing the spec now and focus on interop. TODO: update images |
This shrinks WHOAREYOU by 32 bytes because the src-id is omitted.
Seeing all this confusion about the challenge fields and the concerns about packet header authentication, I have decided to use the simplest solution possible: just use the entire unmasked packet header as the challenge data for both id signature and KDF, and also use it as authenticated data in the AES/GCM step. From a spec perspective, this change is very nice and I wonder why we didn't do it like that earlier. From an implementation point of view, this change sucks, at least for my own implementation. Since the data dependencies have changed so much, I had to change the ordering of some of the encoding steps in order to be able to have the encoded headers and BTW, I noticed that there was a problem with my HKDF usage, my own tests worked on Go 1.15 but not on earlier versions. This is now corrected and I hope you will be able to match the new test vectors. |
I can confirm that I can now decode your latest provided test vectors 👍 |
Very nice! All of them? If we get another implementation to agree, (and when I'm done updating the images) the PR can be merged! |
I'm now passing all of the test vectors in my implementation. |
I'm passing them too with JVM implementation |
This change defines the first stable (non-draft) spec version of discv5.
Work in progress. Still needs:
Closes #152
Closes #141
Closes #135
Closes #131
Closes #117
Closes #83