commit 54ed7b466733d47a51833dd8b470848d306223d7
parent a78e416c96e351b93b7f88e291ad3c2c38a43f70
Author: triesap <triesap@radroots.dev>
Date: Tue, 6 Jan 2026 17:26:34 +0000
nip46: add relay-only nip44 encrypt/decrypt
- handle nip44 encrypt/decrypt in nostr listener
- add nip44 encrypt/decrypt flow to tmp nostr-only test
- validate plaintext round-trip and errors
- keep existing nip04/sign_event flows intact
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/transport/nostr/listener.rs b/src/transport/nostr/listener.rs
@@ -147,6 +147,23 @@ fn handle_request(radrootsd: &Radrootsd, request: NostrConnectRequest) -> NostrC
Err(err) => NostrConnectResponse::with_error(format!("nip04_decrypt failed: {err}")),
}
}
+ NostrConnectRequest::Nip44Encrypt { public_key, text } => {
+ match nip44::encrypt(radrootsd.keys.secret_key(), &public_key, text, nip44::Version::V2)
+ {
+ Ok(ciphertext) => {
+ NostrConnectResponse::with_result(ResponseResult::Nip44Encrypt { ciphertext })
+ }
+ Err(err) => NostrConnectResponse::with_error(format!("nip44_encrypt failed: {err}")),
+ }
+ }
+ NostrConnectRequest::Nip44Decrypt { public_key, ciphertext } => {
+ match nip44::decrypt(radrootsd.keys.secret_key(), &public_key, ciphertext) {
+ Ok(plaintext) => {
+ NostrConnectResponse::with_result(ResponseResult::Nip44Decrypt { plaintext })
+ }
+ Err(err) => NostrConnectResponse::with_error(format!("nip44_decrypt failed: {err}")),
+ }
+ }
NostrConnectRequest::Ping => NostrConnectResponse::with_result(ResponseResult::Pong),
_ => NostrConnectResponse::with_error("unsupported request"),
}