Skip to content

Commit

Permalink
Revert rename of encrypt function to minimize potential breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
jmateoac committed Mar 25, 2024
1 parent c7adaf3 commit 411db00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/api/lib.api
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public final class app/cash/nostrino/model/EncryptedDm$Companion {
}

public final class app/cash/nostrino/model/EncryptedDmKt {
public static final fun encryptMessage (Lapp/cash/nostrino/crypto/SecKey;Lapp/cash/nostrino/crypto/PubKey;Ljava/lang/String;)Lapp/cash/nostrino/crypto/CipherText;
public static final fun encrypt (Lapp/cash/nostrino/crypto/SecKey;Lapp/cash/nostrino/crypto/PubKey;Ljava/lang/String;)Lapp/cash/nostrino/crypto/CipherText;
}

public final class app/cash/nostrino/model/Event {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/jvmMain/kotlin/app/cash/nostrino/model/EncryptedDm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class EncryptedDm(
override val tags: List<Tag> = listOf(PubKeyTag(to)),
) : EventContent {

constructor(from: SecKey, to: PubKey, message: String) : this(to, from.encryptMessage(to, message))
constructor(from: SecKey, to: PubKey, message: String) : this(to, from.encrypt(to, message))

override val kind: Int = EncryptedDm.kind

Expand All @@ -49,7 +49,7 @@ data class EncryptedDm(
}
}

fun SecKey.encryptMessage(to: PubKey, plainText: String): CipherText {
fun SecKey.encrypt(to: PubKey, plainText: String): CipherText {
val random = SecureRandom()
val iv = ByteArray(16)
random.nextBytes(iv)
Expand Down

0 comments on commit 411db00

Please sign in to comment.