Is the number of digits of DID(Decentralized Identifier) specified by W3C fixed?
I tried to check the specification at https://www.w3.org/TR/did-core/, however could not find any explanation there. I particularly checked "3.1 DID Syntax" at https://www.w3.org/TR/did-core/#did-syntax
I am asking about the number of digits after the second colon. In case of the following did, I would like to know about the last section starting with "123..." did:method:123456789abcdefghi
In the w3c document, I see examples with 6 digits and 20 digits. Therefore, it seems that the number of digits is not fixed and can be specified by the developer.
My best guess is that the number of digits of DID is not fixed.
Anyone who knows well about this, please let me know if my guess is correct.
The part which is mentioned in your question is called the method-specific-id or method-specific-identifier, this is the part which comes after the second colon (:
). It is termed as method specific which tells us that it is not bound with any maximum limit and totally depends on the method to determine it's nature, structure and length as well as how it will be determined.
The section which you are referring to form the w3c standards for the syntax of DID at https://www.w3.org/TR/did-core/#did-syntax, is stating the same:
As per the DID ABNF Syntax rules
method-specific-id = *( *idchar ":" ) 1*idchar
idchar = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
We can see these syntax rules are based on ABNF Rules, in ABNF asterisk (*
) represents repetitions (https://www.rfc-editor.org/rfc/rfc5234#section-3.6). Specifying how many times a certain element can appear.
*idchar
means zero or more occurrences of idchar.1*idchar
means one or more occurrences of idchar.And the idchar here can contain uppercase and lowercase letters, digits, periods, hyphens, underscores and percent-encoded characters.
Note : The colon (:) in the syntax rule is signifying that the method-specific-id can indeed have various sections separated by the colon. Example: did:example:foo:bar:baz
So yes, your guess is right that the number of characters after the second colon in DID are not fixed and are defined via the DID's method which is ultimately defined by the developer.
Although the syntax rules have not explicitly specified a maximum length for the method-specific-id, we should avoid overly long DID which can become cumbersome to manage, store, share, remember, hindering the user experience.