Skip to content

Commit

Permalink
signer: remove Version from NostrSigner::nip44_encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Feb 22, 2024
1 parent a4f2242 commit c848c02
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
15 changes: 2 additions & 13 deletions bindings/nostr-sdk-ffi/src/client/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use std::ops::Deref;
use std::sync::Arc;

use nostr_ffi::nips::nip44::Nip44Version;
use nostr_ffi::{Event, EventBuilder, Keys, PublicKey, UnsignedEvent};
use nostr_sdk::{block_on, signer};
use uniffi::Object;
Expand Down Expand Up @@ -94,18 +93,8 @@ impl NostrSigner {
})
}

pub fn nip44_encrypt(
&self,
public_key: Arc<PublicKey>,
content: String,
version: Nip44Version,
) -> Result<String> {
block_on(async move {
Ok(self
.inner
.nip44_encrypt(**public_key, content, version.into())
.await?)
})
pub fn nip44_encrypt(&self, public_key: Arc<PublicKey>, content: String) -> Result<String> {
block_on(async move { Ok(self.inner.nip44_encrypt(**public_key, content).await?) })
}

pub fn nip44_decrypt(&self, public_key: Arc<PublicKey>, content: String) -> Result<String> {
Expand Down
10 changes: 2 additions & 8 deletions bindings/nostr-sdk-js/src/client/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use nostr_js::error::{into_err, Result};
use nostr_js::event::{JsEvent, JsEventBuilder, JsUnsignedEvent};
use nostr_js::key::{JsKeys, JsPublicKey};
use nostr_js::nips::nip07::JsNip07Signer;
use nostr_js::nips::nip44::JsNIP44Version;
use nostr_sdk::NostrSigner;
use wasm_bindgen::prelude::*;

Expand Down Expand Up @@ -105,14 +104,9 @@ impl JsNostrSigner {
}

#[wasm_bindgen(js_name = nip44Encrypt)]
pub async fn nip44_encrypt(
&self,
public_key: &JsPublicKey,
content: String,
version: JsNIP44Version,
) -> Result<String> {
pub async fn nip44_encrypt(&self, public_key: &JsPublicKey, content: String) -> Result<String> {
self.inner
.nip44_encrypt(**public_key, content, version.into())
.nip44_encrypt(**public_key, content)
.await
.map_err(into_err)
}
Expand Down
4 changes: 1 addition & 3 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,9 +1241,7 @@ impl Client {
let rumor = rumor.to_unsigned_event(public_key);

// Compose seal
let content: String = signer
.nip44_encrypt(receiver, rumor.as_json(), nip44::Version::default())
.await?;
let content: String = signer.nip44_encrypt(receiver, rumor.as_json()).await?;
let seal: EventBuilder = EventBuilder::new(Kind::Seal, content, []);
let seal: Event = self.sign_event_builder(seal).await?;

Expand Down
11 changes: 2 additions & 9 deletions crates/nostr-signer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,8 @@ impl NostrSigner {
}

/// NIP44 encryption with [NostrSigner]
///
/// Note: `Version` is ignored for NIP07!
#[cfg(feature = "nip44")]
pub async fn nip44_encrypt<T>(
&self,
public_key: PublicKey,
content: T,
version: nip44::Version,
) -> Result<String, Error>
pub async fn nip44_encrypt<T>(&self, public_key: PublicKey, content: T) -> Result<String, Error>
where
T: AsRef<str>,
{
Expand All @@ -250,7 +243,7 @@ impl NostrSigner {
keys.secret_key()?,
&public_key,
content,
version,
nip44::Version::default(),
)?),
#[cfg(all(feature = "nip07", target_arch = "wasm32"))]
Self::NIP07(signer) => Ok(signer.nip44_encrypt(public_key, content).await?),
Expand Down

0 comments on commit c848c02

Please sign in to comment.