mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Ensure canonical points in the cross-group DLEq proof
This commit is contained in:
@@ -55,10 +55,13 @@ pub(crate) fn read_point<R: Read, G: PrimeGroup>(r: &mut R) -> std::io::Result<G
|
|||||||
let mut repr = G::Repr::default();
|
let mut repr = G::Repr::default();
|
||||||
r.read_exact(repr.as_mut())?;
|
r.read_exact(repr.as_mut())?;
|
||||||
let point = G::from_bytes(&repr);
|
let point = G::from_bytes(&repr);
|
||||||
if point.is_none().into() {
|
let Some(point) = Option::<G>::from(point) else {
|
||||||
Err(std::io::Error::new(std::io::ErrorKind::Other, "invalid point"))?;
|
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
|
/// A pair of generators, one committing to values (primary), one blinding (alt), for an elliptic
|
||||||
|
|||||||
Reference in New Issue
Block a user