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

secretKeyMultibase size incorrect #11

Open
brianorwhatever opened this issue Apr 12, 2024 · 3 comments
Open

secretKeyMultibase size incorrect #11

brianorwhatever opened this issue Apr 12, 2024 · 3 comments

Comments

@brianorwhatever
Copy link

This library creates secretKeyMultibase values that are 64 bytes in size whereas the DI spec says that they should be only 32 bytes. I assume the public key is appended or prepended and this is what used to be done in the older signature suites and maybe this has been updated? The @noble/ed25519 crypto package expects only 32 bytes.

@dlongley
Copy link
Member

dlongley commented Apr 13, 2024

Yeah, there was some debate on how this should be formatted and we ended up on cutting it to 32 bytes. We should update this package and do a major release. Note: You're right that it's just appending the public key onto the secret key material to get to 64 bytes.

@dlongley
Copy link
Member

There is already some code that does something around this... so we should investigate to figure out what is needed:

https://github.com/digitalbazaar/ed25519-multikey/blob/main/lib/serialize.js#L12

@dlongley
Copy link
Member

@brianorwhatever,

There's an option, canonicalize that can be set to true to force old keys that used 64 bytes to output 32 when exporting, see here:

https://github.com/digitalbazaar/ed25519-multikey/blob/main/lib/serialize.js#L14-L15

The current version doesn't mess with imported keys, exporting them the same way they were imported (it looks like). We could have a new major release that defaults to canonicalize=true -- or we could leave things as-is.

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

No branches or pull requests

2 participants