(secret: [u8; 32], their_pubkey: [u8; 32])
| 10 | use x25519_dalek::{PublicKey, StaticSecret}; |
| 11 | |
| 12 | pub fn dh_agree(secret: [u8; 32], their_pubkey: [u8; 32]) -> [u8; 32] { |
| 13 | let secret = StaticSecret::from(secret); |
| 14 | let their_public = PublicKey::from(their_pubkey); |
| 15 | let shared_secret = secret.diffie_hellman(&their_public); |
| 16 | shared_secret.to_bytes() |
| 17 | } |
| 18 | |
| 19 | pub fn dh_decrypt(secret: [u8; 32], ciphertext: &[u8]) -> Result<Vec<u8>> { |
| 20 | // Extract components (matching JS implementation) |