Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: interpret publicKeyMultibase as multicodec #298

Merged
merged 2 commits into from
Sep 27, 2023

Conversation

mirceanis
Copy link
Member

@mirceanis mirceanis commented Sep 27, 2023

fixes #297

Some users of publicKeyMultibase actually encode a multicodec prefixed byte array.
This leads to keys that are not decoded properly and thus are not usable for verification.

This fix includes some heuristics to try to decode multibase directly if it fits known public key lengths and then attempt multicodec decoding.

This PR also exports the methods used for key conversions for use in other libraries.

*
* @public
*/
export function bytesToMultibase(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to eventually pull this function into its own util package? we have a similar function in @veramo/utils as you know, and it would be best to not have to maintain 2 identical functions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll use the function from here in veramo and remove the duplicate

@mirceanis mirceanis changed the title fix: try to interpret publicKeyMultibase as multicodec feat: interpret publicKeyMultibase as multicodec Sep 27, 2023
@mirceanis mirceanis merged commit bf76cea into master Sep 27, 2023
2 checks passed
@mirceanis mirceanis deleted the 297-multicodec-support branch September 27, 2023 18:49
uport-automation-bot pushed a commit that referenced this pull request Sep 27, 2023
# [7.4.0](7.3.0...7.4.0) (2023-09-27)

### Features

* interpret publicKeyMultibase as multicodec ([#298](#298)) ([bf76cea](bf76cea)), closes [#297](#297)
@uport-automation-bot
Copy link
Collaborator

🎉 This PR is included in version 7.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] multicodec encoded publicKeyMultibase is not interpreted correctly
3 participants