upgrade kotlin; sealedbox now accept general signing/verifying keys

This commit is contained in:
Sergey Chernov 2024-08-24 08:34:50 +02:00
parent 134f619037
commit 054252a3ce
3 changed files with 10 additions and 10 deletions

View File

@ -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")
}
}

View File

@ -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 <reified T>encode(value: T, vararg keys: SigningSecretKey): UByteArray =
inline fun <reified T>encode(value: T, vararg keys: SigningKey): UByteArray =
create(BipackEncoder.encode(value).toUByteArray(), *keys).encoded
/**

View File

@ -65,7 +65,6 @@ class SymmetricKey(
return keyBytes.contentHashCode()
}
companion object {
/**
* Create a secure random symmetric key.