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

strange issue with ED25519 keys #29

Closed
jvsteiner opened this issue Feb 7, 2018 · 3 comments · Fixed by #30
Closed

strange issue with ED25519 keys #29

jvsteiner opened this issue Feb 7, 2018 · 3 comments · Fixed by #30
Assignees

Comments

@jvsteiner
Copy link

I have a test failing in my code (below) and I think it shouldn't. Perhaps I'm missing something though - was wondering if this is a bug, or I have incorrect assumptions somewhere:

func TestPubKey(t *testing.T) {
	priv, _, _ := crypto.GenerateEd25519Key(mrand.New(mrand.NewSource(0)))
	id1, _ := peer.IDFromEd25519PublicKey(priv.GetPublic())
	id2, _ := peer.IDFromPrivateKey(priv)
	assert.Equal(t, id1.Pretty(), id2.Pretty(), "should be equal?") // fails...
}

p.s. I found that IDFromPublicKey works instead of IDFromEd25519PublicKey but the difference still seems strange...

@Stebalien
Copy link
Member

My guess is that one inlines the key and the other doesn't. It's imperative that we be consistent here. Otherwise, peers can end up with multiple identities and everything breaks in weird, hard to understand ways.

@jvsteiner
Copy link
Author

jvsteiner commented Feb 7, 2018

for my use case, I'm using the public key as an identifier (topic actually) in go-floodsub. therefore I rely on the peer.ID output from IDFromEd25519PublicKey to set the topic, and it's important that I can derive a key that can be used to verify a signature that was created with the corresponding private key, although this output doesn't look like a multiaddr - doesn't start with "Qm" etc.

While it would be nice if that public key string representation were consistent with the part of the multiaddr that indicates the identity, the important thing is being able to derive the public key. Currently, I can't do that with IDFromPublicKey or peer.IDFromString. I wonder if there is a hash function in the way between the multiaddr representation and a usable public key...

@Stebalien
Copy link
Member

Stebalien commented Feb 7, 2018

For RSA keys, there is (RSA public are big). Ed25519 keys are supposed to be inlined. (apparently not)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants