Confusing explanation of permutation
multun opened this issue · 1 comments
The array consists of 256 bytes forming a permutation: that is, all possible index values occur exactly once as a value in the array. That means it maps every possible byte value to every possible byte value: usually different, but sometimes the same one.
I don't quite understand the last sentence, how can two bytes map to the same one with a permutation? Is it me reading it wrong, or is it something actually incorrect with this sentence?
Are you looking at the RC4 stuff? You may want to check out this PR: #375 (comment) since a paragraph that first introduces permutations is currently being edited.
Two bytes can not map to the same value. What this sentence is trying to say is that all byte values will occur in the array exactly once, so every byte will be mapped to some (exactly 1) byte. Some people assume that this must mean there are no mappings of a byte to itself (still only 1 byte!), but that's not the case: fixed points are quite common. To rephrase, for some byte values b, p(b) = b
. Does that make sense?