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

Incorrect wallet address in Key Management section #481

Open
Cantido opened this issue Mar 11, 2021 · 0 comments
Open

Incorrect wallet address in Key Management section #481

Cantido opened this issue Mar 11, 2021 · 0 comments
Assignees

Comments

@Cantido
Copy link

Cantido commented Mar 11, 2021

I'm writing a Nano library for Elixir, and I believe I have discovered an off-by-one error in whatever library produced the example wallet address in they Key Management section.

My first attempt at encoding the public key into a wallet address used the RFC 4648 base32 algorithm with a modified alphabet. That is, I would take five bits at a time, and use that five-bit integer as an index for a character array. Here was my first attempt:

for <<i::5 <- pubkey>>, into: <<>> do
  String.at("13456789abcdefghijkmnopqrstuwxyz", i)
end

However, this produced an incorrect wallet address.

After some toying around, I discovered that whatever library produced these examples is actually dropping the first bit of the public key. Here's the snippet that produces an address matching the example:

# Drop the first bit of the to-be-encoded value
<<_::1, rest::pubkey>> = bin

# Same RFC 4648 algorithm
for <<i::5 <- rest>>, into: <<>> do
  String.at("13456789abcdefghijkmnopqrstuwxyz", i)
end

I was following the reference implementation at https://github.com/numsu/nanocurrency-web-js/blob/master/lib/nano-address.ts, and I suspect the bug is in there.

Am I correct in saying this is also a bug in the Javascript implementation, or was the example wallet in these docs produced by another library?

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

No branches or pull requests

2 participants