Skip to content

Commit

Permalink
Secret key should only use the x coordinate of a point
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamadazmy committed Feb 20, 2023
1 parent 081db67 commit ecaa38d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/peer/e2e/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ impl Pair {
pub(crate) fn shared<K: AsRef<[u8]>>(&self, pk: K) -> Result<[u8; SHARED_KEY_SIZE], Error> {
let pk = PublicKey::from_slice(pk.as_ref())?;

let point = secp256k1::ecdh::shared_secret_point(&pk, &self.0.secret_key());
// we take the x coordinate of the secret point.
let point = &secp256k1::ecdh::shared_secret_point(&pk, &self.0.secret_key())[..32];
use sha2::{Digest, Sha256};

let mut sh = Sha256::new();
Expand Down

0 comments on commit ecaa38d

Please sign in to comment.