-
Notifications
You must be signed in to change notification settings - Fork 112
swarm/network: Use different privatekey for bzz overlay in sim #1304
Conversation
9dd0a6f
to
3a0c2ea
Compare
9eb8705
to
465b2d1
Compare
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.
just a minor thing I believe
// returns the private key used to generate the bzz key AND the generated bzz key | ||
func BzzKeyFromConfig(conf *adapters.NodeConfig) (*ecdsa.PrivateKey, []byte, error) { | ||
// ecdsa.GenerateKey takes 40 bytes entropy | ||
privKeyBuf := append(crypto.FromECDSA(conf.PrivateKey), []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}...) |
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.
Could you extract []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}
into a variable so that we don't have magic constants? What these hex number anyway? I don't know what they mean.
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.
Hint: hex.
And I tend to think that a bit of cryptic easter egg fun in the code raises spirits. You don't agree, perhaps?
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 see these are hex numbers, but still magic constants. <- 🔥
So, I guess I disagree.
As I feel we already have enough cryptic code to understand. 😉
Let's make fun of solving the already existing puzzles first. 👍
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.
Let's make fun of solving the already existing puzzles first.
That would be magic.
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.
fun is ok bzz, but why are we doing this again? what was wrong with this?
Okay. |
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.
minor comments
// returns the private key used to generate the bzz key AND the generated bzz key | ||
func BzzKeyFromConfig(conf *adapters.NodeConfig) (*ecdsa.PrivateKey, []byte, error) { | ||
// ecdsa.GenerateKey takes 40 bytes entropy | ||
privKeyBuf := append(crypto.FromECDSA(conf.PrivateKey), []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}...) |
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.
fun is ok bzz, but why are we doing this again? what was wrong with this?
6917782
to
54058e8
Compare
@zelig we should not use the same key for p2p and swarm. We should enforce that separation both in binary (which wasn't done either, in fact) and in sims. bzz bzz. |
@frncmx it's still "in process" ;) but thanks, yes, I will mind the comments. |
6ac90c9
to
d2ad11c
Compare
After yesterday stand-up I thought that you will address the last remaining comment about I understand that you think it's a funny Easter egg. Please keep in mind, that you write your code for others to understand and not to entertain them. After looking at
|
Did you actually read the description of the PR? Please read again along with ethereum/go-ethereum#19309 . If it is still not clear, I will try to add a more thorough explanation.
I will add a more precise comment.
No. In fact,
I'm not sure if patronizing me is very useful. |
Yes, I read. To my understanding the description just says that the overlay address and p2p connectivity id should be different in simulations. As it used to be the same before. The description also says we should use the private key, but does not talk about the why. As I've limited understanding of the code under change; I thought you might fill in the blanks for me. As switching from public key to private seemed like a radical change.
Thanks.
I read the description again. I might be mistaken, but I did not find the reference that we intended to change the key generation at other places. Also, I'm not sure when do we want to do that? Is that part of this change effort?
I did not mean that. I just don't understand why such a simple thing - like creating a variable called |
Ahh, so there is a misunderstanding here. We are not generating it from the private key, still from the public key. But the name of this method is stale, from the point where it was actually returning the bzzkey. I've changed the method name. The only thing this method does is to generate the private key from whose public key the bzzkey will be created. The pattern with "deterministic randomness" is used several places in our code. I prefer that kind of approach personally.
I don't mean to make you feel uncomfortable. My apologies. But I simply don't agree with you that we can't risk a bit of fun once in awhile. And we have to be able to cope with disagreement, @frncmx . If there is a difference of opinion on something, we leave it to a third party to be the tiebreaker. And the tie was broken. There was no need to push this further. That said, I've changed the comment description above this line. It should be pretty clear now that the given data is inconsequential, aswell as not pointing out that it's not actual entropy. Thanks for pointing that out. |
8e46e42
to
b16ddc7
Compare
(amend commit to trigger ci - attempt 5)
b16ddc7
to
4d6fdb5
Compare
Merged upstream as ethereum/go-ethereum#19313 |
Depends on #1302
A swarm node has different values for swarm overlay address and p2p connectivity id. However, in simulations the same value is used. This has in some cases led to confusion.
This PR provides a function to generate a swarm overlay address that is deterministically dependent on the p2p id (more precisely, its private key) but where the resulting value is different. The private key will be available through a respective simulation bucket.
When generating networks using the
swarm/network/simulation
package, this change is now built in (seeswarm/network/simulation/node.go:AddNode
). However, when booting from snapshots, it is currently up to the client code defining thenode.Service
implementations to explicitly choose different values.An example of the latter is implemented for the
swarm/pss/prox_test.go
. Corresponding changes for other simulation code will be amended in future PR(s).