diff --git a/crypto/dleq/src/cross_group/mod.rs b/crypto/dleq/src/cross_group/mod.rs index f97ee390..c08ff7b2 100644 --- a/crypto/dleq/src/cross_group/mod.rs +++ b/crypto/dleq/src/cross_group/mod.rs @@ -55,10 +55,13 @@ pub(crate) fn read_point(r: &mut R) -> std::io::Result::from(point) else { + Err(std::io::Error::new(std::io::ErrorKind::Other, "invalid point"))? + }; + if point.to_bytes().as_ref() != repr.as_ref() { + Err(std::io::Error::new(std::io::ErrorKind::Other, "non-canonical point"))?; } - Ok(point.unwrap()) + Ok(point) } /// A pair of generators, one committing to values (primary), one blinding (alt), for an elliptic