forked from sergeych/crypto2
upgrade kotlin; sealedbox now accept general signing/verifying keys
This commit is contained in:
1 parent
134f619037
commit
054252a3ce
3 files changed
+10
-10
No files matched your search
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,6 @@ class SymmetricKey(
|
||||
return keyBytes.contentHashCode()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Create a secure random symmetric key.
|
||||
|
||||
Reference in new issue
Block a user