From 94b888916164ae930dc6483372b48e9db0ac1505 Mon Sep 17 00:00:00 2001 From: Evan Feenstra Date: Tue, 16 May 2023 12:17:07 +0100 Subject: [PATCH] document LSS steps --- broker/Cargo.lock | 6 ++--- broker/lss.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++ broker/src/mqtt.rs | 5 ++++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 broker/lss.md diff --git a/broker/Cargo.lock b/broker/Cargo.lock index 5378a1a..ee644cd 100644 --- a/broker/Cargo.lock +++ b/broker/Cargo.lock @@ -3021,7 +3021,7 @@ dependencies = [ [[package]] name = "sphinx-auther" version = "0.1.12" -source = "git+https://github.com/stakwork/sphinx-rs#82712f0be41eb460827e8db8e136a482cd595cff" +source = "git+https://github.com/stakwork/sphinx-rs#763533b57dd72d18bec13c54760090c7cf302f43" dependencies = [ "anyhow", "base64", @@ -3033,7 +3033,7 @@ dependencies = [ [[package]] name = "sphinx-glyph" version = "0.1.2" -source = "git+https://github.com/stakwork/sphinx-rs#82712f0be41eb460827e8db8e136a482cd595cff" +source = "git+https://github.com/stakwork/sphinx-rs#763533b57dd72d18bec13c54760090c7cf302f43" dependencies = [ "anyhow", "hex", @@ -3078,7 +3078,7 @@ dependencies = [ [[package]] name = "sphinx-signer" version = "0.1.0" -source = "git+https://github.com/stakwork/sphinx-rs#82712f0be41eb460827e8db8e136a482cd595cff" +source = "git+https://github.com/stakwork/sphinx-rs#763533b57dd72d18bec13c54760090c7cf302f43" dependencies = [ "anyhow", "bip39", diff --git a/broker/lss.md b/broker/lss.md new file mode 100644 index 0000000..270c602 --- /dev/null +++ b/broker/lss.md @@ -0,0 +1,60 @@ +# steps to integrate LSS + +### initialization + +##### broker + +- check that there is an LSS url to use +- LssClient::get_server_pubkey +- send server pubkey to signer + +##### signer + +- let client_id = keys_manager.get_persistence_pubkey() +- let auth_token = keys_manager.get_persistence_auth_token(&server_pubkey) +- let shared_secret = keys_manager.get_persistence_shared_secret(&server_pubkey) +- create a ExternalPersistHelper locally and init `state` +- helper.new_nonce +- send the client_id, auth_token, and nonce back to the broker + +##### broker + +- create Auth +- LssClient::new +- let (muts, server_hmac) = client.get("".to_string(), &nonce) +- send the muts and server_hmac to signer + +##### signer + +- check the server hmac +- insert the muts into local state +- let handler_builder = handler_builder.lss_state(...); +- (what is the above line do it muts are already inserted???) +- let (handler, muts) = handler_builder.build(); +- helper.client_hmac +- send the muts and client_hmac back to broker + +##### broker + +- store the muts using the LssClient (client.put(muts, &client_hmac)) + +### VLS + +##### signer + +- let (reply, muts) = handler.handle(msg) +- let client_hmac = helper.client_hmac(&muts); +- send muts and hmac to broker + +##### broker + +- client.put(muts, &client_hmac).await? +- send some kind of confirmation back to signer + +##### signer + +- finally, send the VLS reply back to broker + +##### broker + +- forward the VLS reply back to CLN diff --git a/broker/src/mqtt.rs b/broker/src/mqtt.rs index 7480acb..2adb54e 100644 --- a/broker/src/mqtt.rs +++ b/broker/src/mqtt.rs @@ -143,6 +143,9 @@ pub fn start_broker( let topic = topic_res.unwrap(); if topic.ends_with(topics::ERROR) { let _ = error_sender.send(f.publish.payload.to_vec()); + } else if topics.ends_with(topics::LSS_PUB) { + // send to LSS client here + // get the hmac back, pub to the device } else { let ts: Vec<&str> = topic.split("/").collect(); if ts.len() != 2 { @@ -175,6 +178,8 @@ fn subs(cid: &str, mut ltx: LinkTx) { ltx.subscribe(format!("{}/{}", cid, topics::CONTROL_RETURN)) .unwrap(); ltx.subscribe(format!("{}/{}", cid, topics::ERROR)).unwrap(); + ltx.subscribe(format!("{}/{}", cid, topics::LSS_PUB)) + .unwrap(); } fn unsubs(cid: &str, mut ltx: LinkTx) {