Skip to content

Commit

Permalink
ec/suite_b: Minimize scope of CommonOps members.
Browse files Browse the repository at this point in the history
Callers outside of `ops` use `Modulus` members instead of using
`CommonOps` directly.
  • Loading branch information
briansmith committed Dec 11, 2024
1 parent aca068c commit 01742ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ec/suite_b/ecdsa/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl EcdsaKeyPair {
n.add_assign(&mut e_plus_dr, &e);
scalar_ops.scalar_product(&k_inv, &e_plus_dr, cpu)
};
if cops.is_zero(&s) {
if n.is_zero(&s) {
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions src/ec/suite_b/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Modulus<Q> {

impl CommonOps {
#[inline]
pub fn is_zero<M, E: Encoding>(&self, a: &elem::Elem<M, E>) -> bool {
fn is_zero<M, E: Encoding>(&self, a: &elem::Elem<M, E>) -> bool {
let num_limbs = self.num_limbs.into();
limbs_are_zero_constant_time(&a.limbs[..num_limbs]).leak()
}
Expand Down Expand Up @@ -242,7 +242,7 @@ impl Modulus<Q> {
}

impl CommonOps {
pub(super) fn point_sum(&self, a: &Point, b: &Point, _cpu: cpu::Features) -> Point {
fn point_sum(&self, a: &Point, b: &Point, _cpu: cpu::Features) -> Point {
let mut r = Point::new_at_infinity();
unsafe {
(self.point_add_jacobian_impl)(r.xyz.as_mut_ptr(), a.xyz.as_ptr(), b.xyz.as_ptr())
Expand Down Expand Up @@ -635,7 +635,7 @@ mod tests {
let q = &cops.elem_modulus(cpu::features());
let mut x = Elem::from(&ops.q_minus_n);
q.add_assign(&mut x, &Elem::from(&cops.n));
assert!(cops.is_zero(&x));
assert!(q.is_zero(&x));
}

#[test]
Expand Down

0 comments on commit 01742ba

Please sign in to comment.