diff --git a/build.gradle.kts b/build.gradle.kts index aafeb8e..95048ab 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,7 +19,7 @@ buildscript { } } -version = "1.0.0-alpha" +version = "1.0.1-alpha" group = "io.iohk.atala.prism" allprojects { diff --git a/didcomm/didcomm.podspec b/didcomm/didcomm.podspec index b02acb7..84e5005 100644 --- a/didcomm/didcomm.podspec +++ b/didcomm/didcomm.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'didcomm' - spec.version = '1.0.0-alpha' + spec.version = '1.0.1-alpha' spec.homepage = '' spec.source = { :http=> ''} spec.authors = 'IOG' diff --git a/didpeer/build.gradle.kts b/didpeer/build.gradle.kts index 91d35fd..26b2a9c 100644 --- a/didpeer/build.gradle.kts +++ b/didpeer/build.gradle.kts @@ -99,7 +99,10 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("io.iohk.atala.prism:multibase:1.0.0-alpha") + implementation("io.iohk.atala.prism:multibase:1.6.0-alpha") + implementation("io.iohk.atala.prism:varint:1.6.0-alpha") + implementation("io.iohk.atala.prism:base64:1.6.0-alpha") + implementation("io.iohk.atala.prism:base58:1.6.0-alpha") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1") implementation("com.squareup.okio:okio:3.2.0") } diff --git a/didpeer/didpeer.podspec b/didpeer/didpeer.podspec index fb4cdf9..10c6d2b 100644 --- a/didpeer/didpeer.podspec +++ b/didpeer/didpeer.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'didpeer' - spec.version = '1.0.0-alpha' + spec.version = '1.0.1-alpha' spec.homepage = '' spec.source = { :http=> ''} spec.authors = 'IOG' diff --git a/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/Multicodec.kt b/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/Multicodec.kt index b53faa5..0f064c9 100644 --- a/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/Multicodec.kt +++ b/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/Multicodec.kt @@ -1,5 +1,6 @@ package io.iohk.atala.prism.didcomm.didpeer.core +import io.iohk.atala.prism.apollo.varint.VarInt import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAgreement import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAuthentication import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypePeerDID @@ -13,15 +14,15 @@ enum class Codec(val prefix: Int) { fun toMulticodec(value: ByteArray, keyType: VerificationMethodTypePeerDID): ByteArray { val prefix = getCodec(keyType).prefix val byteBuffer = Buffer() - VarInt.writeVarInt(prefix, byteBuffer) + VarInt.write(prefix, byteBuffer) return byteBuffer.readByteArray().plus(value) } fun fromMulticodec(value: ByteArray): Pair { - val prefix = VarInt.readVarInt(Buffer().write(value)) + val prefix = VarInt.read(Buffer().write(value)) val codec = getCodec(prefix) val byteBuffer = Buffer() - VarInt.writeVarInt(prefix, byteBuffer) + VarInt.write(prefix, byteBuffer) return Pair(codec, value.drop(2).toByteArray()) } diff --git a/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarInt.kt b/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarInt.kt deleted file mode 100644 index 050327f..0000000 --- a/didpeer/src/commonMain/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarInt.kt +++ /dev/null @@ -1,31 +0,0 @@ -package io.iohk.atala.prism.didcomm.didpeer.core - -import okio.Buffer - -// TODO: Move this implementation to its own Module and update it to follow these specifications -// https://github.com/multiformats/unsigned-varint -object VarInt { - fun writeVarInt(value: Int, byteBuffer: Buffer) { - var value = value - while ((value and -0x80).toLong() != 0L) { - byteBuffer.writeByte(value and 0x7F or 0x80) - value = value ushr 7 - } - byteBuffer.writeByte(value and 0x7F) - } - - fun readVarInt(byteBuffer: Buffer): Int { - var value = 0 - var i = 0 - var b = 0 - while (byteBuffer.size > 0 && byteBuffer.readByte().toInt().also { b = it } and 0x80 != 0) { - value = value or (b and 0x7F shl i) - i += 7 - if (i > 35) { - throw IllegalArgumentException("Variable length quantity is too long") - } - } - value = value or (b shl i) - return value - } -} diff --git a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestCreateNumalgo0.kt b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestCreateNumalgo0.kt index 8ef39c9..6156ce7 100644 --- a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestCreateNumalgo0.kt +++ b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestCreateNumalgo0.kt @@ -1,7 +1,6 @@ package io.iohk.atala.prism.didcomm.didpeer import io.iohk.atala.prism.didcomm.didpeer.core.toJson -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFails @@ -32,9 +31,7 @@ class TestCreateNumalgo0 { } @Test - @Ignore // to be removed once Base64 has been fixed fun testCreateNumalgo0MalformedShortInceptionKey() { - // Issue with Base64 for (key in shortKeys) { val ex = assertFails { createPeerDIDNumalgo0(key) diff --git a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestDemo.kt b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestDemo.kt index ed6ea9f..186f37a 100644 --- a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestDemo.kt +++ b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/TestDemo.kt @@ -1,20 +1,9 @@ package io.iohk.atala.prism.didcomm.didpeer -import io.iohk.atala.prism.didcomm.didpeer.core.VarInt -import okio.Buffer import kotlin.test.Test -import kotlin.test.assertEquals class TestDemo { - @Test - fun moussaTest() { - val buffer = Buffer() - VarInt.writeVarInt(500, buffer) - val result = VarInt.readVarInt(buffer) - assertEquals(500, result) - } - @Test fun testCreateResolvePeerDID() { val encryptionKeys = listOf( diff --git a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarIntTests.kt b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarIntTests.kt index 6fe5f6b..4c89b5a 100644 --- a/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarIntTests.kt +++ b/didpeer/src/commonTest/kotlin/io.iohk.atala.prism.didcomm.didpeer/core/VarIntTests.kt @@ -1,25 +1,18 @@ package io.iohk.atala.prism.didcomm.didpeer.core +import io.iohk.atala.prism.apollo.varint.VarInt import okio.Buffer import kotlin.test.Test import kotlin.test.assertEquals class VarIntTests { - @Test - fun testVarInt() { - val origin = 1234774 - val byteBuffer = Buffer() - VarInt.writeVarInt(origin, byteBuffer) - val fin: Int = VarInt.readVarInt(byteBuffer) - assertEquals(origin, fin) - } @Test fun testVarIntX25519() { val origin = Codec.X25519.prefix val byteBuffer = Buffer() - VarInt.writeVarInt(origin, byteBuffer) - val fin: Int = VarInt.readVarInt(byteBuffer) + VarInt.write(origin, byteBuffer) + val fin: Int = VarInt.read(byteBuffer) assertEquals(origin, fin) } @@ -27,8 +20,8 @@ class VarIntTests { fun testVarIntED25519() { val origin = Codec.ED25519.prefix val byteBuffer = Buffer() - VarInt.writeVarInt(origin, byteBuffer) - val fin: Int = VarInt.readVarInt(byteBuffer) + VarInt.write(origin, byteBuffer) + val fin: Int = VarInt.read(byteBuffer) assertEquals(origin, fin) }