peer-did-method-spec
peer-did-method-spec copied to clipboard
Recognizing and handling peer DIDs Regex seems out of date
The regex seems to be out of date.
^did:peer:[01](z)([1-9a-km-zA-HJ-NP-Z]{46,47})$
- There seems to be 3
numalgo
possibilities - There is no capture group for
numalgo
even though it is referenced. - I don't really understand method 2 yet but is sure to be 46 to 47 characters long (question, not statement)
https://github.com/decentralized-identity/peer-did-method-spec/blob/202a91338f18e28612724b60f3843c6f6b123226/core.html#L279
minimally, seems to need
^did:peer:([012])(z)([1-9a-km-zA-HJ-NP-Z]{46,47})$
Yes, the regex is out of date. We need something like ^did:peer:([01](z)([1-9a-km-zA-HJ-NP-Z]{46,47})$|2<up to several hundred base64 chars>$)
. @TelegramSam : do you want to limit how long a method-2 DID can be?
Might make sense to do something like this:
Generic Regex For Peer DID:
^did:peer:([\d+]).*
This would derive the numalgo
Then have method specific Regex base on the numalgo
It seems that the current regex is over specific anyway. The number of characters is only true if uses the z
base58. If we supported a different transform code for base64, the number of characters would be different. Do we really want to express every permutation?
Also running into some issues with the regex when using other types of keys. E.g the fingerprint of a bls12381g1 key looks like this. Which is 69 characters long.
z3tEFVhKXU6NQAKw17iY6Uh372YwZDrMZrQHfoTXVpTtoxsDPT3naA4sgfv63o3ayoF1MU
Or the g2 variant, which is 134 characters long
UC78Kzw6c4cvZqJ8wfFeFCswrGQ6KeDTcoRGzmHD8PeEY8yeZ4QUfhHh5Kt89UXRJw6W8P2bk2ezGqk7S9gkyb9P4jEzdEfmhvkqykjVPtUfsHkEkF6zd2SuTNECxzHkNmywV1
Maybe we should just remove the character limit in the regex? Or at least make it sufficient for longer keys