mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-08 21:00:40 +00:00
Remove unused conditional_choose function
This commit is contained in:
parent
098ff2ffca
commit
c92ebdd0ac
1 changed files with 1 additions and 43 deletions
44
src/field.rs
44
src/field.rs
|
|
@ -179,49 +179,7 @@ impl FieldElement {
|
||||||
FieldElement([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ])
|
FieldElement([ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Overwrite this FieldElement with one of the inputs without branching.
|
/// Conditionally assign another FieldElement to this one.
|
||||||
/// 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.
|
|
||||||
///
|
///
|
||||||
/// If `choice == 0`, replace `self` with `self`:
|
/// If `choice == 0`, replace `self` with `self`:
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue