Skip to content

Commit

Permalink
we also need to save the ed25519 private key
Browse files Browse the repository at this point in the history
  • Loading branch information
uhoreg committed Dec 16, 2024
1 parent 764c0d0 commit 048b0f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/olm/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ mod dehydrated_device {
pub(super) struct Pickle {
version: u32,
private_curve25519_key: Box<[u8; 32]>,
private_ed25519_key: Box<[u8; 64]>,
one_time_keys: Vec<OneTimeKey>,
opt_fallback_key: OptFallbackKey,
}
Expand All @@ -822,6 +823,7 @@ mod dehydrated_device {
Self {
version: PICKLE_VERSION,
private_curve25519_key: account.diffie_hellman_key.secret_key().to_bytes(),
private_ed25519_key: account.signing_key.expanded_secret_key(),
one_time_keys,
opt_fallback_key: OptFallbackKey { fallback_key },
}
Expand All @@ -848,7 +850,7 @@ mod dehydrated_device {
};

Ok(Self {
signing_key: Ed25519Keypair::new(), // random key, just to satisfy the contract
signing_key: Ed25519Keypair::from_expanded_key(&pickle.private_ed25519_key)?,
diffie_hellman_key: Curve25519Keypair::from_secret_key(
&pickle.private_curve25519_key,
),
Expand Down
2 changes: 0 additions & 2 deletions src/types/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,13 @@ impl Ed25519Keypair {
}
}

#[cfg(feature = "libolm-compat")]
pub(crate) fn from_expanded_key(secret_key: &[u8; 64]) -> Result<Self, crate::KeyError> {
let secret_key = ExpandedSecretKey::from_bytes(secret_key);
let public_key = secret_key.public_key();

Ok(Self { secret_key: secret_key.into(), public_key })
}

#[cfg(feature = "libolm-compat")]
pub(crate) fn expanded_secret_key(&self) -> Box<[u8; 64]> {
use sha2::Digest;

Expand Down

0 comments on commit 048b0f3

Please sign in to comment.