You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Did key spec now has standardized errors for did:key.
While this library is not specifically a did:key library it does checks that the did:key spec expects to happen.
These checks need to raise specific errors in order to conform to the spec.
The errors that need to be raised are:
invalidDid (when the publicKeyMultibase doesn't start with z)
invalidPublicKeyLength (when the publicKey keyBuffer is not 32 bytes in length)
For a public key this ensure the first letter in the multibaseKey is z and then it checks that the first bytes of the resulting Uint8Array matches the bytes of the const MULTICODEC_ED25519_PUB_HEADER = new Uint8Array([0xed, 0x01]);
So should we update this library to throw errors that conform to the did:key specs errors?
Currently not starting with a z should result in an invalidDid error (this might be updated to invalidDidKey) This would need to happen before the byte check.
Secondly we now need to throw this error: invalidPublicKeyLength
This just requires changing the error here so that it can be caught and reported back to an implementation:
Did key spec now has standardized errors for
did:key
.While this library is not specifically a
did:key
library it does checks that thedid:key
spec expects to happen.These checks need to raise specific errors in order to conform to the spec.
The errors that need to be raised are:
invalidDid
(when the publicKeyMultibase doesn't start withz
)invalidPublicKeyLength
(when the publicKey keyBuffer is not 32 bytes in length)Currently this library has the following check:
ed25519-verification-key-2020/lib/Ed25519VerificationKey2020.js
Lines 48 to 53 in 56eb921
ed25519-verification-key-2020/lib/Ed25519VerificationKey2020.js
Lines 442 to 451 in 56eb921
For a public key this ensure the first letter in the
multibaseKey
isz
and then it checks that the first bytes of the resultingUint8Array
matches the bytes of theconst MULTICODEC_ED25519_PUB_HEADER = new Uint8Array([0xed, 0x01]);
So should we update this library to throw errors that conform to the
did:key
specs errors?Currently not starting with a
z
should result in aninvalidDid
error (this might be updated toinvalidDidKey
) This would need to happen before the byte check.Secondly we now need to throw this error:
invalidPublicKeyLength
This just requires changing the error here so that it can be caught and reported back to an implementation:
ed25519-verification-key-2020/lib/ed25519.js
Lines 132 to 149 in 56eb921
I think we should use
Error.code
to report these errors back like this:These can be caught later down the line and used for various aspects of conformance.
The text was updated successfully, but these errors were encountered: