Skip to content

Commit 9a8daa1

Browse files
reyamiryukibtc
authored andcommitted
nostr: encrypt NIP-46 events with NIP-44 instead of NIP-04
Ref nostr-protocol/nips#1248 Closes #861 Pull-Request: #862 Reviewed-by: Yuki Kishimoto <[email protected]> Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent e308fcd commit 9a8daa1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
### Breaking changes
3131

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

3435
### Changed
3536

crates/nostr/src/event/builder.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use secp256k1::rand::{CryptoRng, Rng};
1515
use secp256k1::{Secp256k1, Signing, Verification};
1616
use serde_json::{json, Value};
1717

18-
#[cfg(all(feature = "std", feature = "nip04", feature = "nip46"))]
18+
#[cfg(all(feature = "std", feature = "nip44", feature = "nip46"))]
1919
use crate::nips::nip46::Message as NostrConnectMessage;
2020
use crate::nips::nip62::VanishTarget;
2121
use crate::prelude::*;
@@ -876,15 +876,20 @@ impl EventBuilder {
876876
///
877877
/// <https://github.com/nostr-protocol/nips/blob/master/46.md>
878878
#[inline]
879-
#[cfg(all(feature = "std", feature = "nip04", feature = "nip46"))]
879+
#[cfg(all(feature = "std", feature = "nip44", feature = "nip46"))]
880880
pub fn nostr_connect(
881881
sender_keys: &Keys,
882882
receiver_pubkey: PublicKey,
883883
msg: NostrConnectMessage,
884884
) -> Result<Self, Error> {
885885
Ok(Self::new(
886886
Kind::NostrConnect,
887-
nip04::encrypt(sender_keys.secret_key(), &receiver_pubkey, msg.as_json())?,
887+
nip44::encrypt(
888+
sender_keys.secret_key(),
889+
&receiver_pubkey,
890+
msg.as_json(),
891+
nip44::Version::default(),
892+
)?,
888893
)
889894
.tag(Tag::public_key(receiver_pubkey)))
890895
}

0 commit comments

Comments
 (0)