diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/BinaryId.kt b/src/commonMain/kotlin/net/sergeych/crypto2/BinaryId.kt index 3522776..2333af6 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/BinaryId.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/BinaryId.kt @@ -37,7 +37,7 @@ import kotlin.random.Random * @throws InvalidException if crc check failed */ @Serializable -open class BinaryId protected constructor ( +open class BinaryId( /** * The packed binary id. Note that serialized version is one byte longer containing * the size prefix diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/ByteChunk.kt b/src/commonMain/kotlin/net/sergeych/crypto2/ByteChunk.kt index ff099e2..6fd01e0 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/ByteChunk.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/ByteChunk.kt @@ -53,7 +53,7 @@ class ByteChunk(val data: UByteArray): Comparable { /** * hex representation of data */ - override fun toString(): String = hex + override fun toString(): String = base64Url /** * Hex encoded data diff --git a/src/commonMain/kotlin/net/sergeych/crypto2/VerifyingPublicKey.kt b/src/commonMain/kotlin/net/sergeych/crypto2/VerifyingPublicKey.kt index c278105..d2d0946 100644 --- a/src/commonMain/kotlin/net/sergeych/crypto2/VerifyingPublicKey.kt +++ b/src/commonMain/kotlin/net/sergeych/crypto2/VerifyingPublicKey.kt @@ -83,7 +83,10 @@ class VerifyingPublicKey(override val keyBytes: UByteArray) : UniversalKey(), Ve val data = s.decodeBase64Url().asUByteArray() if (data.size == 32) VerifyingPublicKey(data) - else { + else if( data.size == 34) { + // raw id + BinaryId(data).asVerifyingKey as VerifyingPublicKey + }else { runCatching { data.decodeFromBipack() }.getOrNull() ?: kotlin.runCatching { data.decodeFromBipack() as VerifyingPublicKey } .getOrElse { throw IllegalArgumentException("can't parse verifying key") } diff --git a/src/commonTest/kotlin/KeysTest.kt b/src/commonTest/kotlin/KeysTest.kt index d4ec5ec..eda80ab 100644 --- a/src/commonTest/kotlin/KeysTest.kt +++ b/src/commonTest/kotlin/KeysTest.kt @@ -456,5 +456,8 @@ class KeysTest { testToString(k4) for( i in listOf(k1, k2, k3, k4, k5, k6, k7, k8)) testAsString(i) + + val x = VerifyingPublicKey.parse("I1po9Y2I7p2aOxeh4nFyGPm3e0YunBEu1Mo-PmIqP84Evg") + println(x) } }