0.7.1 started. fixed secret key serialization excessive size for signing/verifying keys
This commit is contained in:
parent
10ec58ec08
commit
e8fa634640
@ -8,6 +8,8 @@ All primitives meant to send over the network or store are `kotlinx.serializatio
|
||||
|
||||
# Important notes on upgrade
|
||||
|
||||
___Please upgrade to 0.7.1+___ as it has much more compact but not backward-compatible serialization format!
|
||||
|
||||
Since version __0.5.*__ key identity calculation for asymmetric keys is updated
|
||||
to make it safer for theoretic future attack on blake2b hashing. Key.id values
|
||||
are incompatible with older. Sorry for inconvenience.
|
||||
@ -19,7 +21,7 @@ repositories {
|
||||
maven("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
|
||||
}
|
||||
dependencies {
|
||||
import("net.sergeych:crypto2:0.5.8")
|
||||
import("net.sergeych:crypto2:0.7.1-SNAPSHOT")
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -9,7 +9,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "net.sergeych"
|
||||
version = "0.6.3-SNAPSHOT"
|
||||
version = "0.7.1-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -30,6 +30,7 @@ class SigningSecretKey(
|
||||
override fun seal(message: UByteArray, expiresAt: Instant?): Seal =
|
||||
Seal.create(this, message, now(), expiresAt)
|
||||
|
||||
@Transient
|
||||
override val id: KeyId = verifyingKey.id
|
||||
|
||||
override val label: String
|
||||
|
@ -3,6 +3,8 @@ import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.sergeych.bipack.BipackDecoder
|
||||
import net.sergeych.bipack.BipackEncoder
|
||||
import net.sergeych.crypto2.*
|
||||
import net.sergeych.tools.bipack
|
||||
import net.sergeych.tools.biunpack
|
||||
@ -390,4 +392,28 @@ class KeysTest {
|
||||
assertNull(Container.decrypt<String>(bytes, kr1))
|
||||
assertEquals(data, Container.decrypt<String>(bytes, kr2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEncodedSizes() = runTest {
|
||||
initCrypto()
|
||||
val x = SigningSecretKey.new()
|
||||
// println("key bytes: ${x.keyBytes.size}:\n${x.keyBytes.toDump()}")
|
||||
val y = BipackEncoder.encode(x)
|
||||
// println("packed: ${y.size}: ${y.toDump()}")
|
||||
assertTrue { x.keyBytes.size + 5 > y.size }
|
||||
assertEquals(x, BipackDecoder.decode<SigningSecretKey>(y))
|
||||
assertContentEquals(x.keyBytes, BipackDecoder.decode<SigningSecretKey>(y).keyBytes)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEncodedSizes2() = runTest {
|
||||
initCrypto()
|
||||
val x = SecretKey.new()
|
||||
// println("key bytes: ${x.keyBytes.size}:\n${x.keyBytes.toDump()}")
|
||||
val y = BipackEncoder.encode(x)
|
||||
// println("packed: ${y.size}: ${y.toDump()}")
|
||||
assertTrue { x.keyBytes.size + 5 > y.size }
|
||||
assertEquals(x, BipackDecoder.decode<SecretKey>(y))
|
||||
assertContentEquals(x.keyBytes, BipackDecoder.decode<SecretKey>(y).keyBytes)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user