Skip to content
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

PeerID Derivation Is Broken #14

Closed
bonedaddy opened this issue Jul 15, 2020 · 3 comments · Fixed by #26
Closed

PeerID Derivation Is Broken #14

bonedaddy opened this issue Jul 15, 2020 · 3 comments · Fixed by #26

Comments

@bonedaddy
Copy link
Contributor

bonedaddy commented Jul 15, 2020

PeerID derivation is currently broken. It works sometimes, but other times doesn't work and returns bad data. I think there's some kind of memory issue, but am uncertain.

Example:

5UQDbFGV9gpiaEH <-- bad

QmfGFNuk8rk9oQU8iX572JgtExBnwsAmSzDhSwPRdpRLGG <-- good

The error appears to come from mh_new function call

@bonedaddy
Copy link
Contributor Author

bonedaddy commented Jul 15, 2020

@bonedaddy
Copy link
Contributor Author

@bonedaddy
Copy link
Contributor Author

bonedaddy commented Jul 18, 2020

I believe i've found the source of the problem. The library we use for base58 encoding does not properly handle input data that as a 0 in it. It seems like if the input data has a 0 in it, then the base58 library interprets that as the end of the input data.

I can think of a few work arounds:

  • hex encode the sha256 hash before converting to peerid
  • switch from base58 to base32, or base64

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

Successfully merging a pull request may close this issue.

1 participant