Skip to content

Commit

Permalink
manually clamp x25519 scalar for consistency with old version
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Sep 20, 2023
1 parent bff120c commit 684cafa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions indy-data-types/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::convert::TryFrom;
use std::str::FromStr;

#[cfg(feature = "ed25519")]
use curve25519_dalek::edwards::CompressedEdwardsY;
use curve25519_dalek::{edwards::CompressedEdwardsY, scalar::clamp_integer};
#[cfg(feature = "ed25519")]
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey};
#[cfg(feature = "ed25519")]
Expand Down Expand Up @@ -77,7 +77,7 @@ impl PrivateKey {
KeyType::ED25519 => {
let mut hash = sha2::Sha512::digest(&self.key[..32]);
let x_sk =
x25519_dalek::StaticSecret::from(<[u8; 32]>::try_from(&hash[..32]).unwrap());
x25519_dalek::StaticSecret::from(clamp_integer(hash[..32].try_into().unwrap()));
hash.zeroize();
Ok(Self::new(x_sk.to_bytes(), Some(KeyType::X25519)))
}
Expand Down

0 comments on commit 684cafa

Please sign in to comment.