Skip to content

Commit

Permalink
fix: zeroize temporary scalar value
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Aug 27, 2023
1 parent 1e6f603 commit f24bda1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ristretto/pedersen/extended_commitment_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use curve25519_dalek::{
scalar::Scalar,
traits::{Identity, MultiscalarMul},
};
use zeroize::Zeroize;

#[cfg(feature = "precomputed_tables")]
use crate::ristretto::pedersen::scalar_mul_with_pre_computation_tables;
Expand Down Expand Up @@ -84,7 +85,7 @@ impl ExtendedPedersenCommitmentFactory {
}

/// Creates a Pedersen commitment using the value scalar and a blinding factor vector
pub fn commit_scalars(
fn commit_scalars(
&self,
value: &Scalar,
blinding_factors: &[Scalar],
Expand Down Expand Up @@ -166,8 +167,9 @@ impl ExtendedHomomorphicCommitmentFactory for ExtendedPedersenCommitmentFactory
k_vec: &[RistrettoSecretKey],
v: &RistrettoSecretKey,
) -> Result<PedersenCommitment, CommitmentError> {
let blinding_factors: Vec<Scalar> = k_vec.iter().map(|k| k.0).collect();
let mut blinding_factors: Vec<Scalar> = k_vec.iter().map(|k| k.0).collect();
let c = self.commit_scalars(&v.0, &blinding_factors)?;
blinding_factors.zeroize();
Ok(HomomorphicCommitment(RistrettoPublicKey::new_from_pk(c)))
}

Expand Down

0 comments on commit f24bda1

Please sign in to comment.