Function consistenttime::ct_select_u8
[−]
[src]
pub extern fn ct_select_u8(flag: bool, x: u8, y: u8) -> u8
Optional swapping.
Allow to set a varible optionally at the same speed without branching, or changing speed.
Returns X if flag == True.
Returns Y if flag == False.
At compile time this becomes a CMOV. This is a brach. The branch misprediction cost is ~20cycles. And if this is incurred does not depend on the input, but the random state of our machine + quantum winds.
This should provide a consistent guarantee of speed.