Skip to content

Commit

Permalink
fix: use correct base encoding with JWK (#6)
Browse files Browse the repository at this point in the history
* fix: use correct base encoding with JWK

* fix: remove workaround for base64 decoding

* enhancements: update invalid key size error message
  • Loading branch information
hamada147 committed Apr 25, 2023
1 parent 6665c8b commit fd26f49
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
}

allprojects {
version = "1.0.2-alpha"
version = "1.0.3-alpha"
group = "io.iohk.atala.prism.didcomm"

repositories {
Expand Down
2 changes: 1 addition & 1 deletion didcomm/didcomm.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'didcomm'
spec.version = '1.0.2-alpha'
spec.version = '1.0.3-alpha'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = 'IOG'
Expand Down
2 changes: 1 addition & 1 deletion didpeer/didpeer.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'didpeer'
spec.version = '1.0.2-alpha'
spec.version = '1.0.3-alpha'
spec.homepage = ''
spec.source = { :http=> ''}
spec.authors = 'IOG'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.iohk.atala.prism.didcomm.didpeer.core

import io.iohk.atala.prism.apollo.base64.base64UrlDecodedBytes
import io.iohk.atala.prism.apollo.base64.base64UrlEncoded
import io.iohk.atala.prism.apollo.base64.base64UrlPadDecodedBytes
import io.iohk.atala.prism.didcomm.didpeer.VerificationMaterialPeerDID
import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAgreement
import io.iohk.atala.prism.didcomm.didpeer.VerificationMethodTypeAuthentication
Expand Down Expand Up @@ -39,9 +39,9 @@ fun fromJwk(verMaterial: VerificationMaterialPeerDID<out VerificationMethodTypeP
// Base64.decodeBase64(value) // this line in JVM handle both Base64 Standard & Base64 URL
// The following if condition is a workaround for a bug in Apollo Base64URLPad decoding which will be
// fixed in the next release
var decoded = value.base64UrlPadDecodedBytes
if (decoded.isNotEmpty() && decoded.last().toInt() == 0) {
decoded = decoded.dropLast(1).toByteArray()
}
return decoded
// var decoded = value.base64UrlDecodedBytes
// if (decoded.isNotEmpty() && decoded.last().toInt() == 0) {
// decoded = decoded.dropLast(1).toByteArray()
// }
return value.base64UrlDecodedBytes
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ internal fun validateJson(value: String) {
internal fun validateRawKeyLength(key: ByteArray) {
// for all supported key types now (ED25519 and X25510) the expected size is 32
if (key.size != 32)
throw IllegalArgumentException("Invalid key $key")
throw IllegalArgumentException("Invalid key $key, size should be 32 and it is: ${key.size}")
}

0 comments on commit fd26f49

Please sign in to comment.