diff --git a/curve25519-dalek/src/backend/serial/fiat_u32/field.rs b/curve25519-dalek/src/backend/serial/fiat_u32/field.rs index 7b95add6..d121928e 100644 --- a/curve25519-dalek/src/backend/serial/fiat_u32/field.rs +++ b/curve25519-dalek/src/backend/serial/fiat_u32/field.rs @@ -282,13 +282,13 @@ impl FieldElement2625 { // start from least significant go to most significant for i in 0..10 { - _ul = self.0[i]; - _vl = other.0[i]; + _ul = self.0[i]; + _vl = other.0[i]; - gt_i = _ul > _vl; - eq_i = _ul == _vl; + gt_i = _ul > _vl; + eq_i = _ul == _vl; - c_gt = gt_i || (eq_i & c_gt); + c_gt = gt_i || (eq_i & c_gt); } Choice::from(c_gt as u8) diff --git a/curve25519-dalek/src/backend/serial/fiat_u64/field.rs b/curve25519-dalek/src/backend/serial/fiat_u64/field.rs index d1fee439..1b28b2bc 100644 --- a/curve25519-dalek/src/backend/serial/fiat_u64/field.rs +++ b/curve25519-dalek/src/backend/serial/fiat_u64/field.rs @@ -260,7 +260,6 @@ impl FieldElement51 { output } - /// Returns 1 if self is greater than the other and 0 otherwise // strategy: check if b-a overflows. if it does not overflow, then a was larger pub(crate) fn gt_direct(&self, other: &Self) -> Choice { @@ -274,13 +273,13 @@ impl FieldElement51 { // start from least significant go to most significant for i in 0..5 { - _ul = self.0[i]; - _vl = other.0[i]; + _ul = self.0[i]; + _vl = other.0[i]; - gt_i = _ul > _vl; - eq_i = _ul == _vl; + gt_i = _ul > _vl; + eq_i = _ul == _vl; - c_gt = gt_i || (eq_i & c_gt); + c_gt = gt_i || (eq_i & c_gt); } Choice::from(c_gt as u8) diff --git a/curve25519-dalek/src/backend/serial/u32/field.rs b/curve25519-dalek/src/backend/serial/u32/field.rs index 7ebe4cf2..a7471285 100644 --- a/curve25519-dalek/src/backend/serial/u32/field.rs +++ b/curve25519-dalek/src/backend/serial/u32/field.rs @@ -615,13 +615,13 @@ impl FieldElement2625 { // start from least significant go to most significant for i in 0..10 { - _ul = self.0[i]; - _vl = other.0[i]; + _ul = self.0[i]; + _vl = other.0[i]; - gt_i = _ul > _vl; - eq_i = _ul == _vl; + gt_i = _ul > _vl; + eq_i = _ul == _vl; - c_gt = gt_i || (eq_i & c_gt); + c_gt = gt_i || (eq_i & c_gt); } Choice::from(c_gt as u8) diff --git a/curve25519-dalek/src/backend/serial/u64/field.rs b/curve25519-dalek/src/backend/serial/u64/field.rs index cde51842..ada14204 100644 --- a/curve25519-dalek/src/backend/serial/u64/field.rs +++ b/curve25519-dalek/src/backend/serial/u64/field.rs @@ -586,13 +586,13 @@ impl FieldElement51 { // start from least significant go to most significant for i in 0..5 { - _ul = self.0[i]; - _vl = other.0[i]; + _ul = self.0[i]; + _vl = other.0[i]; - gt_i = _ul > _vl; - eq_i = _ul == _vl; + gt_i = _ul > _vl; + eq_i = _ul == _vl; - c_gt = gt_i || (eq_i & c_gt); + c_gt = gt_i || (eq_i & c_gt); } Choice::from(c_gt as u8) diff --git a/curve25519-dalek/src/field.rs b/curve25519-dalek/src/field.rs index b95c77e2..4b99ff53 100644 --- a/curve25519-dalek/src/field.rs +++ b/curve25519-dalek/src/field.rs @@ -313,10 +313,9 @@ impl ConstantTimeGreater for FieldElement { /// If self > other return Choice(1), otherwise return Choice(0) /// fn ct_gt(&self, other: &FieldElement) -> Choice { - - // One possible failure for is if self.or other falls in 0..18 + // One possible failure for is if self or other falls in 0..18 // as s+p in 2^255-19..2^255-1. We can check this by - // converting to bytes and then back to FieldElement, + // converting to bytes and then back to FieldElement, // since our encoding routine is canonical the returned value // will always be compared properly. let a = FieldElement::from_bytes(&self.as_bytes()); @@ -520,11 +519,13 @@ mod test { // 2^255 - 1 = 18 let low_high_val = <[u8; 32]>::from_hex( "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - ).expect("should never fail"); + ) + .expect("should never fail"); // 32 let higher_low_val = <[u8; 32]>::from_hex( "0000000000000000000000000000000000000000000000000000000000000020", - ).expect("should never fail"); + ) + .expect("should never fail"); let cases = [ (FieldElement::ONE, FieldElement::ZERO, true),