btcsuite / btcutil

Provides bitcoin-specific convenience functions and types
479 stars 409 forks source link

Is fastReduction from gcs.go supposed to be equivalent to the modulo operation? #138

Closed AlexITC closed 5 years ago

AlexITC commented 5 years ago

From what I understand, the fastReduction is supposed to be equivalent to the modulo operation, while experimenting, I found that it is not the case.

fastReduction(6573390126540650161, 13343827) = 4754995 while 6573390126540650161 mod 13343827 = 438473

Roasbeef commented 5 years ago

No they aren't meant to be equivalent, but they have a similar distribution (a fair map), which is all we need for our use case.

AlexITC commented 5 years ago

That's what I noticed, as I read about GCS using modulo I was curious whether this was intentional.

Thanks.