mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
Fix sign error
This commit is contained in:
parent
6b3dbf6870
commit
5daa217b18
1 changed files with 3 additions and 6 deletions
|
|
@ -159,15 +159,12 @@ impl DecafPoint {
|
||||||
r.conditional_negate(m2uZ.is_negative_decaf());
|
r.conditional_negate(m2uZ.is_negative_decaf());
|
||||||
|
|
||||||
// Step 4: Compute s = | u(r(aZX - dYT)+Y)/a|
|
// Step 4: Compute s = | u(r(aZX - dYT)+Y)/a|
|
||||||
// = |-u(r(aZX - dYT)+Y)|
|
// = |u(r(-ZX - dYT)+Y)| since a = -1
|
||||||
let minus_ZX = -&(&self.0.Z * &X);
|
let minus_ZX = -&(&self.0.Z * &X);
|
||||||
let dYT = &constants::d * &(&Y * &T);
|
let dYT = &constants::d * &(&Y * &T);
|
||||||
// Compute s = u(r(aZX - dYT)+Y)
|
// Compute s = u(r(aZX - dYT)+Y) and cnegate for abs
|
||||||
let mut s = &u * &(&(&r * &(&minus_ZX - &dYT)) + &Y);
|
let mut s = &u * &(&(&r * &(&minus_ZX - &dYT)) + &Y);
|
||||||
// Set s <- |-s|
|
let neg = s.is_negative_decaf();
|
||||||
// XXX I think there's a sign error somewhere?
|
|
||||||
// flipping the sign here makes the tests pass
|
|
||||||
let neg = s.is_nonnegative_decaf();
|
|
||||||
s.conditional_negate(neg);
|
s.conditional_negate(neg);
|
||||||
CompressedDecaf(s.to_bytes())
|
CompressedDecaf(s.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue