-
Notifications
You must be signed in to change notification settings - Fork 294
multistream-select 1.0: simultaneous open protocol extension #196
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
Changes from 5 commits
31b56bf
df1ad98
15eb969
682894e
21be08c
26774a2
ff7a12e
3dd8877
debc8f5
dc663fe
ae86e33
13ea44a
41ce779
77cbb43
dd14a1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||
| # Simultaneous Open for bootstrapping connections in multistream-select | ||||||||||||
|
|
||||||||||||
| | Lifecycle Stage | Maturity | Status | Latest Revision | | ||||||||||||
| |-----------------|---------------|--------|-----------------| | ||||||||||||
| | 1A | Working Draft | Active | DRAFT | | ||||||||||||
|
||||||||||||
| | 1A | Working Draft | Active | DRAFT | | |
| | 1A | Working Draft | Active | r0, 2021-05-06 | |
mxinden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
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.
@vyzo Why do we need to encode to base64 here ? Why not simply append the 256 bits ?
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 assume it's because multistream 1 is a text-based, human-readable protocol (with all the pros and cons that come with it).
That said, base64 seems like a suboptimal choice here. I propose switching to hexadecimal encoding. Encoding math.MaxUint64 (18446744073709551615) is 0xFFFFFFFFFFFFFFFF in hex and MTg0NDY3NDQwNzM3MDk1NTE2MTU= in base64.
Also, 256 bits seem excessive here. I think we can live with a collision probability of 2^-64, which would allow implementations to use a regular uint64 instead of math/big.Int. We might even want to limit this to 52 (?) bits to make things easier in JavaScript (but I'm no expert on that).
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.
Encoding math.MaxUint64 (18446744073709551615) is 0xFFFFFFFFFFFFFFFF in hex and MTg0NDY3NDQwNzM3MDk1NTE2MTU= in base64.
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.
Would it? I used https://www.base64encode.net/, and that gives the same result (except for the last character?) as echo 18446744073709551615 | base64. But maybe that's decoding the string "18446744073709551615" and not the number?
As / is a separator we use in multistream, so base64 encoding might get us into trouble, if we don't escape it, right?
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.
Yes I guess you're encoding the string.
It doesn't make sense that encoding something in base64 would give something longer than encoding that same thing in base16
I think that / isn't a problem because of the select: prefix. Otherwise I'd suggest base58.
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.
Not opposed to base58, but also not sure if it's easily accessible in all the languages we care about. In Go, we'd have to import a third-party library (it's not in the standard library).
Any thoughts on the length of this value?
mxinden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
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.
| In the unlikely case where both peers selected the same integer, they | |
| generate a fresh one and enter another round of the protocol. If | |
| multiple rounds of the protocol result in the same integers, this is | |
| indicative of a bug and both peers should abort the connection. | |
| In the unlikely case where both peers selected the same integer, connection establishment fails. |
The Golang implementation does not retry. See multiformats/go-multistream#42 (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.
As per @raulk's comment in #196 (comment).