0
$\begingroup$

So I was supposed to use hash some co-ordinates and I was supposed to use k 3-wise independent hash functions in order for the mathematical explanations behind that algorithm to be hold. But after using k 3 wise independent hash functions, I got kinda bad accuracy(I used tabulation hashing which I myself wrote for this. Then I decided to use some cryptographic hash function for collision resistance and ended up using sha256 in this way

  • As I have to generate k different hash functions for my purpose, I generated k different seeds and wrote this snippet -
hex_num = hashlib.sha256((str(self.seed[i])+str(d)).encode('utf-8')).hexdigest()
                int_hex = int(hex_num[:5],16)
                index = int_hex % self.width

where I want to get the hashed values in the range of 0 to self.width-1. Now I had a few questions-

$\endgroup$
7
  • 1
    $\begingroup$ Do you really need hash instead of use Encryption so that no two different plaintexts can map to the same ciphertext? The collision probability is given by the birthday-paradox. For two-item, it is almost zero. What is your total items, so that one can provide an almost exact number? If the result of the hash is not fitted then rejection should be applied inorder to eliminate the bias. $\endgroup$
    – kelalaka
    Aug 10, 2020 at 20:50
  • $\begingroup$ Also, what is self.width? $\endgroup$
    – kelalaka
    Aug 10, 2020 at 20:57
  • $\begingroup$ Also, see : Birthday problem for cryptographic hashing, 101 $\endgroup$
    – kelalaka
    Aug 10, 2020 at 21:08
  • $\begingroup$ @kelalaka self.width is originally the width of a table, but you can actually assume that it is the range of output. $\endgroup$ Aug 10, 2020 at 23:52
  • 1
    $\begingroup$ You can edit your question to clarify more. As it stands the: Birthday problem for cryptographic hashing, 101 answers your question. Just plug the numbers. Can we call it dupe? $\endgroup$
    – kelalaka
    Aug 11, 2020 at 9:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.