mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-06-28 03:59:27 +00:00
* feat: http server based key package registry * chore: instructions on running the registration service * chore: remove duplicate post param * chore: revert out sourced account id for multi devices support * feat: signature on account id and key packages * chore: include http registry in contact registry module * refactor: use device id for retrieve key package * chore: use string for device id * feat: server verification on the register * chore: doc the smoke test * chore: fix data folder non exist * chore: use payload for register and retrieve * chore: fix clippy
64 lines
1.9 KiB
Rust
64 lines
1.9 KiB
Rust
use crypto::{Ed25519Signature, Ed25519SigningKey, Ed25519VerifyingKey};
|
|
use openmls::prelude::SignatureScheme;
|
|
use openmls_traits::signatures::Signer;
|
|
|
|
use crate::{AccountId, IdentityProvider};
|
|
|
|
/// Logos Account represents a single account across
|
|
/// multiple installations and services.
|
|
///
|
|
/// Deprecated!
|
|
pub struct LogosAccount {
|
|
id: AccountId,
|
|
signing_key: Ed25519SigningKey,
|
|
verifying_key: Ed25519VerifyingKey,
|
|
}
|
|
|
|
impl LogosAccount {
|
|
/// Create a test LogosAccount. The `AccountId` is derived from the
|
|
/// generated Ed25519 verifying key (hex-encoded) so signatures over the
|
|
/// id can be verified by anyone holding the id alone.
|
|
/// The supplied `_display_name` is currently ignored — id is the key.
|
|
/// This should only be used during MLS integration. Not suitable for production use.
|
|
/// TODO: (P1) Remove once implementation is ready.
|
|
pub fn new_test(_display_name: impl Into<String>) -> Self {
|
|
let signing_key = Ed25519SigningKey::generate();
|
|
let verifying_key = signing_key.verifying_key();
|
|
let id = AccountId::new(hex::encode(verifying_key.as_ref()));
|
|
Self {
|
|
id,
|
|
signing_key,
|
|
verifying_key,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Signer for LogosAccount {
|
|
// TODO: (P2) Remove OpenMLS dependency to make accounts more portable
|
|
fn sign(&self, payload: &[u8]) -> Result<Vec<u8>, openmls_traits::signatures::SignerError> {
|
|
Ok(self.signing_key.sign(payload).as_ref().to_vec())
|
|
}
|
|
|
|
fn signature_scheme(&self) -> SignatureScheme {
|
|
SignatureScheme::ED25519
|
|
}
|
|
}
|
|
|
|
impl IdentityProvider for LogosAccount {
|
|
fn account_id(&self) -> &AccountId {
|
|
&self.id
|
|
}
|
|
|
|
fn display_name(&self) -> String {
|
|
self.id.to_string()
|
|
}
|
|
|
|
fn sign(&self, payload: &[u8]) -> Ed25519Signature {
|
|
self.signing_key.sign(payload)
|
|
}
|
|
|
|
fn public_key(&self) -> &Ed25519VerifyingKey {
|
|
&self.verifying_key
|
|
}
|
|
}
|