Keccak-p[1600, 24] permutation's θ step mapping function, which is implemented
in terms of 32 -bit word size ( bit interleaved representation )
See https://github.com/itzmeanjan/merklize-sha/blob/1d35aae9da7fed20127489f362b4bc93242a516c/include/sha3.hpp#L55-L98 for original implementation
Expected stack state :
[state_addr, ...]
Final stack state :
[ ... ]
Whole keccak-p[1600, 24] state can be represented using fifty u32 elements i.e. 13 absolute memory addresses
s.t. last two elements of 12 -th ( when indexed from zero ) memory address are zeroed.
Consecutive memory addresses can be computed by repeated application of `add.1`.
## std::crypto::hashes::keccak256
| Procedure | Description |
| ----------- | ------------- |
| to_bit_interleaved | Given two 32 -bit unsigned integers ( standard form ), representing upper and lower
bits of a 64 -bit unsigned integer ( actually a keccak-[1600, 24] lane ),
this function converts them into bit interleaved representation, where two 32 -bit
unsigned integers ( even portion & then odd portion ) hold bits in even and odd
indices of 64 -bit unsigned integer ( remember it's represented in terms of
two 32 -bit elements )
Input stack state :
[hi, lo, ...]
After application of bit interleaving, stack looks like
[even, odd, ...]
Read more about bit interleaved representation in section 2.1 of https://keccak.team/files/Keccak-implementation-3.2.pdf
See https://github.com/itzmeanjan/merklize-sha/blob/1d35aae9da7fed20127489f362b4bc93242a516c/include/utils.hpp#L123-L149
for reference implementation in higher level language.
|
| from_bit_interleaved | Given two 32 -bit unsigned integers ( in bit interleaved form ), representing even and odd
positioned bits of a 64 -bit unsigned integer ( actually a keccak-[1600, 24] lane ),
this function converts them into standard representation, where two 32 -bit
unsigned integers hold higher ( 32 -bit ) and lower ( 32 -bit ) bits of standard
representation of 64 -bit unsigned integer
Input stack state :
[even, odd, ...]
After application of logic, stack looks like
[hi, lo, ...]
This function reverts the action done by `to_bit_interleaved` function implemented above.
Read more about bit interleaved representation in section 2.1 of https://keccak.team/files/Keccak-implementation-3.2.pdf
See https://github.com/itzmeanjan/merklize-sha/blob/1d35aae9da7fed20127489f362b4bc93242a516c/include/utils.hpp#L151-L175
for reference implementation in higher level language.
|
| hash | Given 64 -bytes input, in terms of sixteen 32 -bit unsigned integers, where each pair
of them holding higher & lower 32 -bits of 64 -bit unsigned integer ( reinterpreted on
host CPU from little endian byte array ) respectively, this function computes 32 -bytes
keccak256 digest, held on stack top, represented in terms of eight 32 -bit unsigned integers,
where each pair of them keeps higher and lower 32 -bits of 64 -bit unsigned integer respectively
Expected stack state :
[iword0, iword1, iword2, iword3, iword4, iword5, iword6, iword7,
iword8, iword9, iword10, iword11, iword12, iword13, iword14, iword15, ... ]
Final stack state :
[oword0, oword1, oword2, oword3, oword4, oword5, oword6, oword7, ... ]
See https://github.com/itzmeanjan/merklize-sha/blob/1d35aae9da7fed20127489f362b4bc93242a516c/include/keccak_256.hpp#L232-L257
|