diff --git a/.idea/misc.xml b/.idea/misc.xml
index 775445d..7deb2c1 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,10 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 06bd31e..43ad863 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,14 @@
Kotlin Multiplatform cryptographic primitives using modern strong cryptography.
+## v0.9.0 for kotlin 2.2.21, new kotlin time compatible
+
+The primary goal was to fix kotlin-caused incompatibilities with kotlinx.datetime.Instant and Clock; the upgrade shoud be in-place
+replacement providing calling code ises `kotlin.time.Instant` and
+`kotlin.time.Clock` respectively. No other changes are needed.
+
+Also we start to add small syntax sugar methods.
+
## v.0.8.4 is built for all platform, IOS and wasmJS included
Cryptographic API works exactly the same and compiles to any platform supported listed below with no change in source code.
diff --git a/build.gradle.kts b/build.gradle.kts
index 1974ccc..5086bc6 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,14 +13,14 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
- kotlin("multiplatform") version "2.2.20"
- id("org.jetbrains.kotlin.plugin.serialization") version "2.2.20"
+ kotlin("multiplatform") version "2.2.21"
+ id("org.jetbrains.kotlin.plugin.serialization") version "2.2.21"
id("org.jetbrains.dokka") version "1.9.20"
`maven-publish`
}
group = "net.sergeych"
-version = "0.8.5"
+version = "0.9.0"
repositories {
mavenCentral()
@@ -31,12 +31,8 @@ repositories {
}
kotlin {
- jvm {
- @OptIn(ExperimentalKotlinGradlePluginApi::class)
- compilerOptions {
- jvmTarget = JvmTarget.JVM_11
- }
- }
+ jvmToolchain(21)
+ jvm()
js {
browser()
nodejs()
@@ -60,18 +56,20 @@ kotlin {
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
+ languageSettings.optIn("kotlin.time.ExperimentalTime")
}
val commonMain by getting {
dependencies {
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
- implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0")
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
+ implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("net.sergeych:multiplatform-crypto-libsodium-bindings:0.9.6")
implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.1"))
implementation("org.kotlincrypto.hash:sha3")
api("com.ionspin.kotlin:bignum:0.3.10")
- api("net.sergeych:mp_bintools:0.2.2")
+ api("net.sergeych:mp_bintools:0.3.2")
+
}
}
val commonTest by getting {
@@ -114,6 +112,14 @@ publishing {
}
}
+tasks.named("jvmTest") {
+ // Ignore Kotlin synthetic classes generated from files that look like tests
+ exclude("**/*TestKt.class")
+ exclude("**/*TestsKt.class")
+ exclude("**/*AssertThrowsKt.class")
+ exclude("**/*Test_toolsKt.class")
+}
+
tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("dokka"))
dokkaSourceSets {
diff --git a/gradle.properties b/gradle.properties
index 7a7674f..2804048 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -9,3 +9,7 @@
#
kotlin.code.style=official
+org.gradle.parallel=true
+org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
+org.gradle.configuration-cache=true
+org.gradle.caching=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0e287ab..e5bc481 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -10,6 +10,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
\ No newline at end of file
diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/Multikey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/Multikey.kt
index 5e6ced5..8e55f1c 100644
--- a/src/commonMain/kotlin/net/sergeych/crypto2/Multikey.kt
+++ b/src/commonMain/kotlin/net/sergeych/crypto2/Multikey.kt
@@ -60,6 +60,12 @@ sealed class Multikey {
*/
abstract fun check(keys: Iterable): Boolean
+ /**
+ * Step towards automated picking necessary keys.
+ * Return all the keys mentioned in this multikey condition.
+ */
+ abstract fun mentionedKeys(): Set
+
/**
* Check that [verifyingKeys] satisfy the multikey condition
*/
@@ -97,6 +103,10 @@ sealed class Multikey {
}
return false
}
+
+ override fun mentionedKeys(): Set {
+ return validKeys
+ }
}
/**
@@ -119,6 +129,10 @@ sealed class Multikey {
}
return false
}
+
+ override fun mentionedKeys(): Set {
+ return validKeys.flatMap { it.mentionedKeys() }.toSet()
+ }
}
/**
@@ -129,6 +143,7 @@ sealed class Multikey {
@Serializable
object AnyKey : Multikey() {
override fun check(keys: Iterable): Boolean = true
+ override fun mentionedKeys(): Set = emptySet()
}
diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt b/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt
index ff0e3c1..aef61eb 100644
--- a/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt
+++ b/src/commonMain/kotlin/net/sergeych/crypto2/Seal.kt
@@ -10,7 +10,7 @@
package net.sergeych.crypto2
-import kotlinx.datetime.Instant
+import kotlin.time.Instant
import kotlinx.serialization.Serializable
import net.sergeych.bipack.BipackEncoder
import net.sergeych.bipack.decodeFromBipack
diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt
index f04e95e..fbbc4ce 100644
--- a/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt
+++ b/src/commonMain/kotlin/net/sergeych/crypto2/SealedBox.kt
@@ -10,7 +10,7 @@
package net.sergeych.crypto2
-import kotlinx.datetime.Instant
+import kotlin.time.Instant
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
import net.sergeych.bipack.BipackDecoder
diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SigningKey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SigningKey.kt
index 7b4e35f..8ac0880 100644
--- a/src/commonMain/kotlin/net/sergeych/crypto2/SigningKey.kt
+++ b/src/commonMain/kotlin/net/sergeych/crypto2/SigningKey.kt
@@ -10,7 +10,7 @@
package net.sergeych.crypto2
-import kotlinx.datetime.Instant
+import kotlin.time.Instant
interface SigningKey: KeyInstance {
val verifyingKey: VerifyingPublicKey
diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt
index 4f60f0c..f8966ac 100644
--- a/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt
+++ b/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt
@@ -11,7 +11,7 @@
package net.sergeych.crypto2
import com.ionspin.kotlin.crypto.signature.Signature
-import kotlinx.datetime.Instant
+import kotlin.time.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient
diff --git a/src/commonMain/kotlin/net/sergeych/utools/time.kt b/src/commonMain/kotlin/net/sergeych/utools/time.kt
index e4c4939..6cbb74c 100644
--- a/src/commonMain/kotlin/net/sergeych/utools/time.kt
+++ b/src/commonMain/kotlin/net/sergeych/utools/time.kt
@@ -12,8 +12,8 @@
package net.sergeych.utools
-import kotlinx.datetime.Clock
-import kotlinx.datetime.Instant
+import kotlin.time.Clock
+import kotlin.time.Instant
fun now(): Instant = Clock.System.now()
fun nowToSeconds(): Instant = Clock.System.now().truncateToSeconds()
diff --git a/src/commonTest/kotlin/HashTest.kt b/src/commonTest/kotlin/HashTest.kt
index 93eba85..2da3237 100644
--- a/src/commonTest/kotlin/HashTest.kt
+++ b/src/commonTest/kotlin/HashTest.kt
@@ -10,25 +10,17 @@
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.test.runTest
-import kotlinx.datetime.Clock
+import kotlin.time.Clock
import net.sergeych.crypto2.Hash
import net.sergeych.crypto2.initCrypto
import kotlin.random.Random
import kotlin.random.nextUBytes
+import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertFalse
-@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
-suspend fun sw(label: String, f: suspend () -> T): T {
- val t1 = Clock.System.now()
- val result = f()
- val t2 = Clock.System.now()
-// println("$label: ${t2 - t1}")
- return result
-}
-
class HashTest {
@Test
fun testEqualMethods() {
@@ -77,3 +69,13 @@ class HashTest {
}
+@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
+suspend fun sw(label: String, f: suspend () -> T): T {
+ val t1 = Clock.System.now()
+ val result = f()
+ val t2 = Clock.System.now()
+// println("$label: ${t2 - t1}")
+ return result
+}
+
+
diff --git a/src/commonTest/kotlin/PackTest.kt b/src/commonTest/kotlin/PackTest.kt
index 8be7901..4e1f30b 100644
--- a/src/commonTest/kotlin/PackTest.kt
+++ b/src/commonTest/kotlin/PackTest.kt
@@ -9,7 +9,7 @@
*/
import kotlinx.coroutines.test.runTest
-import kotlinx.datetime.Instant
+import kotlin.time.Instant
import net.sergeych.crypto2.initCrypto
import net.sergeych.utools.nowToSeconds
import net.sergeych.utools.pack