Skip to content

Commit 3fce16b

Browse files
committed
Factor out CommonOps::is_zero() for future use in scalar inversion.
1 parent b329d48 commit 3fce16b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ec/suite_b/ops/ops.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,18 @@ impl CommonOps {
165165
unary_op(self.elem_sqr_mont, a)
166166
}
167167

168+
#[inline]
169+
pub fn is_zero<M, E: Encoding>(&self, a: &elem::Elem<M, E>) -> bool {
170+
limbs_are_zero_constant_time(&a.limbs[..self.num_limbs]) ==
171+
LimbMask::True
172+
}
173+
168174
pub fn elem_verify_is_not_zero(&self, a: &Elem<R>)
169175
-> Result<(), error::Unspecified> {
170-
match limbs_are_zero_constant_time(&a.limbs[..self.num_limbs]) {
171-
LimbMask::False => Ok(()),
172-
_ => Err(error::Unspecified),
176+
if self.is_zero(a) {
177+
Err(error::Unspecified)
178+
} else {
179+
Ok(())
173180
}
174181
}
175182

0 commit comments

Comments
 (0)