diff --git a/src/field.rs b/src/field.rs index 2f1301f..5b7885f 100644 --- a/src/field.rs +++ b/src/field.rs @@ -179,49 +179,7 @@ impl FieldElement { FieldElement([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) } - /// Overwrite this FieldElement with one of the inputs without branching. - /// Like `conditional_assign`, but chooses between two inputs instead of - /// one input and the original value. - /// - /// If `choice == 0`, replace `self` with `f`: - /// - /// ``` - /// # use curve25519_dalek::field::FieldElement; - /// let f = FieldElement([1,1,1,1,1,1,1,1,1,1]); - /// let g = FieldElement([2,2,2,2,2,2,2,2,2,2]); - /// let mut h = FieldElement([0,0,0,0,0,0,0,0,0,0]); - /// h.conditional_choose(&f, &g, 0); - /// assert!(h == f); - /// ``` - /// - /// If `choice == 1`, replace `self` with `g`: - /// - /// ``` - /// # use curve25519_dalek::field::FieldElement; - /// # let f = FieldElement([1,1,1,1,1,1,1,1,1,1]); - /// # let g = FieldElement([2,2,2,2,2,2,2,2,2,2]); - /// # let mut h = FieldElement([0,0,0,0,0,0,0,0,0,0]); - /// h.conditional_choose(&f, &g, 1); - /// assert!(h == g); - /// ``` - /// - /// # Preconditions - /// - /// * `b` in {0,1} - pub fn conditional_choose(&mut self, - f: &FieldElement, - g: &FieldElement, - choice: u8) - { - let mask = -(choice as Limb); - for i in 0..10 { - self[i] = f[i] ^ (mask & (f[i] ^ g[i])); - } - } - - /// Conditionally assign the Limbs of another FieldElement to this - /// one. Like `conditional_choose`, but choosing between one - /// input and the original value. + /// Conditionally assign another FieldElement to this one. /// /// If `choice == 0`, replace `self` with `self`: ///