Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testutil/keeper/ssi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func SsiKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
memStoreKey,
"SsiParams",
)
paramsSubspace = paramsSubspace.WithKeyTable(types.ParamKeyTable())
k := keeper.NewKeeper(
cdc,
storeKey,
Expand Down
20 changes: 17 additions & 3 deletions x/ssi/verification/common_document_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func documentIdentifier(docType string) string {
}

func returnVersionNumIdx(namespace string) int {
if namespace == "mainnet" {
if namespace == "" {
return 3
} else {
return 4
Expand Down Expand Up @@ -71,18 +71,32 @@ func IsValidID(Id string, namespace string, docType string) error {

// Mainnet Chain namespace check. If the document is registered on the mainnet chain,
// the namespace should be empty
var expectedLength int
if namespace == "" {
if len(docElements) != 3 {
return fmt.Errorf("expected number of did id elements for mainnet to be 3, got %s", fmt.Sprint(len(docElements)))
if docIdentifier == "sch" {
expectedLength = 4
} else {
expectedLength = 3
}
docMethodSpecificId = 2
} else {
if docIdentifier == "sch" {
expectedLength = 5
} else {
expectedLength = 4
}
docMethodSpecificId = 3

docNamespace := docElements[docNamespaceIndex]
if namespace != docNamespace {
return fmt.Errorf("expected did namespace %s, got %s", namespace, docNamespace)
}
}

if len(docElements) != expectedLength {
return fmt.Errorf("expected %s id elements, got %s", fmt.Sprintf("%d", expectedLength), fmt.Sprintf("%d", len(docElements)))
}

// Check if method-specific-id string is alphanumeric and
// has the minimum required character length of 32
isProperMethodSpecificId, err := regexp.MatchString(
Expand Down
Loading