Skip to content

Commit d9fc081

Browse files
committed
nostr: add ConversationKey::new
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 6f9186d commit d9fc081

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* nostr: add `EventId::LEN` const ([Yuki Kishimoto])
5151
* nostr: add `UnsignedEvent::ensure_id` method ([Yuki Kishimoto])
5252
* nostr: add missing `payload` arg to `EventBuilder::job_result` ([Yuki Kishimoto])
53+
* nostr: add `ConversationKey::new` ([Yuki Kishimoto])
5354
* pool: add `RelayPoolNotification::Authenticated` variant ([Yuki Kishimoto])
5455
* sdk: add `Client::gift_wrap_to` and `Client::send_private_msg_to` ([reyamir])
5556
* sdk: add option to autoconnect relay on `Client::add_relay` method call ([Yuki Kishimoto])

crates/nostr/src/nips/nip44/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl TryFrom<u8> for Version {
107107
}
108108
}
109109

110-
/// Encrypt - EXPERIMENTAL
110+
/// Encrypt
111111
#[inline]
112112
#[cfg(feature = "std")]
113113
pub fn encrypt<T>(
@@ -122,7 +122,7 @@ where
122122
encrypt_with_rng(&mut OsRng, secret_key, public_key, content, version)
123123
}
124124

125-
/// Encrypt - EXPERIMENTAL
125+
/// Encrypt
126126
pub fn encrypt_with_rng<R, T>(
127127
rng: &mut R,
128128
secret_key: &SecretKey,

crates/nostr/src/nips/nip44/v2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ impl Deref for ConversationKey {
135135
}
136136

137137
impl ConversationKey {
138+
/// Construct conversation key from 32-byte array
139+
#[inline]
140+
pub fn new(bytes: [u8; 32]) -> Self {
141+
Self(Hmac::from_byte_array(bytes))
142+
}
143+
138144
/// Derive Conversation Key
139145
#[inline]
140146
pub fn derive(secret_key: &SecretKey, public_key: &PublicKey) -> Self {

0 commit comments

Comments
 (0)