Fix connect.rs documentation

This commit is contained in:
Sosthene 2024-10-30 16:06:52 +01:00
parent bfa60aa023
commit e9421f2e04

View File

@ -24,29 +24,44 @@ 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.
/// Tests the connection process between two devices, Alice and Bob, by executing a secure
/// transaction to establish a shared secret for encrypted communication.
///
/// The basics are that one device will initiate the process by sending a transaction that pays another device.
/// The recipient of the transaction as soon as it finds it, can extract a shared secret and send an encrypted
/// message back. Upon receiving this message, the initiator answers with a similar message similarly encrypted.
/// Upon receiving this message, the recipient can be assured that the communication is safe, and start using
/// the secret to communicate.
///
/// The security of the shared secret rest on the soundness of the silent payment protocol for Bitcoin.
/// In its encrypted response, the initiator adds a signature that is proof that it indeed controls the
/// private key for the silent payment address it announced, so recipient knows there's no mitm or impostor.
///
/// # Process Summary
/// # Detailed Process
///
/// ## Alice's Initialization:
/// ## Alice sends a transaction that pays Bob:
/// - 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 creates a new member using Bobs device address (this is mainly for testing purpose,
/// because `create_connection_transaction` would take members as argument).
/// - She generates a connection transaction (`connect_tx`) targeting Bob's device.
/// - Alice processes her own transaction and stores the derived shared secrets in `alice_secrets_store`,
/// associating each shared secret with Bob's addresses.
/// associating the shared secret with Bob's addresses.
///
/// ## Bob's Initialization:
/// ## Bob parses the transaction:
/// - 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`.
/// - He parses Alices connection transaction to retrieve the shared secret Alice created for him.
/// - Bob saves these derived shared secrets in `bob_secrets_store` but can't index it with Alice's address yet.
///
/// ## 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`.
/// ## Prd Connect exchange
/// - Bob then responds by sending a prd connect back to Alice encrypted with the shared secret.
/// This prd is very simple and basically contains the following:
/// * All Bob's devices addresses
/// * a commitment to the shared secret
/// * a proof signed with Bob's device spend key
/// - Alice receives and decrypts the message from Bob.
/// - She replies to Bob by encrypting another prd connect which is basically the same, but keeping Bob's proof and adding her own.
/// - **Bobs Confirmation**: Bob receives Alices confirmation message, decrypts it, and updates his secret in `bob_secrets_store`.
///
/// ## Verification:
/// - Finally, the function asserts that Alice and Bob now share the same secrets, confirming successful