Doc connect.rs

This commit is contained in:
Omar Oughriss 2024-10-30 15:26:08 +01:00
parent 0a81ce12df
commit bfa60aa023

View File

@ -24,6 +24,33 @@ use utils::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
/// Tests the connection process between two devices, Alice and Bob, by executing a series of secure
/// transactions to establish a shared secret for encrypted communication.
///
/// # Process Summary
///
/// ## Alice's Initialization:
/// - Alice initializes her device from an `sp_wallet` object and sets it as the local device.
/// - She retrieves her own address and obtains Bobs address.
/// - Alice creates a new member using Bobs address to identify him within the transaction.
/// - She generates a connection transaction (`connect_tx`) targeting Bob's device, initiating the process for secure message sharing.
/// - Alice processes her own transaction and stores the derived shared secrets in `alice_secrets_store`,
/// associating each shared secret with Bob's addresses.
///
/// ## Bob's Initialization:
/// - Bob initializes his device from his own `sp_wallet`.
/// - He parses Alices connection transaction to retrieve the shared secret Alice created for him,
/// then responds by sending an encrypted message back to Alice in a follow-up transaction.
/// - Bob saves these derived shared secrets in `bob_secrets_store`.
///
/// ## Message Exchange:
/// - **Alices Response**: Alice receives and decrypts the message from Bobs response transaction.
/// - She replies to Bob by encrypting a confirmation message, updating her secrets in `alice_secrets_store`.
/// - **Bobs Confirmation**: Bob receives Alices confirmation message, decrypts it, and updates his secrets in `bob_secrets_store`.
///
/// ## Verification:
/// - Finally, the function asserts that Alice and Bob now share the same secrets, confirming successful
/// connection and mutual authentication between the devices.
fn test_connect() {
setup();
// let mut alice_process_cache = HashMap::new();