pub struct SecretScalar<T: SecureSanitize> { /* private fields */ }Expand description
Owned secret-controlled scalar with clear-on-drop storage.
This type intentionally has no generic borrow or exposure closure. Reviewed data-oblivious operations are provided through trait-bounded methods, while conversion back to an ordinary value is a consuming, reason-bearing declassification.
Clearing covers this wrapper’s live storage. Rust moves, compiler-created temporaries, registers, and caller-created copies remain outside that guarantee.
Implementations§
Source§impl<T: SecureSanitize> SecretScalar<T>
impl<T: SecureSanitize> SecretScalar<T>
Sourcepub fn ct_eq(&self, other: &Self) -> Choicewhere
T: ConstantTimeEq,
pub fn ct_eq(&self, other: &Self) -> Choicewhere
T: ConstantTimeEq,
Compare two wrapped scalars without declassifying the result.
Sourcepub fn ct_cmp(&self, other: &Self) -> CtOrderingwhere
T: ConstantTimeOrd,
pub fn ct_cmp(&self, other: &Self) -> CtOrderingwhere
T: ConstantTimeOrd,
Order two wrapped scalars without declassifying the result.
Sourcepub fn conditional_select(left: &Self, right: &Self, choice: Choice) -> Selfwhere
T: ConditionallySelectable,
pub fn conditional_select(left: &Self, right: &Self, choice: Choice) -> Selfwhere
T: ConditionallySelectable,
Select one wrapped scalar without consuming either source.
The returned wrapper owns a third value. Both source wrappers remain live and retain their independent clear-on-drop obligations.
Sourcepub fn declassify(self, reason: &'static str) -> T
pub fn declassify(self, reason: &'static str) -> T
Explicitly reveal this scalar as a normal value.
The caller assumes responsibility for sanitizing the returned value. The consumed wrapper is left empty so its destructor cannot clean the moved value a second time.