Should changes to FNV-1A’s input exhibit the avalanche effect?

This is kind of related to Which hashing algorithm is best for uniqueness and speed?. In that question, the excellently written top answer notes,

Randomnessification

The other subjective measure is how randomly distributed the hashes are. Mapping the resulting HashTables shows how evenly the data is distributed.

(here, “random” is not being used to mean “deterministic” — all of the functions under consideration are deterministic.)

Based on that question’s excellent answer, I implemented FNV-1A. However, the results I’m getting do not seem particularly “random”ly distributed:

In [19]: for x in xrange(10):
   ....:     h = Fnv1A(); h.update(b'testing' + str(x)); print hex(h.value)
   ....:
0x3e249fc5d899c731L
0x3e249ec5d899c57eL
0x3e249dc5d899c3cbL
0x3e249cc5d899c218L
0x3e24a3c5d899cdfdL
0x3e24a2c5d899cc4aL
0x3e24a1c5d899ca97L
0x3e24a0c5d899c8e4L
0x3e2497c5d899b999L
0x3e2496c5d899b7e6L

Notice that the vast majority of the bits in the output here are the same.

Is FNV-1A supposed to be an extremely discontinuous function? i.e., the output changes drastically for small changes in the input; it exhibits the Avalanche effect.

Note that this is orthogonal to being uniformly distributed, which I also want.

I’m attempting to use FNV-1A to simply randomly distribute users into one of n weighted buckets. None of the inputs are user-controlled, so security is not of much concern, but the inputs are highly not random (they’re auto-incrementing integers…); I do, however, need the output two be random (but deterministic): for a given user ID, it should be random which bucket they end up in.

I actually asked another similar question a while ago; I understand that hash outputs don’t necessarily need to be random (for hashtables, all you really care about is that they don’t collide). For my particular application, I unfortunately need randomness.

(In case you’re curious about the correctness of my implementation,

In [22]: h = experiment.Fnv1A(); h.update(b'foobar'); h.value
Out[22]: 9625390261332436968L

…as this is for work, I’m trying to share as little code as needed. This question is more about FNV-1A itself, rather than my particular implementation.)

4

From your requirements it rather sounds like you should be using a secure (cryptographic) hash.


To your actual question:

Is FNV-1A supposed to be an extremely discontinuous function? i.e., the output changes drastically for small changes in the input; it exhibits the Avalanche effect.

we can quickly get an answer of No by looking at the FNV test vectors linked from the FNV homepage. Your foobar => 0x85944171f73967e8 test case is here, and also here we find these test cases:

input    output
"a"      0xaf63dc4c8601ec8c
"b"      0xaf63df4c8601f1a5
"c"      0xaf63de4c8601eff2
"d"      0xaf63d94c8601e773
"e"      0xaf63d84c8601e5c0
"f"      0xaf63db4c8601ead9

It’s clear that this hash is not one to use if you want small changes to avalanche.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật