upgrade kotlin; sealedbox now accept general signing/verifying keys
This commit is contained in:
parent
134f619037
commit
054252a3ce
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "2.0.0"
|
kotlin("multiplatform") version "2.0.20"
|
||||||
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0"
|
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.20"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ kotlin {
|
|||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
browser()
|
browser()
|
||||||
|
nodejs()
|
||||||
}
|
}
|
||||||
linuxX64()
|
linuxX64()
|
||||||
linuxArm64()
|
linuxArm64()
|
||||||
@ -47,7 +48,7 @@ kotlin {
|
|||||||
|
|
||||||
implementation("com.ionspin.kotlin:multiplatform-crypto-libsodium-bindings:0.9.2")
|
implementation("com.ionspin.kotlin:multiplatform-crypto-libsodium-bindings:0.9.2")
|
||||||
api("com.ionspin.kotlin:bignum:0.3.9")
|
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")
|
api("net.sergeych:mp_stools:1.5.1")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class SealedBox(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
constructor(message: UByteArray, vararg keys: SigningSecretKey) :
|
constructor(message: UByteArray, vararg keys: SigningKey) :
|
||||||
this(message, keys.map { it.seal(message) } )
|
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
|
* key, or return unchanged (same) object if it is already signed by this key; you
|
||||||
* _can't assume it always returns a copied object!_
|
* _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
|
if (key.verifyingKey in this) this
|
||||||
else SealedBox(message, seals + key.seal(message),false)
|
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]
|
* Add expiring seal, otherwise use [plus]. Overrides exising seal for [key]
|
||||||
* if present:
|
* if present:
|
||||||
*/
|
*/
|
||||||
fun addSeal(key: SigningSecretKey, expresAt: Instant): SealedBox {
|
fun addSeal(key: SigningKey, expiresAt: Instant): SealedBox {
|
||||||
val filtered = seals.filter { it.publicKey != key.verifyingKey }
|
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.
|
* 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 }
|
return seals.any { it.publicKey == publicKey }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class SealedBox(
|
|||||||
return SealedBox(data, keys.map { it.seal(data) }, false)
|
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
|
create(BipackEncoder.encode(value).toUByteArray(), *keys).encoded
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,6 @@ class SymmetricKey(
|
|||||||
return keyBytes.contentHashCode()
|
return keyBytes.contentHashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
* Create a secure random symmetric key.
|
* Create a secure random symmetric key.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user