@@ -871,7 +871,7 @@ pub trait ConstantTimeGreater {
871
871
///
872
872
///```
873
873
/// use subtle::{
874
- /// Choice, IteratedOperation, ConstantTimeEq, IteratedEq, ConstantTimeGreater, IteratedGreater ,
874
+ /// Choice, IteratedOperation, ConstantTimeEq, IteratedEq, ConstantTimeGreater, LexicographicIteratedGreater ,
875
875
/// };
876
876
///
877
877
/// struct S { pub len: usize, pub live: bool };
@@ -885,7 +885,7 @@ pub trait ConstantTimeGreater {
885
885
/// }
886
886
/// impl ConstantTimeGreater for S {
887
887
/// fn ct_gt(&self, other: &Self) -> Choice {
888
- /// let mut x = IteratedGreater ::initiate();
888
+ /// let mut x = LexicographicIteratedGreater ::initiate();
889
889
/// x.apply_gt(&(self.len as u64), &(other.len as u64));
890
890
/// x.apply_gt(&(self.live as u8), &(other.live as u8));
891
891
/// x.extract_result()
@@ -900,24 +900,24 @@ pub trait ConstantTimeGreater {
900
900
/// assert_eq!(1, s2.ct_gt(&s1).unwrap_u8());
901
901
/// assert_eq!(1, s3.ct_gt(&s2).unwrap_u8());
902
902
///```
903
- pub struct IteratedGreater {
903
+ pub struct LexicographicIteratedGreater {
904
904
was_gt : Choice ,
905
905
was_lt : Choice ,
906
906
}
907
907
908
- impl IteratedOperation for IteratedGreater {
908
+ impl IteratedOperation for LexicographicIteratedGreater {
909
909
fn initiate ( ) -> Self {
910
910
Self {
911
- was_gt : Choice :: from ( 0 ) ,
912
- was_lt : Choice :: from ( 0 ) ,
911
+ was_gt : Choice :: of_bool ( false ) ,
912
+ was_lt : Choice :: of_bool ( false ) ,
913
913
}
914
914
}
915
915
fn extract_result ( self ) -> Choice {
916
916
self . was_gt . into ( )
917
917
}
918
918
}
919
919
920
- impl IteratedGreater {
920
+ impl LexicographicIteratedGreater {
921
921
/// Unconditionally modify internal state with result of two directed "greater" comparisons.
922
922
#[ inline]
923
923
pub fn apply_gt < T : ConstantTimeGreater + ?Sized > ( & mut self , a : & T , b : & T ) {
@@ -1022,7 +1022,7 @@ impl<T: ConstantTimeGreater + ConstantTimeEq> ConstantTimeGreater for [T] {
1022
1022
}
1023
1023
}
1024
1024
1025
- let mut x = IteratedGreater :: initiate ( ) ;
1025
+ let mut x = LexicographicIteratedGreater :: initiate ( ) ;
1026
1026
for ( ai, bi) in self . iter ( ) . zip ( _rhs. iter ( ) ) {
1027
1027
x. apply_gt ( ai, bi) ;
1028
1028
}
@@ -1077,8 +1077,8 @@ pub trait ConstantTimeLess: ConstantTimeGreater {
1077
1077
///
1078
1078
///```
1079
1079
/// use subtle::{
1080
- /// Choice, IteratedOperation, ConstantTimeEq, IteratedEq, ConstantTimeGreater, IteratedGreater ,
1081
- /// ConstantTimeLess, IteratedLess ,
1080
+ /// Choice, IteratedOperation, ConstantTimeEq, IteratedEq, ConstantTimeGreater, LexicographicIteratedGreater ,
1081
+ /// ConstantTimeLess, LexicographicIteratedLess ,
1082
1082
/// };
1083
1083
///
1084
1084
/// struct S { pub len: usize, pub live: bool };
@@ -1092,15 +1092,15 @@ pub trait ConstantTimeLess: ConstantTimeGreater {
1092
1092
/// }
1093
1093
/// impl ConstantTimeGreater for S {
1094
1094
/// fn ct_gt(&self, other: &Self) -> Choice {
1095
- /// let mut x = IteratedGreater ::initiate();
1095
+ /// let mut x = LexicographicIteratedGreater ::initiate();
1096
1096
/// x.apply_gt(&(self.len as u64), &(other.len as u64));
1097
1097
/// x.apply_gt(&(self.live as u8), &(other.live as u8));
1098
1098
/// x.extract_result()
1099
1099
/// }
1100
1100
/// }
1101
1101
/// impl ConstantTimeLess for S {
1102
1102
/// fn ct_lt(&self, other: &Self) -> Choice {
1103
- /// let mut x = IteratedLess ::initiate();
1103
+ /// let mut x = LexicographicIteratedLess ::initiate();
1104
1104
/// x.apply_lt(&(self.len as u64), &(other.len as u64));
1105
1105
/// x.apply_lt(&(self.live as u8), &(other.live as u8));
1106
1106
/// x.extract_result()
@@ -1115,24 +1115,24 @@ pub trait ConstantTimeLess: ConstantTimeGreater {
1115
1115
/// assert_eq!(1, s2.ct_gt(&s1).unwrap_u8());
1116
1116
/// assert_eq!(1, s2.ct_lt(&s3).unwrap_u8());
1117
1117
///```
1118
- pub struct IteratedLess {
1118
+ pub struct LexicographicIteratedLess {
1119
1119
was_lt : Choice ,
1120
1120
was_gt : Choice ,
1121
1121
}
1122
1122
1123
- impl IteratedOperation for IteratedLess {
1123
+ impl IteratedOperation for LexicographicIteratedLess {
1124
1124
fn initiate ( ) -> Self {
1125
1125
Self {
1126
- was_lt : Choice :: from ( 0 ) ,
1127
- was_gt : Choice :: from ( 0 ) ,
1126
+ was_lt : Choice :: of_bool ( false ) ,
1127
+ was_gt : Choice :: of_bool ( false ) ,
1128
1128
}
1129
1129
}
1130
1130
fn extract_result ( self ) -> Choice {
1131
1131
self . was_lt . into ( )
1132
1132
}
1133
1133
}
1134
1134
1135
- impl IteratedLess {
1135
+ impl LexicographicIteratedLess {
1136
1136
/// Unconditionally modify internal state with result of two directed "less" comparisons.
1137
1137
#[ inline]
1138
1138
pub fn apply_lt < T : ConstantTimeLess + ?Sized > ( & mut self , a : & T , b : & T ) {
0 commit comments