mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-05 20:10:35 +00:00
Check xy is nonnegative, y nonzero in decoding.
This commit is contained in:
parent
5daa217b18
commit
95bf09a335
1 changed files with 10 additions and 1 deletions
11
src/decaf.rs
11
src/decaf.rs
|
|
@ -83,7 +83,16 @@ impl CompressedDecaf {
|
|||
let Y = &w * &Z;
|
||||
let T = &w * &X;
|
||||
|
||||
Some(DecafPoint(ExtendedPoint{ X: X, Y: Y, Z: Z, T: T }))
|
||||
// "To decode the point, one must decode it to affine form
|
||||
// instead of projective, and check that xy is non-negative."
|
||||
//
|
||||
// XXX can we merge this inversion with the one above?
|
||||
let xy = &T * &Z.invert();
|
||||
if (Y.is_nonzero() & xy.is_nonnegative_decaf()) == 1u8 {
|
||||
Some(DecafPoint(ExtendedPoint{ X: X, Y: Y, Z: Z, T: T }))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue