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

fix: Fix multibase [DEV-2307] #5

Merged
merged 3 commits into from
Mar 14, 2023
Merged

fix: Fix multibase [DEV-2307] #5

merged 3 commits into from
Mar 14, 2023

Conversation

DaevMithran
Copy link

What issue is this PR fixing

fixes decentralized-identity#1139

What is being changed

This PR slices the two-byte prefix 0xed01 in publicKeyMultibase according to the spec in extractPublicKeyHex function

Quality

Check all that apply:

  • I want these changes to be integrated
  • I successfully ran pnpm i, pnpm build, pnpm test, pnpm test:browser locally.
  • I allow my PR to be updated by the reviewers (to speed up the review process).

Details

If applicable, add screen captures, error messages or stack traces to help explain your problem.

@DaevMithran DaevMithran requested a review from Eengineer1 March 3, 2023 10:07
@@ -48,7 +48,7 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
const verificationKey = new Ed25519VerificationKey2020({
id,
controller,
publicKeyMultibase: this.preSigningKeyModification(u8a.fromString(key.publicKeyHex, 'hex')),
publicKeyMultibase: u8a.toString(u8a.fromString(key.publicKeyHex, 'hex'), 'base58btc'),

Choose a reason for hiding this comment

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

I'm not sure that's enough for it to be a multibase public key representation.
publicKeyMultibase is supposed to be self descriptive, meaning that the key type (Ed25519) should be determined by a prefix.
The internal publicKeyHex is supposed to be the raw public key data, without such a prefix.
The encoding you are doing here seems to be more suitable for publicKeyBase58 rather than publicKeyMultibase.

If you're having trouble matching a Verification Method from a DID document against the locally managed key (decentralized-identity#1139), it's more likely that there's a bug in extractPublicKeyBytes. Perhaps try to check if this line is doing the right thing.

@rosspower11 rosspower11 changed the title Fix multibase fix: Fix multibase [DEV-2307] Mar 8, 2023
@ankurdotb
Copy link

Copy link

@Eengineer1 Eengineer1 left a comment

Choose a reason for hiding this comment

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

Approved.

Re-arranged the fix to affect byte conversion.
Thanks!

@Eengineer1 Eengineer1 merged commit 7d231b6 into next Mar 14, 2023
@Eengineer1 Eengineer1 deleted the fix-multibase branch March 14, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants