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.

hashing doesn't correctly handle some corner cases

See original GitHub issue

Issue

Description In experimenting with my “educational” version of ElectionGuard, where I accumulated the whole formula of every operation on ElementModP and Q, I discovered a few misfeatures in the hash function.

  • If the value being hashed is the integer 0, that’s treated by Python as “false” and is hashed as “null”
  • There were some cases where lists weren’t being hashed recursively, but were instead being converted to a string and then hashed as a string

None of these impact correctness, since the hash still properly depends on the value in question, but they do impact portability, in the sense that another programming language might properly implement the same hash function with identical behavior.

The patch is pretty simple, only a few changes in hash.py

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rc-mscommented, Jun 25, 2021

Thanks for this thread and discussion. We hope to address this immediately after our next release. We plan to enable a suite of more efificient unit tests with prescriptive values such as you indicate.

0reactions
AddressXceptioncommented, Jul 8, 2021

Thanks @rc-ms, I’m looking forward to seeing it. Do you have any indication of roughly how far away that is likely to be?

We are pulling this in to the current iteration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Practice Problems on Hashing
In this article, we will discuss the types of questions based on hashing. Before understanding this, you should have idea about hashing, ...
Read more >
How to handle duplicate hashes
How to handle duplicate hashes ... AFAIK git just trusts sha1 hash to be unique, so it doesn't handle cases when two hashes...
Read more >
Hash Collision - an overview
They target some corner-case, worst-case, or pathological behavior of a function. Another example, albeit a narrowly-focused one, is the hash collision ...
Read more >
Which hashing algorithm is best for uniqueness and speed?
I tested some different algorithms, measuring speed and number of ... This points out that CityHash has some problems in corner cases.
Read more >
Address certain corner cases of time-travel queries by ...
With the exception of what I described above, that's what happens, and using a hash that is not the hash of a valid...
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