Skip to content

Commit

Permalink
nostr: disable nip44 default feature
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Aug 30, 2023
1 parent 6ecf2a8 commit c2f7930
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/nostr-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["nostr", "sdk"]
default = ["all-nips"]
blocking = ["dep:once_cell", "async-utility/blocking", "nostr/blocking"]
vanity = ["nostr/vanity"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip44", "nip46", "nip47"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip46", "nip47"]
nip03 = ["nostr/nip03"]
nip04 = ["nostr/nip04"]
nip05 = ["nostr/nip05"]
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The following crate feature flags are available:
| `nip06` | Yes | Enable NIP-06: Basic key derivation from mnemonic seed phrase |
| `nip11` | Yes | Enable NIP-11: Relay Information Document |
| `nip19` | Yes | Enable NIP-19: bech32-encoded entities |
| `nip44` | Yes | Enable NIP-44: Encrypted Payloads (Versioned) |
| `nip44` | No | Enable NIP-44: Encrypted Payloads (Versioned) |
| `nip46` | Yes | Enable NIP-46: Nostr Connect |
| `nip47` | Yes | Enable NIP-47: Nostr Wallet Connect |

Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["nostr", "protocol"]
default = ["all-nips"]
blocking = ["reqwest?/blocking"]
vanity = ["nip19"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip21", "nip44", "nip46", "nip47"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip21", "nip46", "nip47"]
nip03 = ["dep:nostr-ots"]
nip04 = ["dep:aes", "dep:base64", "dep:cbc"]
nip05 = ["dep:reqwest"]
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The following crate feature flags are available:
| `nip11` | Yes | Enable NIP-11: Relay Information Document |
| `nip19` | Yes | Enable NIP-19: bech32-encoded entities |
| `nip21` | Yes | Enable NIP-21: `nostr` URI scheme |
| `nip44` | Yes | Enable NIP-44: Encrypted Payloads (Versioned) |
| `nip44` | No | Enable NIP-44: Encrypted Payloads (Versioned) |
| `nip46` | Yes | Enable NIP-46: Nostr Connect |
| `nip47` | Yes | Enable NIP-47: Nostr Wallet Connect |

Expand Down
5 changes: 4 additions & 1 deletion crates/nostr/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ use core::str::FromStr;
use secp256k1::{ecdh, PublicKey, SecretKey, XOnlyPublicKey};

/// Generate shared key
///
/// **Important: use of a strong cryptographic hash function may be critical to security! Do NOT use
/// unless you understand cryptographical implications.**
pub fn generate_shared_key(
sk: &SecretKey,
pk: &XOnlyPublicKey,
) -> Result<[u8; 32], secp256k1::Error> {
let pk_normalized: PublicKey = normalize_schnorr_pk(pk)?;
let ssp = ecdh::shared_secret_point(&pk_normalized, sk);
let ssp: [u8; 64] = ecdh::shared_secret_point(&pk_normalized, sk);
let mut shared_key: [u8; 32] = [0u8; 32];
shared_key.copy_from_slice(&ssp[..32]);
Ok(shared_key)
Expand Down

0 comments on commit c2f7930

Please sign in to comment.