Keccak padding function pad10*1
For the keccak hash function, the input bit string needs to be padded to a length that is a multiple of 1,088. This padding function, called pad10*1
, is specified in section 5.1 of the SHA-3 Standard↗. It can be described as follows: a bit 1 is appended, and another (additional) bit 1 will be added at the very end, and then enough 0s (possibly none) are inserted between these two 1 bits to make the length divisible by 1,088. If bits
is the list of bits
that need to be padded, then the number of zeroes is thus (-len(bits)-2) modulo 1088
, or in Go (due to Go's behavior with respect to remainders of negative numbers), (1088 - ((len(bits) + 2) % 1088)) % 1088
. The number of 1,088-bit blocks of the padded data are then ceil((len(bits) + 2) / 1088) = floor((len(bits) + 1) / 1088) + 1
.