v0.9.0: kotlin 2.2.21, kotlin.time fix for deprecated methods in kotlinx.datetime. Should work ok on mac/ios

This commit is contained in:
Sergey Chernov 2025-12-16 19:13:27 +01:00
parent 3bd06ac7ff
commit 13dff8d760
13 changed files with 69 additions and 31 deletions

5
.idea/misc.xml generated
View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK"> <component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -2,6 +2,14 @@
Kotlin Multiplatform cryptographic primitives using modern strong cryptography. 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 ## 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. Cryptographic API works exactly the same and compiles to any platform supported listed below with no change in source code.

View File

@ -13,14 +13,14 @@ import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins { plugins {
kotlin("multiplatform") version "2.2.20" kotlin("multiplatform") version "2.2.21"
id("org.jetbrains.kotlin.plugin.serialization") version "2.2.20" id("org.jetbrains.kotlin.plugin.serialization") version "2.2.21"
id("org.jetbrains.dokka") version "1.9.20" id("org.jetbrains.dokka") version "1.9.20"
`maven-publish` `maven-publish`
} }
group = "net.sergeych" group = "net.sergeych"
version = "0.8.5" version = "0.9.0"
repositories { repositories {
mavenCentral() mavenCentral()
@ -31,12 +31,8 @@ repositories {
} }
kotlin { kotlin {
jvm { jvmToolchain(21)
@OptIn(ExperimentalKotlinGradlePluginApi::class) jvm()
compilerOptions {
jvmTarget = JvmTarget.JVM_11
}
}
js { js {
browser() browser()
nodejs() nodejs()
@ -60,18 +56,20 @@ kotlin {
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi") languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes") languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
languageSettings.optIn("kotlin.time.ExperimentalTime")
} }
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("net.sergeych:multiplatform-crypto-libsodium-bindings:0.9.6") implementation("net.sergeych:multiplatform-crypto-libsodium-bindings:0.9.6")
implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.1")) implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.1"))
implementation("org.kotlincrypto.hash:sha3") implementation("org.kotlincrypto.hash:sha3")
api("com.ionspin.kotlin:bignum:0.3.10") 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 { val commonTest by getting {
@ -114,6 +112,14 @@ publishing {
} }
} }
tasks.named<Test>("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 { tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("dokka")) outputDirectory.set(buildDir.resolve("dokka"))
dokkaSourceSets { dokkaSourceSets {

View File

@ -9,3 +9,7 @@
# #
kotlin.code.style=official 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

View File

@ -10,6 +10,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -60,6 +60,12 @@ sealed class Multikey {
*/ */
abstract fun check(keys: Iterable<VerifyingPublicKey>): Boolean abstract fun check(keys: Iterable<VerifyingPublicKey>): Boolean
/**
* Step towards automated picking necessary keys.
* Return all the keys mentioned in this multikey condition.
*/
abstract fun mentionedKeys(): Set<VerifyingPublicKey>
/** /**
* Check that [verifyingKeys] satisfy the multikey condition * Check that [verifyingKeys] satisfy the multikey condition
*/ */
@ -97,6 +103,10 @@ sealed class Multikey {
} }
return false return false
} }
override fun mentionedKeys(): Set<VerifyingPublicKey> {
return validKeys
}
} }
/** /**
@ -119,6 +129,10 @@ sealed class Multikey {
} }
return false return false
} }
override fun mentionedKeys(): Set<VerifyingPublicKey> {
return validKeys.flatMap { it.mentionedKeys() }.toSet()
}
} }
/** /**
@ -129,6 +143,7 @@ sealed class Multikey {
@Serializable @Serializable
object AnyKey : Multikey() { object AnyKey : Multikey() {
override fun check(keys: Iterable<VerifyingPublicKey>): Boolean = true override fun check(keys: Iterable<VerifyingPublicKey>): Boolean = true
override fun mentionedKeys(): Set<VerifyingPublicKey> = emptySet()
} }

View File

@ -10,7 +10,7 @@
package net.sergeych.crypto2 package net.sergeych.crypto2
import kotlinx.datetime.Instant import kotlin.time.Instant
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.sergeych.bipack.BipackEncoder import net.sergeych.bipack.BipackEncoder
import net.sergeych.bipack.decodeFromBipack import net.sergeych.bipack.decodeFromBipack

View File

@ -10,7 +10,7 @@
package net.sergeych.crypto2 package net.sergeych.crypto2
import kotlinx.datetime.Instant import kotlin.time.Instant
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient import kotlinx.serialization.Transient
import net.sergeych.bipack.BipackDecoder import net.sergeych.bipack.BipackDecoder

View File

@ -10,7 +10,7 @@
package net.sergeych.crypto2 package net.sergeych.crypto2
import kotlinx.datetime.Instant import kotlin.time.Instant
interface SigningKey: KeyInstance { interface SigningKey: KeyInstance {
val verifyingKey: VerifyingPublicKey val verifyingKey: VerifyingPublicKey

View File

@ -11,7 +11,7 @@
package net.sergeych.crypto2 package net.sergeych.crypto2
import com.ionspin.kotlin.crypto.signature.Signature import com.ionspin.kotlin.crypto.signature.Signature
import kotlinx.datetime.Instant import kotlin.time.Instant
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient import kotlinx.serialization.Transient

View File

@ -12,8 +12,8 @@
package net.sergeych.utools package net.sergeych.utools
import kotlinx.datetime.Clock import kotlin.time.Clock
import kotlinx.datetime.Instant import kotlin.time.Instant
fun now(): Instant = Clock.System.now() fun now(): Instant = Clock.System.now()
fun nowToSeconds(): Instant = Clock.System.now().truncateToSeconds() fun nowToSeconds(): Instant = Clock.System.now().truncateToSeconds()

View File

@ -10,25 +10,17 @@
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Clock import kotlin.time.Clock
import net.sergeych.crypto2.Hash import net.sergeych.crypto2.Hash
import net.sergeych.crypto2.initCrypto import net.sergeych.crypto2.initCrypto
import kotlin.random.Random import kotlin.random.Random
import kotlin.random.nextUBytes import kotlin.random.nextUBytes
import kotlin.test.Ignore
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertContentEquals import kotlin.test.assertContentEquals
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFalse import kotlin.test.assertFalse
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
suspend fun <T> 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 { class HashTest {
@Test @Test
fun testEqualMethods() { fun testEqualMethods() {
@ -77,3 +69,13 @@ class HashTest {
} }
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
suspend fun <T> 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
}

View File

@ -9,7 +9,7 @@
*/ */
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import kotlinx.datetime.Instant import kotlin.time.Instant
import net.sergeych.crypto2.initCrypto import net.sergeych.crypto2.initCrypto
import net.sergeych.utools.nowToSeconds import net.sergeych.utools.nowToSeconds
import net.sergeych.utools.pack import net.sergeych.utools.pack