Skip to content

Commit 999e0c9

Browse files
authored
ed448-goldilocks: reject identity points in Group::try_from_rng() (#1347)
1 parent 9e8656b commit 999e0c9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

ed448-goldilocks/src/decaf/points.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ impl Group for DecafPoint {
177177
let mut bytes = DecafPointRepr::default();
178178

179179
loop {
180-
rng.try_fill_bytes(bytes.as_mut())?;
181-
if let Some(point) = Self::from_bytes(&bytes).into() {
180+
rng.try_fill_bytes(&mut bytes)?;
181+
if let Some(point) = Self::from_bytes(&bytes)
182+
.into_option()
183+
.filter(|&point| point != Self::IDENTITY)
184+
{
182185
return Ok(point);
183186
}
184187
}

ed448-goldilocks/src/edwards/extended.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ impl Group for EdwardsPoint {
344344
let mut bytes = Array::default();
345345

346346
loop {
347-
rng.try_fill_bytes(bytes.as_mut())?;
348-
if let Some(point) = Self::from_bytes(&bytes).into() {
347+
rng.try_fill_bytes(&mut bytes)?;
348+
if let Some(point) = Self::from_bytes(&bytes)
349+
.into_option()
350+
.filter(|&point| point != Self::IDENTITY)
351+
{
349352
return Ok(point);
350353
}
351354
}

0 commit comments

Comments
 (0)