I'm guessing they're some kind of standard function but what do they do and what do the names mean? A little explaination or link me to an article would be great.
1 Answers
The definitions given in FIPS 180-4 are $$\begin{align} \operatorname{Maj}(x,y,z)&=(x\wedge y)\oplus(x\wedge z)\oplus(y\wedge z)\\ \operatorname{Ch}(x,y,z)&=(x\wedge y)\oplus(\neg x\wedge z) \end{align}$$ where $\wedge$ is bitwise AND, $\oplus$ is bitwise exclusive-OR, and $\neg $ is bitwise negation. The functions are defined for bit vectors (of 32 bits in case fo SHA-256).
$\operatorname{Maj}$ stands for majority: for each bit index, that result bit is according to the majority of the 3 inputs bits for $x$ $y$ and $z$ at this index.
$\operatorname{Ch}$ stands for choose (source: poncho) or choice, as the $x$ input chooses if the output is from $y$ or from $z$. More precisely, for each bit index, that result bit is according to the bit from $y$ (or respectively $z$ ) at this index, depending on if the bit from $x$ at this index is 1 (or respectively 0).

- 140,762
- 12
- 307
- 587
vec_sel
intrinsic can be used for Ch, but I am looking for something for Maj. Are you aware of a Power8 instruction for Maj. (Sorry to ask. IBM docs on its in-core crypto don't really exist. I saw you jumped into hardware, and thought you might have an answer). – Feb 25 '18 at 12:08x ? y : z
for each bit. – forest Jan 29 '19 at 04:29