diff --git a/build.gradle.kts b/build.gradle.kts index 3cc075d..4fa9954 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - kotlin("multiplatform") version "2.0.0" - id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0" + kotlin("multiplatform") version "2.0.20" + id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20" `maven-publish` } @@ -18,6 +18,7 @@ kotlin { jvm() js { browser() + nodejs() } linuxX64() linuxArm64() @@ -47,7 +48,7 @@ kotlin { implementation("com.ionspin.kotlin:multiplatform-crypto-libsodium-bindings:0.9.2") api("com.ionspin.kotlin:bignum:0.3.9") - api("net.sergeych:mp_bintools:0.1.6") + api("net.sergeych:mp_bintools:0.1.7") api("net.sergeych:mp_stools:1.5.1") } } diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt index 0a616be..131da3f 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt @@ -33,7 +33,7 @@ class SealedBox( ) { @Suppress("unused") - constructor(message: UByteArray, vararg keys: SigningSecretKey) : + constructor(message: UByteArray, vararg keys: SigningKey) : this(message, keys.map { it.seal(message) } ) /** @@ -41,7 +41,7 @@ class SealedBox( * key, or return unchanged (same) object if it is already signed by this key; you * _can't assume it always returns a copied object!_ */ - operator fun plus(key: SigningSecretKey): SealedBox = + operator fun plus(key: SigningKey): SealedBox = if (key.verifyingKey in this) this else SealedBox(message, seals + key.seal(message),false) @@ -49,15 +49,15 @@ class SealedBox( * Add expiring seal, otherwise use [plus]. Overrides exising seal for [key] * if present: */ - fun addSeal(key: SigningSecretKey, expresAt: Instant): SealedBox { + fun addSeal(key: SigningKey, expiresAt: Instant): SealedBox { val filtered = seals.filter { it.publicKey != key.verifyingKey } - return SealedBox(message, filtered + key.seal(message, expresAt), false) + return SealedBox(message, filtered + key.seal(message, expiresAt), false) } /** * Check that it is signed with a specified key. */ - operator fun contains(publicKey: VerifyingPublicKey): Boolean { + operator fun contains(publicKey: VerifyingKey): Boolean { return seals.any { it.publicKey == publicKey } } @@ -85,7 +85,7 @@ class SealedBox( return SealedBox(data, keys.map { it.seal(data) }, false) } - inline fun encode(value: T, vararg keys: SigningSecretKey): UByteArray = + inline fun encode(value: T, vararg keys: SigningKey): UByteArray = create(BipackEncoder.encode(value).toUByteArray(), *keys).encoded /** diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SymmetricKey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SymmetricKey.kt index 2985d3c..f8b06af 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/SymmetricKey.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/SymmetricKey.kt @@ -65,7 +65,6 @@ class SymmetricKey( return keyBytes.contentHashCode() } - companion object { /** * Create a secure random symmetric key.