Why specificing both the base and the prefix ?
Closed this issue · 2 comments
ticapix commented
Hi,
I'm trying to transform a JWK into a did:key
The JWK is defined as
{
"crv": "Ed25519",
"d": "zXt8CIQcpTe5AqrSj7jbCmsT7Hk_iSsa7OugpuETy00",
"kty": "OKP",
"x": "1IFOwqNRAXr7bxkzsaUP4c5TsfODswA3L8EZYoaWP08"
}
To do so, I need to decode the x
parameter which is encoded in base64url
.
I'm expecting to either be able to use the procedural method via multibase.decode()
because I would prefix the string with the proper base64url
flag u
, or use the object-oriented style via multibase.get("base64url").decode()
, without having to prefix the string.
multibase.decode("u" + "1IFOwqNRAXr7bxkzsaUP4c5TsfODswA3L8EZYoaWP08") # works
multibase.get("base64url").decode("u" + "1IFOwqNRAXr7bxkzsaUP4c5TsfODswA3L8EZYoaWP08") # works
multibase.get("base64url").decode("1IFOwqNRAXr7bxkzsaUP4c5TsfODswA3L8EZYoaWP08") # fails
> multiformats.multibase.err.MultibaseKeyError: 'No known multibase code is a prefix of the given string.'
What is the point of getting the Multibase object if we still have to prefix the string ?
Is that the expected behavior ?
Best regards
ticapix commented
Solved.
I can directly use raw_decoder()
sg495 commented
Thank you for this, and for your pull request (which has now been merged)!