ec suite_b: Make oneRR_mod_n private.

This commit is contained in:
Brian Smith 2023-12-03 12:46:18 -08:00
parent f55712e909
commit ed2b1d7054
2 changed files with 8 additions and 5 deletions

View File

@ -156,10 +156,7 @@ impl EcdsaKeyPair {
) -> Result<Self, error::KeyRejected> {
let (seed, public_key) = key_pair.split();
let d = private_key::private_key_as_scalar(alg.private_key_ops, &seed);
let d = alg
.private_scalar_ops
.scalar_ops
.scalar_product(&d, &alg.private_scalar_ops.oneRR_mod_n);
let d = alg.private_scalar_ops.to_mont(&d);
let nonce_key = NonceRandomKey::new(alg, &seed, rng)?;
Ok(Self {

View File

@ -321,7 +321,13 @@ impl PublicScalarOps {
pub struct PrivateScalarOps {
pub scalar_ops: &'static ScalarOps,
pub oneRR_mod_n: Scalar<RR>, // 1 * R**2 (mod n). TOOD: Use One<RR>.
oneRR_mod_n: Scalar<RR>, // 1 * R**2 (mod n). TOOD: Use One<RR>.
}
impl PrivateScalarOps {
pub fn to_mont(&self, s: &Scalar<Unencoded>) -> Scalar<R> {
self.scalar_ops.scalar_product(s, &self.oneRR_mod_n)
}
}
// XXX: Inefficient and unnecessarily depends on `PrivateKeyOps`. TODO: implement interleaved wNAF