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

Recognizing and handling peer DIDs Regex seems out of date #31

Open
devin-fisher opened this issue Apr 8, 2021 · 4 comments
Open

Recognizing and handling peer DIDs Regex seems out of date #31

devin-fisher opened this issue Apr 8, 2021 · 4 comments

Comments

@devin-fisher
Copy link
Contributor

The regex seems to be out of date.

^did:peer:[01](z)([1-9a-km-zA-HJ-NP-Z]{46,47})$

  1. There seems to be 3 numalgo possibilities
  2. There is no capture group for numalgo even though it is referenced.
  3. I don't really understand method 2 yet but is sure to be 46 to 47 characters long (question, not statement)

^did:peer:[01](z)([1-9a-km-zA-HJ-NP-Z]{46,47})$

@devin-fisher
Copy link
Contributor Author

devin-fisher commented Apr 8, 2021

minimally, seems to need

^did:peer:([012])(z)([1-9a-km-zA-HJ-NP-Z]{46,47})$

@dhh1128
Copy link
Collaborator

dhh1128 commented Apr 8, 2021

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?

@devin-fisher
Copy link
Contributor Author

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?

@TimoGlastra
Copy link

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

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

3 participants