// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // Copyright by contributors to this project. // SPDX-License-Identifier: (Apache-2.0 OR MIT)
// Bob[0] crates a group. Repeat for `i=0` to `num_groups - 1` times : Bob[i] adds Bob[i+1] fn make_groups_best_case<P: CryptoProvider + Clone>(
num_groups: usize,
crypto_provider: &P,
) -> Result<Vec<Group<impl MlsConfig>>, MlsError> { let bob_client = make_client(crypto_provider.clone(), &make_name(0))?;
let bob_group = bob_client.create_group(Default::default())?;
letmut groups = vec![bob_group];
for i in0..(num_groups - 1) { let bob_client = make_client(crypto_provider.clone(), &make_name(i + 1))?;
// The new client generates a key package. let bob_kpkg = bob_client.generate_key_package_message()?;
// Last group sends a commit adding the new client to the group. let commit = groups
.last_mut()
.unwrap()
.commit_builder()
.add_member(bob_kpkg)?
.build()?;
// All other groups process the commit. for group in groups.iter_mut().rev().skip(1) {
group.process_incoming_message(commit.commit_message.clone())?;
}
// The last group applies the generated commit.
groups.last_mut().unwrap().apply_pending_commit()?;
// The new member joins. let (bob_group, _info) = bob_client.join_group(None, &commit.welcome_messages[0])?;
groups.push(bob_group);
}
Ok(groups)
}
// Alice creates a group by adding `num_groups - 1` clients in one commit. fn make_groups_worst_case<P: CryptoProvider + Clone>(
num_groups: usize,
crypto_provider: &P,
) -> Result<Vec<Group<impl MlsConfig>>, MlsError> { let alice_client = make_client(crypto_provider.clone(), &make_name(0))?;
// Generate a signature key pair. let (secret, public) = cipher_suite.signature_key_generate().unwrap();
// Create a basic credential for the session. // NOTE: BasicCredential is for demonstration purposes and not recommended for production. // X.509 credentials are recommended. let basic_identity = BasicCredential::new(name.as_bytes().to_vec()); let signing_identity = SigningIdentity::new(basic_identity.into_credential(), public);
fn main() -> Result<(), MlsError> { let crypto_provider = mls_rs_crypto_openssl::OpensslCryptoProvider::default();
println!("Demonstrate that performance depends on a) group evolution and b) a members position in the tree.\n");
let (small_bench_bc, large_bench_bc) = bench_commit_size(Case::Best, &crypto_provider)?; let (small_bench_wc, large_bench_wc) = bench_commit_size(Case::Worst, &crypto_provider)?;
println!("\nBest case a), worst case b) : commit size is θ(log(n)) bytes.");
println!("group sizes n :\n{GROUP_SIZES:?}\ncommit sizes :\n{large_bench_bc:?}");
println!("\nWorst case a), worst case b) : commit size is θ(n) bytes.");
println!("group sizes n :\n{GROUP_SIZES:?}\ncommit sizes :\n{large_bench_wc:?}");
println!( "\nBest case b) : if n-1 is a power of 2, commit size is θ(1) bytes, independent of a)."
);
println!("group sizes n :\n{GROUP_SIZES:?}\ncommit sizes, best case a) :\n{small_bench_bc:?}");
println!("commit sizes, worst case a) :\n{small_bench_wc:?}");
Ok(())
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.