Trait aligned_cmov::CMov
source · pub trait CMov: Sized {
// Required method
fn cmov(&mut self, condition: Choice, src: &Self);
}
Expand description
CMov represents types that can be (obliviously) conditionally moved.
“Conditional move” means: if condition { *dest = *src }
The interesting case is when this must be side-channel resistant and
the condition cannot be leaked over CPU side-channels.
This API is object-oriented, and we take self = dest. This is good in rust because then you don’t have to name the type to call the function.
These are the types that we can hope to support with ORAM, and this API allows ORAM to be written in a generic way.
Note: Types that own dynamic memory cannot be CMov by design.
They also cannot be in an ORAM, by design.
If your type has nontrivial Drop
it is likely not reasonable to CMov
it
or put it in an ORAM.