Function consistenttime::ct_select_u16 [] [src]

pub extern fn ct_select_u16(flag: bool, x: u16, y: u16) -> u16

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.