0.5.3 incompatible but better asymmetric keys id (both encryption and signing)

This commit is contained in:
sergeych committed 2024-08-19 16:45:33 +02:00
1 parent 6431d4896a
commit 134f619037
7 files changed
+38 -6

No files matched your search

+11
View File
@@ -159,6 +159,11 @@ class KeysTest {
val x2 = pk1.encryptMessage(plain, sk1).encoded
assertFalse { x1 contentEquals x2 }
// public key ID should use key bytes instead
assertContentEquals(pk1.keyBytes, pk1.id.binaryTag.take(32).toUByteArray())
assertContentEquals(pk1.keyBytes, sk1.id.binaryTag.take(32).toUByteArray())
}
@Test
fun asymmetricKeySerializationTest() = runTest {
@@ -261,5 +266,11 @@ class KeysTest {
val dk2 = unpack<VerifyingPublicKey>(s2)
assertEquals(k, dk1)
assertEquals(k.verifyingKey, dk2)
// id for public/shared keys should be of the key itself to increase safety.
// not hashed!
assertContentEquals(k.verifyingKey.keyBytes, dk2.id.binaryTag.take(32).toUByteArray())
assertContentEquals(k.verifyingKey.keyBytes, dk1.id.binaryTag.take(32).toUByteArray())
}
}