Skip to content

Commit 7900a0b

Browse files
committed
connect: drop support for NIP-46 event decryption with NIP-04
Ref nostr-protocol/nips#1248 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 9a8daa1 commit 7900a0b

File tree

5 files changed

+13
-31
lines changed

5 files changed

+13
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
- pool: drop support for deprecated negentropy protocol ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/853)
3333
- connect: encrypt NIP-46 events with NIP-44 instead of NIP-04 ([reyamir] at https://github.com/rust-nostr/nostr/pull/862)
34+
- connect: drop support for NIP-46 event decryption with NIP-04 ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/864)
3435

3536
### Changed
3637

crates/nostr-connect/src/client.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use tokio::sync::broadcast::Receiver;
1616
use tokio::sync::OnceCell;
1717

1818
use crate::error::Error;
19-
use crate::util;
2019

2120
/// Nostr Connect Client
2221
///
@@ -259,7 +258,8 @@ impl NostrConnect {
259258
while let Ok(notification) = notifications.recv().await {
260259
if let RelayPoolNotification::Event { event, .. } = notification {
261260
if event.kind == Kind::NostrConnect {
262-
let msg: String = util::decrypt(secret_key, &event)?;
261+
let msg: String =
262+
nip44::decrypt(secret_key, &event.pubkey, event.content.as_str())?;
263263
let msg: Message = Message::from_json(msg)?;
264264

265265
tracing::debug!("Received NIP46 message: '{msg}'");
@@ -414,7 +414,11 @@ async fn get_remote_signer_public_key(
414414
if let RelayPoolNotification::Event { event, .. } = notification {
415415
if event.kind == Kind::NostrConnect {
416416
// Decrypt content
417-
let msg: String = util::decrypt(app_keys.secret_key(), &event)?;
417+
let msg: String = nip44::decrypt(
418+
app_keys.secret_key(),
419+
&event.pubkey,
420+
event.content.as_str(),
421+
)?;
418422

419423
tracing::debug!("Received Nostr Connect message: '{msg}'");
420424

crates/nostr-connect/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ pub mod client;
1515
pub mod error;
1616
pub mod prelude;
1717
pub mod signer;
18-
mod util;

crates/nostr-connect/src/signer.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use nostr::nips::nip46::{Message, Request, ResponseResult};
1111
use nostr_relay_pool::prelude::*;
1212

1313
use crate::error::Error;
14-
use crate::util;
1514

1615
/// Nostr Connect Keys
1716
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
@@ -176,7 +175,11 @@ impl NostrConnectRemoteSigner {
176175
.handle_notifications(|notification| async {
177176
if let RelayPoolNotification::Event { event, .. } = notification {
178177
if event.kind == Kind::NostrConnect {
179-
match util::decrypt(self.keys.signer.secret_key(), &event) {
178+
match nip44::decrypt(
179+
self.keys.signer.secret_key(),
180+
&event.pubkey,
181+
&event.content,
182+
) {
180183
Ok(msg) => {
181184
tracing::debug!("New Nostr Connect message received: {msg}");
182185

crates/nostr-connect/src/util.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)