From 964741463e67ab225d56b2f582bfbd2dfd82ac17 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 20 Aug 2023 10:54:26 -0400 Subject: [PATCH] vld0 work --- veilid-core/src/crypto/vld0/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/veilid-core/src/crypto/vld0/mod.rs b/veilid-core/src/crypto/vld0/mod.rs index a763e7a1..cb27da7a 100644 --- a/veilid-core/src/crypto/vld0/mod.rs +++ b/veilid-core/src/crypto/vld0/mod.rs @@ -27,8 +27,8 @@ fn secret_to_x25519_sk(secret: &SecretKey) -> VeilidAPIResult .chain_update(secret.bytes) .finalize() .into(); - let mut output = [0u8; 32]; - output.copy_from_slice(&hash[..32]); + let mut output = [0u8; SECRET_KEY_LENGTH]; + output.copy_from_slice(&hash[..SECRET_KEY_LENGTH]); Ok(xd::StaticSecret::from(output)) } @@ -134,7 +134,11 @@ impl CryptoSystem for CryptoSystemVLD0 { let pk_xd = public_to_x25519_pk(&key)?; let sk_xd = secret_to_x25519_sk(&secret)?; - Ok(SharedSecret::new(sk_xd.diffie_hellman(&pk_xd).to_bytes())) + let output = self + .generate_hash(&sk_xd.diffie_hellman(&pk_xd).to_bytes()) + .bytes; + + Ok(SharedSecret::new(output)) } fn generate_keypair(&self) -> KeyPair { vld0_generate_keypair()