Skip to content

Commit 3382b0e

Browse files
committed
Merge pull request #340 from mmcco/neg
Remove needless helper function negative()
2 parents 9e5d86c + f8492f3 commit 3382b0e

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/curve25519.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,12 +1405,6 @@ fn equal(b: u8, c: u8) -> i32 {
14051405

14061406

14071407

1408-
fn negative(b: i8) -> u8 {
1409-
let mut x = (b as i64) as u64;
1410-
x >>= 63; /* 1: yes; 0: no */
1411-
x as u8
1412-
}
1413-
14141408
impl GePrecomp {
14151409
fn zero() -> GePrecomp {
14161410
GePrecomp {
@@ -1427,7 +1421,7 @@ impl GePrecomp {
14271421
}
14281422

14291423
pub fn select(pos: usize, b: i8) -> GePrecomp {
1430-
let bnegative: u8 = negative(b);
1424+
let bnegative = (b as u8) >> 7;
14311425
let babs: u8 = (b - (((-(bnegative as i8)) & b) << 1)) as u8;
14321426
let mut t = GePrecomp::zero();
14331427
t.maybe_set(&GE_PRECOMP_BASE[pos][0], equal(babs, 1));

0 commit comments

Comments
 (0)