Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Fix: Remove redundant Ed25519 public key (#36). #54

Merged
merged 2 commits into from
Feb 1, 2019

Conversation

t-bast
Copy link
Contributor

@t-bast t-bast commented Jan 31, 2019

The private key already contains the public key point, no need to add it twice.

The private key already contains the public key point, no need to add it twice.
})
}
t.Run("PrivateKey", func(t *testing.T) {
for name, f := range map[string]func() ([]byte, error){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also wanted to add a stronger regression test by generating a key with the old code (redundant public key), marshalling it, keeping it hardcoded into the test and verifying that it can still be used.
Do you think it's worth it or is it overkill?

Fixed it and added tests.
Nit: replaced fmt.Errorf by errors.New to avoid unnecessary fmt.Sprintf.
@t-bast
Copy link
Contributor Author

t-bast commented Jan 31, 2019

@Stebalien I'll let you assign this to whoever has time to review it (should be pretty quick though).

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

changing the external representation breaks the key hashing and changes peer IDs.

@t-bast
Copy link
Contributor Author

t-bast commented Jan 31, 2019

That's right. But I think that it's not an issue and doesn't impact backwards-compatibility.

In UnmarshalEd25519PrivateKey we were already stripping the redundant public key (before that PR), so all the code that unmarshals private keys will work the same and generate the same peer IDs after this PR. Backwards-compatibility might have been broken when the code that stripped the redundant public key was introduced though, but that doesn't impact this PR.

The only difference will be when you generate a new key so it won't impact existing users.
Or am I missing something?

@vyzo
Copy link
Contributor

vyzo commented Jan 31, 2019

Oh, it's the private key format that's changing. The backwards incompatibility is with reading existing keys in that case.

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

We've had a go-ipfs release since the duplication was fixed so this should be good.

@t-bast
Copy link
Contributor Author

t-bast commented Feb 1, 2019

I don't have write access, I'll let you merge this when you feel it makes sense.

@vyzo vyzo merged commit f2988f1 into libp2p:master Feb 1, 2019
@t-bast t-bast deleted the bt/ed25515/redundant-public-key branch February 1, 2019 09:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants