mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-06-30 21:20:09 +00:00
bump de-mls and adapt group_v2 to its new API
This commit is contained in:
parent
97eacc01a7
commit
0d04992ca8
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -1816,7 +1816,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "de-mls"
|
name = "de-mls"
|
||||||
version = "4.0.0"
|
version = "4.0.0"
|
||||||
source = "git+https://github.com/vacp2p/de-mls?tag=v4.0.0#425203056d4586115beef6559b49560095a15256"
|
source = "git+https://github.com/vacp2p/de-mls?branch=main#3056898d07519bc6d8fbf58ce5cb4e004e4cc932"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hashgraph-like-consensus",
|
"hashgraph-like-consensus",
|
||||||
"indexmap 2.14.0",
|
"indexmap 2.14.0",
|
||||||
@ -2104,7 +2104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -3707,7 +3707,7 @@ version = "0.50.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4993,7 +4993,7 @@ dependencies = [
|
|||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.12.1",
|
"linux-raw-sys 0.12.1",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -5051,7 +5051,7 @@ dependencies = [
|
|||||||
"security-framework",
|
"security-framework",
|
||||||
"security-framework-sys",
|
"security-framework-sys",
|
||||||
"webpki-root-certs",
|
"webpki-root-certs",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -5661,7 +5661,7 @@ dependencies = [
|
|||||||
"getrandom 0.4.2",
|
"getrandom 0.4.2",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix 1.1.4",
|
"rustix 1.1.4",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -6359,7 +6359,7 @@ version = "0.1.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@ -18,7 +18,7 @@ storage = { workspace = true }
|
|||||||
alloy = "2.0"
|
alloy = "2.0"
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
chat-proto = { git = "https://github.com/logos-messaging/chat_proto", rev = "37ec98a151f6d50aab2905802ac0a896477e62ea" }
|
chat-proto = { git = "https://github.com/logos-messaging/chat_proto", rev = "37ec98a151f6d50aab2905802ac0a896477e62ea" }
|
||||||
de-mls = { git = "https://github.com/vacp2p/de-mls", tag = "v4.0.0" }
|
de-mls = { git = "https://github.com/vacp2p/de-mls", branch = "main"}
|
||||||
double-ratchets = { path = "../double-ratchets" }
|
double-ratchets = { path = "../double-ratchets" }
|
||||||
hashgraph-like-consensus = "0.5.1"
|
hashgraph-like-consensus = "0.5.1"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|||||||
@ -7,16 +7,13 @@ use crate::{Content, WakeupService};
|
|||||||
use alloy::signers::local::PrivateKeySigner;
|
use alloy::signers::local::PrivateKeySigner;
|
||||||
use blake2::{Blake2b, Digest, digest::consts::U6};
|
use blake2::{Blake2b, Digest, digest::consts::U6};
|
||||||
use chat_proto::logoschat::encryption::{EncryptedPayload, Plaintext, encrypted_payload};
|
use chat_proto::logoschat::encryption::{EncryptedPayload, Plaintext, encrypted_payload};
|
||||||
use de_mls::defaults::{
|
|
||||||
DefaultConsensusPlugin, DefaultPeerScoring, DefaultStewardList, InMemoryPeerScoreStorage,
|
|
||||||
};
|
|
||||||
use de_mls::protos::de_mls::messages::v1::{
|
use de_mls::protos::de_mls::messages::v1::{
|
||||||
AppMessage as AppMessageProto, MemberWelcome, app_message,
|
AppMessage as AppMessageProto, MemberWelcome, app_message,
|
||||||
};
|
};
|
||||||
use de_mls::{
|
use de_mls::{
|
||||||
ConsensusPlugin, ConsensusServiceFor, Conversation, ConversationConfig, ConversationEvent,
|
Conversation, ConversationConfig, ConversationEvent, PeerScoringService, ScoringConfig,
|
||||||
DeterministicStewardList, PeerScoringService, ScoringConfig, StewardListConfig,
|
|
||||||
default_score_deltas,
|
default_score_deltas,
|
||||||
|
defaults::{DefaultConsensusPlugin, DefaultPeerScoring, InMemoryPeerScoreStorage},
|
||||||
};
|
};
|
||||||
use hashgraph_like_consensus::signing::EthereumConsensusSigner;
|
use hashgraph_like_consensus::signing::EthereumConsensusSigner;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
@ -48,27 +45,16 @@ fn rand_app_id() -> Arc<[u8]> {
|
|||||||
/// Peer-scoring plug-in: the library default over in-memory storage.
|
/// Peer-scoring plug-in: the library default over in-memory storage.
|
||||||
fn make_scoring() -> DefaultPeerScoring {
|
fn make_scoring() -> DefaultPeerScoring {
|
||||||
PeerScoringService::new(
|
PeerScoringService::new(
|
||||||
InMemoryPeerScoreStorage::new(),
|
InMemoryPeerScoreStorage::default(),
|
||||||
default_score_deltas(),
|
default_score_deltas(),
|
||||||
ScoringConfig::default(),
|
ScoringConfig::default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Steward-list plug-in: the library default, seedless — the library stamps the
|
|
||||||
/// conversation-id sort salt when it builds the conversation.
|
|
||||||
fn make_steward() -> DefaultStewardList {
|
|
||||||
DeterministicStewardList::empty(StewardListConfig::default())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Consensus service: the library default over a fresh in-memory store and a
|
/// Consensus service: the library default over a fresh in-memory store and a
|
||||||
/// random Ethereum consensus signer.
|
/// random Ethereum consensus signer.
|
||||||
fn make_consensus() -> ConsensusServiceFor<DefaultConsensusPlugin> {
|
fn make_consensus() -> DefaultConsensusPlugin {
|
||||||
ConsensusServiceFor::<DefaultConsensusPlugin>::new_with_components(
|
DefaultConsensusPlugin::new(EthereumConsensusSigner::new(PrivateKeySigner::random()))
|
||||||
DefaultConsensusPlugin::new_storage(),
|
|
||||||
DefaultConsensusPlugin::new_event_bus(),
|
|
||||||
EthereumConsensusSigner::new(PrivateKeySigner::random()),
|
|
||||||
10,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TEST-ONLY millisecond timers. de-mls deadlines are real wall-clock, so the
|
/// TEST-ONLY millisecond timers. de-mls deadlines are real wall-clock, so the
|
||||||
@ -88,7 +74,7 @@ fn demls_config() -> ConversationConfig {
|
|||||||
|
|
||||||
pub struct GroupV2Convo {
|
pub struct GroupV2Convo {
|
||||||
convo_id: String,
|
convo_id: String,
|
||||||
conversation: Conversation<DefaultConsensusPlugin, DefaultPeerScoring, DefaultStewardList>,
|
conversation: Conversation<DefaultConsensusPlugin, InMemoryPeerScoreStorage>,
|
||||||
/// Member-ids we proposed via add_member. We forward a welcome only to joiners WE invited.
|
/// Member-ids we proposed via add_member. We forward a welcome only to joiners WE invited.
|
||||||
pending_invites: Vec<Vec<u8>>,
|
pending_invites: Vec<Vec<u8>>,
|
||||||
}
|
}
|
||||||
@ -111,19 +97,17 @@ impl GroupV2Convo {
|
|||||||
service_ctx: &mut ServiceContext<S>,
|
service_ctx: &mut ServiceContext<S>,
|
||||||
) -> Result<Self, ChatError> {
|
) -> Result<Self, ChatError> {
|
||||||
let convo_id = rand_string(5);
|
let convo_id = rand_string(5);
|
||||||
let member = member_id(service_ctx);
|
|
||||||
let conversation = Conversation::create(
|
let conversation = Conversation::create(
|
||||||
&convo_id,
|
&convo_id,
|
||||||
|
&member_id(service_ctx),
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
service_ctx.mls_identity.get_credential(),
|
service_ctx.mls_identity.get_credential(),
|
||||||
CIPHER_SUITE,
|
CIPHER_SUITE,
|
||||||
&service_ctx.mls_identity,
|
&service_ctx.mls_identity,
|
||||||
|
&make_consensus(),
|
||||||
make_scoring(),
|
make_scoring(),
|
||||||
make_steward(),
|
|
||||||
make_consensus(),
|
|
||||||
rand_app_id(),
|
rand_app_id(),
|
||||||
demls_config(),
|
demls_config(),
|
||||||
&member,
|
|
||||||
)?;
|
)?;
|
||||||
let convo = GroupV2Convo {
|
let convo = GroupV2Convo {
|
||||||
convo_id,
|
convo_id,
|
||||||
@ -145,18 +129,16 @@ impl GroupV2Convo {
|
|||||||
service_ctx: &mut ServiceContext<S>,
|
service_ctx: &mut ServiceContext<S>,
|
||||||
welcome: &MemberWelcome,
|
welcome: &MemberWelcome,
|
||||||
) -> Result<Self, ChatError> {
|
) -> Result<Self, ChatError> {
|
||||||
let member = member_id(service_ctx);
|
|
||||||
let Some(conv) = Conversation::join(
|
let Some(conv) = Conversation::join(
|
||||||
|
&member_id(service_ctx),
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
|
&service_ctx.mls_identity,
|
||||||
&welcome.welcome_bytes,
|
&welcome.welcome_bytes,
|
||||||
&welcome.conversation_sync_bytes,
|
&welcome.conversation_sync_bytes,
|
||||||
|
&make_consensus(),
|
||||||
make_scoring(),
|
make_scoring(),
|
||||||
make_steward(),
|
|
||||||
make_consensus(),
|
|
||||||
rand_app_id(),
|
rand_app_id(),
|
||||||
demls_config(),
|
demls_config(),
|
||||||
&member,
|
|
||||||
&service_ctx.mls_identity,
|
|
||||||
)?
|
)?
|
||||||
else {
|
else {
|
||||||
return Err(ChatError::generic("welcome not addressed to this member"));
|
return Err(ChatError::generic("welcome not addressed to this member"));
|
||||||
@ -217,8 +199,8 @@ where
|
|||||||
) -> Result<(), ChatError> {
|
) -> Result<(), ChatError> {
|
||||||
self.conversation.send_message(
|
self.conversation.send_message(
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
content.to_vec(),
|
|
||||||
&service_ctx.mls_identity,
|
&service_ctx.mls_identity,
|
||||||
|
content.to_vec(),
|
||||||
)?;
|
)?;
|
||||||
self.after_op(service_ctx)?;
|
self.after_op(service_ctx)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -244,9 +226,9 @@ where
|
|||||||
|
|
||||||
self.conversation.process_inbound(
|
self.conversation.process_inbound(
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
|
&service_ctx.mls_identity,
|
||||||
&frame.sender_app_id,
|
&frame.sender_app_id,
|
||||||
&inner,
|
&inner,
|
||||||
&service_ctx.mls_identity,
|
|
||||||
)?;
|
)?;
|
||||||
self.conversation
|
self.conversation
|
||||||
.poll(&service_ctx.mls_provider, &service_ctx.mls_identity);
|
.poll(&service_ctx.mls_provider, &service_ctx.mls_identity);
|
||||||
@ -289,7 +271,6 @@ where
|
|||||||
// Record who WE invited before touching the conversation: after_op
|
// Record who WE invited before touching the conversation: after_op
|
||||||
// forwards a welcome only to joiners in pending_invites (the de-mls
|
// forwards a welcome only to joiners in pending_invites (the de-mls
|
||||||
// member-id is the invitee's id bytes).
|
// member-id is the invitee's id bytes).
|
||||||
let mut kps = Vec::with_capacity(members.len());
|
|
||||||
for member in members {
|
for member in members {
|
||||||
let kp_bytes = service_ctx
|
let kp_bytes = service_ctx
|
||||||
.registry
|
.registry
|
||||||
@ -298,14 +279,11 @@ where
|
|||||||
.ok_or_else(|| ChatError::generic("No key package"))?;
|
.ok_or_else(|| ChatError::generic("No key package"))?;
|
||||||
self.pending_invites
|
self.pending_invites
|
||||||
.push(member.as_str().as_bytes().to_vec());
|
.push(member.as_str().as_bytes().to_vec());
|
||||||
kps.push(kp_bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
for kp_bytes in &kps {
|
|
||||||
self.conversation.add_member(
|
self.conversation.add_member(
|
||||||
&service_ctx.mls_provider,
|
&service_ctx.mls_provider,
|
||||||
kp_bytes,
|
|
||||||
&service_ctx.mls_identity,
|
&service_ctx.mls_identity,
|
||||||
|
member.as_str().as_bytes(),
|
||||||
|
&kp_bytes,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
self.after_op(service_ctx)?;
|
self.after_op(service_ctx)?;
|
||||||
@ -379,7 +357,7 @@ impl GroupV2Convo {
|
|||||||
|
|
||||||
fn events_to_content(&self, events: &[ConversationEvent]) -> Option<ConvoOutcome> {
|
fn events_to_content(&self, events: &[ConversationEvent]) -> Option<ConvoOutcome> {
|
||||||
events.iter().find_map(|evt| match evt {
|
events.iter().find_map(|evt| match evt {
|
||||||
ConversationEvent::AppMessage(AppMessageProto {
|
ConversationEvent::ConversationMessage(AppMessageProto {
|
||||||
payload: Some(app_message::Payload::ConversationMessage(cm)),
|
payload: Some(app_message::Payload::ConversationMessage(cm)),
|
||||||
}) => Some(ConvoOutcome {
|
}) => Some(ConvoOutcome {
|
||||||
convo_id: self.convo_id.clone(),
|
convo_id: self.convo_id.clone(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user