diff --git a/README.md b/README.md index ab5e936..b68b61c 100644 --- a/README.md +++ b/README.md @@ -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") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index b6532d4..6700b04 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.sergeych" -version = "0.6.3-SNAPSHOT" +version = "0.7.1-SNAPSHOT" repositories { mavenCentral() diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt index f2a341e..8ba1241 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/SigningSecretKey.kt @@ -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 diff --git a/src/commonTest/kotlin/KeysTest.kt b/src/commonTest/kotlin/KeysTest.kt index 109f1c1..9ec6030 100644 --- a/src/commonTest/kotlin/KeysTest.kt +++ b/src/commonTest/kotlin/KeysTest.kt @@ -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(bytes, kr1)) assertEquals(data, Container.decrypt(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(y)) + assertContentEquals(x.keyBytes, BipackDecoder.decode(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(y)) + assertContentEquals(x.keyBytes, BipackDecoder.decode(y).keyBytes) + } }