question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handler:canApply can fail a transaction because of a case-sensitive check on publicKey

See original GitHub issue

Describe the bug crypto/lib/handlers/transactions/handler.js line 27. There is a comparison : applicable = (transaction.senderPublicKey === wallet.publicKey) && enoughBalance

This check, will fail if either transaction.senderPublicKey is UPPERCASE and wallet.publicKey is lowercase or vice-versa, even if they’re equal. I ran into a scenario on my relay, where somehow the in-memory wallets found in Pool-Wallet-Manager(byPublicKey) became keyed by uppercase versions of the publicKey. So, on a subsequent transaction send, it would fail. This might have implications elsewhere where we do such comparisons.

To Reproduce I’m not sure how the in-memory wallets got keyed in uppercase, but I’d start in the transaction-pool and dig there. At any case, that shouldn’t cause the transaction to fail.

Expected behavior The two properties are equal in meaning, but not in casing. That shouldn’t be a deal breaker…

Screenshots uppercase_by_publickey

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vasildcommented, Nov 2, 2018

What a mess. The root of the problem is that we do machine operations on data that is presented in a human readable way, for humans to read, not machines.

Like, for example, trying to compare two dates by comparing their string representations and messing up trying to compare different human readable representations: Fri Nov 02 2018 08:20:40 GMT+0100 (Central European Standard Time) toString() and 11/2/2018, 8:20:40 AM toLocaleString() whereas the correct way would be to compare the machine readable variant (getTime() in this case).

That said, the correct way of doing things is to manipulate (store on disk, compare, send over the network) the public key in a binary buffer and only convert it to hex string when it is to be presented to humans. This way it will also take less space on disk, compare faster and use less bandwidth.

0reactions
paroxysmcommented, Nov 2, 2018

Yes @vasild , that is problematic and will mask hard to find bugs. We need to be pro-actively rooting such erroneous code before it comes back to bite us.

As far as storing publicKey as a binary buffer, I don’t view having it in hex form at runtime as a terrible thing, there’s some benefits(such as easier to debug, log analysis and write tests for). Devs just need to be cognizant when writing code of comparisons and equality, that there are casing issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FIND comparing case-sensitive character variable to indexed ...
FIND comparing a case-sensitive CHARACTER variable to an indexed, non-case-sensitive field fails. Table (database table or temp-table) ...
Read more >
Are email addresses case sensitive? - Stack Overflow
So yes, the part before the "@" could be case-sensitive, since it is entirely under the control of the host system. In practice...
Read more >
Adjust case sensitivity - WSL - Microsoft Learn
Learn how case sensitive file names are handled between Windows and Linux file systems, how to adjust these settings by directory with WSL, ......
Read more >
Is Python Case-Sensitive? - LearnPython.com
Yes, Python Is a Case-Sensitive Language​​ First, let's clarify what case sensitivity is. It's the differentiation between lower- and uppercase ...
Read more >
5 ways to do case-sensitive VLOOKUP in Excel - Ablebits
The tutorial explains how to make Excel VLOOKUP case-sensitive, ... The below formula will catch "bill" because it comes first in the lookup ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found