From e2fe32477273ee9021142157d11e152c8ca48599 Mon Sep 17 00:00:00 2001 From: arnabghose997 Date: Sun, 20 Feb 2022 07:54:36 +0530 Subject: [PATCH] Code has been refactored to reduce redundancy; Service and capabilityDelegation field has been implemented --- docs/static/openapi.yml | 82 +- proto/ssi/v1/did.proto | 26 +- proto/ssi/v1/query.proto | 2 +- proto/ssi/v1/tx.proto | 45 +- x/ssi/client/cli/tx_ssi.go | 4 +- x/ssi/client/cli/tx_utils.go | 4 +- x/ssi/keeper/did.go | 25 +- ...get_did_doc_by_id.go => grpc_query_did.go} | 12 + x/ssi/keeper/grpc_query_did_doc_count.go | 22 - x/ssi/keeper/grpc_query_get_schema.go | 36 - x/ssi/keeper/grpc_query_schema.go | 78 + x/ssi/keeper/grpc_query_schema_count.go | 22 - x/ssi/keeper/grpc_query_schemas.go | 41 - x/ssi/keeper/msg_server_create_did.go | 60 - ...server_update_did.go => msg_server_did.go} | 55 +- ..._create_schema.go => msg_server_schema.go} | 0 x/ssi/keeper/schema.go | 48 +- x/ssi/keeper/verify.go | 9 +- x/ssi/types/did.go | 26 + x/ssi/types/did.pb.go | 1120 ++++++++- x/ssi/types/errors.go | 3 +- x/ssi/types/message_create_did.go | 107 - .../{message_update_did.go => message_did.go} | 123 +- ...age_create_schema.go => message_schema.go} | 0 x/ssi/types/query.pb.go | 96 +- x/ssi/types/tx.pb.go | 2207 +---------------- x/ssi/utils/did_vars.go | 8 + x/ssi/utils/utils.go | 95 +- 28 files changed, 1605 insertions(+), 2751 deletions(-) rename x/ssi/keeper/{grpc_query_get_did_doc_by_id.go => grpc_query_did.go} (64%) delete mode 100644 x/ssi/keeper/grpc_query_did_doc_count.go delete mode 100644 x/ssi/keeper/grpc_query_get_schema.go create mode 100644 x/ssi/keeper/grpc_query_schema.go delete mode 100644 x/ssi/keeper/grpc_query_schema_count.go delete mode 100644 x/ssi/keeper/grpc_query_schemas.go delete mode 100644 x/ssi/keeper/msg_server_create_did.go rename x/ssi/keeper/{msg_server_update_did.go => msg_server_did.go} (53%) rename x/ssi/keeper/{msg_server_create_schema.go => msg_server_schema.go} (100%) delete mode 100644 x/ssi/types/message_create_did.go rename x/ssi/types/{message_update_did.go => message_did.go} (57%) rename x/ssi/types/{message_create_schema.go => message_schema.go} (100%) create mode 100644 x/ssi/utils/did_vars.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 47af08c..5dc98cb 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -11931,6 +11931,21 @@ paths: type: array items: type: string + capabilityDelegation: + type: array + items: + type: string + service: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string created: type: string updated: @@ -20161,7 +20176,7 @@ definitions: description: >- MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. - hypersignprotocol.hidnode.ssi.DidDocStructCreateDID: + hypersignprotocol.hidnode.ssi.Did: type: object properties: context: @@ -20207,28 +20222,11 @@ definitions: type: array items: type: string - created: - type: string - updated: - type: string - hypersignprotocol.hidnode.ssi.DidDocStructUpdateDID: - type: object - properties: - context: - type: array - items: - type: string - id: - type: string - controller: + capabilityDelegation: type: array items: type: string - alsoKnownAs: - type: array - items: - type: string - verificationMethod: + service: type: array items: type: object @@ -20237,26 +20235,8 @@ definitions: type: string type: type: string - controller: - type: string - publicKeyMultibase: + serviceEndpoint: type: string - authentication: - type: array - items: - type: string - assertionMethod: - type: array - items: - type: string - keyAgreement: - type: array - items: - type: string - capabilityInvocation: - type: array - items: - type: string created: type: string updated: @@ -20336,6 +20316,21 @@ definitions: type: array items: type: string + capabilityDelegation: + type: array + items: + type: string + service: + type: array + items: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string created: type: string updated: @@ -20499,6 +20494,15 @@ definitions: type: string additionalProperties: type: boolean + hypersignprotocol.hidnode.ssi.Service: + type: object + properties: + id: + type: string + type: + type: string + serviceEndpoint: + type: string hypersignprotocol.hidnode.ssi.SignInfo: type: object properties: diff --git a/proto/ssi/v1/did.proto b/proto/ssi/v1/did.proto index 1bf402e..ea29044 100644 --- a/proto/ssi/v1/did.proto +++ b/proto/ssi/v1/did.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package hypersignprotocol.hidnode.ssi; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; -import "ssi/v1/tx.proto"; - message Did { repeated string context = 1; string id = 2; @@ -14,6 +12,26 @@ message Did { repeated string assertionMethod = 7; repeated string keyAgreement = 8; repeated string capabilityInvocation = 9; - string created = 10; - string updated = 11; + repeated string capabilityDelegation = 10; + repeated Service service = 11; + string created = 12; + string updated = 13; +} + +message VerificationMethod { + string id = 1; + string type = 2; + string controller = 3; + string publicKeyMultibase = 4; +} + +message Service { + string id = 1; + string type = 2; + string serviceEndpoint = 3; +} + +message SignInfo { + string verification_method_id = 1; + string signature = 2; } \ No newline at end of file diff --git a/proto/ssi/v1/query.proto b/proto/ssi/v1/query.proto index 29c40dd..e2595c8 100644 --- a/proto/ssi/v1/query.proto +++ b/proto/ssi/v1/query.proto @@ -84,7 +84,7 @@ message QueryGetDidDocByIdRequest { } message QueryGetDidDocByIdResponse { - DidDocStructCreateDID didDoc = 1; + Did didDoc = 1; } message QueryDidDocCountRequest { diff --git a/proto/ssi/v1/tx.proto b/proto/ssi/v1/tx.proto index 7d1ba89..9ef2acd 100644 --- a/proto/ssi/v1/tx.proto +++ b/proto/ssi/v1/tx.proto @@ -6,6 +6,7 @@ package hypersignprotocol.hidnode.ssi; option go_package = "github.com/hypersign-protocol/hid-node/x/ssi/types"; import "ssi/v1/schema.proto"; +import "ssi/v1/did.proto"; // Msg defines the Msg service. service Msg { @@ -16,57 +17,17 @@ service Msg { } message MsgCreateDID { - DidDocStructCreateDID didDocString = 1; + Did didDocString = 1; repeated SignInfo signatures = 2; string creator = 3; } -message DidDocStructCreateDID { - repeated string context = 1; - string id = 2; - repeated string controller = 3; // DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller - repeated string alsoKnownAs = 4; - repeated VerificationMethod verificationMethod = 5; - repeated string authentication = 6; - repeated string assertionMethod = 7; - repeated string keyAgreement = 8; - repeated string capabilityInvocation = 9; - string created = 10; - string updated = 11; -} - -message DidDocStructUpdateDID { - repeated string context = 1; - string id = 2; - repeated string controller = 3; // DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller - repeated string alsoKnownAs = 4; - repeated VerificationMethod verificationMethod = 5; - repeated string authentication = 6; - repeated string assertionMethod = 7; - repeated string keyAgreement = 8; - repeated string capabilityInvocation = 9; - string created = 10; - string updated = 11; -} - -message VerificationMethod { - string id = 1; - string type = 2; - string controller = 3; - string publicKeyMultibase = 4; -} - message MsgCreateDIDResponse { uint64 id = 1; } -message SignInfo { - string verification_method_id = 1; - string signature = 2; -} - message MsgUpdateDID { - DidDocStructUpdateDID didDocString = 1; + Did didDocString = 1; repeated SignInfo signatures = 2; string creator = 3; } diff --git a/x/ssi/client/cli/tx_ssi.go b/x/ssi/client/cli/tx_ssi.go index 39772b3..b8f8d3f 100644 --- a/x/ssi/client/cli/tx_ssi.go +++ b/x/ssi/client/cli/tx_ssi.go @@ -28,7 +28,7 @@ func CmdCreateDID() *cobra.Command { } // Unmarshal DidDocString - var didDoc types.DidDocStructCreateDID + var didDoc types.Did err = clientCtx.Codec.UnmarshalJSON([]byte(argDidDocString), &didDoc) if err != nil { return err @@ -81,7 +81,7 @@ func CmdUpdateDID() *cobra.Command { } // Unmarshal DidDocString - var didDoc types.DidDocStructUpdateDID + var didDoc types.Did err = clientCtx.Codec.UnmarshalJSON([]byte(argDidDocString), &didDoc) if err != nil { return err diff --git a/x/ssi/client/cli/tx_utils.go b/x/ssi/client/cli/tx_utils.go index a4284ba..849c4da 100644 --- a/x/ssi/client/cli/tx_utils.go +++ b/x/ssi/client/cli/tx_utils.go @@ -9,13 +9,13 @@ import ( ) func getVerKey(cmd *cobra.Command, clientCtx client.Context) (ed25519.PrivateKey, error) { - // Try getting from arg + // Get the verification key from --ver-key flag verKeyPrivBase64, err := cmd.Flags().GetString(VerKeyFlag) if err != nil { return nil, err } - // Decode key + // Decode key into bytes verKeyPrivBytes, err := base64.StdEncoding.DecodeString(verKeyPrivBase64) if err != nil { return nil, err diff --git a/x/ssi/keeper/did.go b/x/ssi/keeper/did.go index c1bf1d5..acf06a7 100644 --- a/x/ssi/keeper/did.go +++ b/x/ssi/keeper/did.go @@ -11,13 +11,13 @@ import ( ) func (k Keeper) GetDidCount(ctx sdk.Context) uint64 { - // Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-") + // Get the store using storeKey and DidCountKey (which is "Did-count-") store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.DidCountKey)) - // Convert the PostCountKey to bytes + // Convert the DidCountKey to bytes byteKey := []byte(types.DidCountKey) // Get the value of the count bz := store.Get(byteKey) - // Return zero if the count value is not found (for example, it's the first post) + // Return zero if the count value is not found if bz == nil { return 0 } @@ -32,16 +32,14 @@ func (k Keeper) HasDid(ctx sdk.Context, id string) bool { } // Retrieves the DID from the store -func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.DidDocStructCreateDID, error) { +func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.Did, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) if !k.HasDid(*ctx, id) { return nil, sdkerrors.ErrNotFound } - // TODO: Currently, we can interchange DidDocStructCreateDID with DidDocStructUpdateDID - // as they are similar. They need to have a similar Interface - var value types.DidDocStructCreateDID + var value types.Did var bytes = store.Get([]byte(id)) if err := k.cdc.Unmarshal(bytes, &value); err != nil { return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidType, err.Error()) @@ -51,14 +49,14 @@ func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.DidDocStructCreateDI } func (k Keeper) SetDidCount(ctx sdk.Context, count uint64) { - // Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-") + // Get the store using storeKey and SchemaCountKey (which is "Did-count-") store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.DidCountKey)) - // Convert the PostCountKey to bytes + // Convert the DidCountKey to bytes byteKey := []byte(types.DidCountKey) // Convert count from uint64 to string and get bytes bz := make([]byte, 8) binary.BigEndian.PutUint64(bz, count) - // Set the value of Post-count- to count + // Set the value of Did-count- to count store.Set(byteKey, bz) } @@ -71,15 +69,14 @@ func (k Keeper) SetDid(ctx sdk.Context, did types.Did) error { } func (k Keeper) AppendDID(ctx sdk.Context, didSpec types.Did) uint64 { - // Get the current number of posts in the store + // Get the current number of DIDs in the store count := k.GetDidCount(ctx) // Get the store store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.DidKey)) - // Convert the post ID into bytes - // Marshal the post into bytes + // Marshal the DID into bytes didDocString := k.cdc.MustMarshal(&didSpec) store.Set(utils.UnsafeStrToBytes(didSpec.Id), didDocString) - // Update the post count + // Update the Did count k.SetDidCount(ctx, count+1) return count } diff --git a/x/ssi/keeper/grpc_query_get_did_doc_by_id.go b/x/ssi/keeper/grpc_query_did.go similarity index 64% rename from x/ssi/keeper/grpc_query_get_did_doc_by_id.go rename to x/ssi/keeper/grpc_query_did.go index 2eed506..ba3b73f 100644 --- a/x/ssi/keeper/grpc_query_get_did_doc_by_id.go +++ b/x/ssi/keeper/grpc_query_did.go @@ -9,6 +9,18 @@ import ( "google.golang.org/grpc/status" ) +func (k Keeper) DidDocCount(goCtx context.Context, req *types.QueryDidDocCountRequest) (*types.QueryDidDocCountResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + var didDocCount uint64 = k.GetDidCount(ctx) + + return &types.QueryDidDocCountResponse{Count: didDocCount}, nil +} + func (k Keeper) GetDidDocById(goCtx context.Context, req *types.QueryGetDidDocByIdRequest) (*types.QueryGetDidDocByIdResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") diff --git a/x/ssi/keeper/grpc_query_did_doc_count.go b/x/ssi/keeper/grpc_query_did_doc_count.go deleted file mode 100644 index 2c8a764..0000000 --- a/x/ssi/keeper/grpc_query_did_doc_count.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/x/ssi/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) DidDocCount(goCtx context.Context, req *types.QueryDidDocCountRequest) (*types.QueryDidDocCountResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - var didDocCount uint64 = k.GetDidCount(ctx) - - return &types.QueryDidDocCountResponse{Count: didDocCount}, nil -} diff --git a/x/ssi/keeper/grpc_query_get_schema.go b/x/ssi/keeper/grpc_query_get_schema.go deleted file mode 100644 index 7c76d8e..0000000 --- a/x/ssi/keeper/grpc_query_get_schema.go +++ /dev/null @@ -1,36 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/utils" - "github.com/hypersign-protocol/hid-node/x/ssi/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) GetSchema(goCtx context.Context, req *types.QueryGetSchemaRequest) (*types.QueryGetSchemaResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - // Get the key-value module store using the store key (in our case store key is "chain") - store := ctx.KVStore(k.storeKey) - // Get the part of the store that keeps posts (using post key, which is "Schema-value-") - schemaStore := prefix.NewStore(store, []byte(types.SchemaKey)) - bz := schemaStore.Get(utils.UnsafeStrToBytes(req.SchemaId)) - if bz == nil { - return nil, status.Error(codes.NotFound, "schema not found") - } - - var schema types.Schema - k.cdc.MustUnmarshal(bz, &schema) - - return &types.QueryGetSchemaResponse{ - Schema: &schema, - }, nil -} diff --git a/x/ssi/keeper/grpc_query_schema.go b/x/ssi/keeper/grpc_query_schema.go new file mode 100644 index 0000000..ff0ef16 --- /dev/null +++ b/x/ssi/keeper/grpc_query_schema.go @@ -0,0 +1,78 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/hypersign-protocol/hid-node/utils" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/hypersign-protocol/hid-node/x/ssi/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetSchema(goCtx context.Context, req *types.QueryGetSchemaRequest) (*types.QueryGetSchemaResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // Get the key-value module store using the store key (in our case store key is "chain") + store := ctx.KVStore(k.storeKey) + // Get the part of the store that keeps schemas (using post key, which is "Schema-value-") + schemaStore := prefix.NewStore(store, []byte(types.SchemaKey)) + bz := schemaStore.Get(utils.UnsafeStrToBytes(req.SchemaId)) + if bz == nil { + return nil, status.Error(codes.NotFound, "schema not found") + } + + var schema types.Schema + k.cdc.MustUnmarshal(bz, &schema) + + return &types.QueryGetSchemaResponse{ + Schema: &schema, + }, nil +} + +func (k Keeper) SchemaCount(goCtx context.Context, req *types.QuerySchemaCountRequest) (*types.QuerySchemaCountResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + var count uint64 = k.GetSchemaCount(ctx) + + return &types.QuerySchemaCountResponse{Count: count}, nil +} + +func (k Keeper) Schemas(goCtx context.Context, req *types.QuerySchemasRequest) (*types.QuerySchemasResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + // Define a variable that will store a list of schemas + var schemas []*types.Schema + // Get context with the information about the environment + ctx := sdk.UnwrapSDKContext(goCtx) + // Get the key-value module store using the store key (in our case store key is "chain") + store := ctx.KVStore(k.storeKey) + // Get the part of the store that keeps schema (using post key, which is "Schema-value-") + postStore := prefix.NewStore(store, []byte(types.SchemaKey)) + // Paginate the schema store based on PageRequest + pageRes, err := query.Paginate(postStore, req.Pagination, func(key []byte, value []byte) error { + var schema types.Schema + if err := k.cdc.Unmarshal(value, &schema); err != nil { + return err + } + schemas = append(schemas, &schema) + return nil + }) + // Throw an error if pagination failed + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return &types.QuerySchemasResponse{SchemaList: schemas, Pagination: pageRes}, nil +} \ No newline at end of file diff --git a/x/ssi/keeper/grpc_query_schema_count.go b/x/ssi/keeper/grpc_query_schema_count.go deleted file mode 100644 index 29bd0a5..0000000 --- a/x/ssi/keeper/grpc_query_schema_count.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/hypersign-protocol/hid-node/x/ssi/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) SchemaCount(goCtx context.Context, req *types.QuerySchemaCountRequest) (*types.QuerySchemaCountResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - var count uint64 = k.GetSchemaCount(ctx) - - return &types.QuerySchemaCountResponse{Count: count}, nil -} diff --git a/x/ssi/keeper/grpc_query_schemas.go b/x/ssi/keeper/grpc_query_schemas.go deleted file mode 100644 index 82e30ba..0000000 --- a/x/ssi/keeper/grpc_query_schemas.go +++ /dev/null @@ -1,41 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/hypersign-protocol/hid-node/x/ssi/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) Schemas(goCtx context.Context, req *types.QuerySchemasRequest) (*types.QuerySchemasResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - // Define a variable that will store a list of posts - var schemas []*types.Schema - // Get context with the information about the environment - ctx := sdk.UnwrapSDKContext(goCtx) - // Get the key-value module store using the store key (in our case store key is "chain") - store := ctx.KVStore(k.storeKey) - // Get the part of the store that keeps posts (using post key, which is "Post-value-") - postStore := prefix.NewStore(store, []byte(types.SchemaKey)) - // Paginate the posts store based on PageRequest - pageRes, err := query.Paginate(postStore, req.Pagination, func(key []byte, value []byte) error { - var schema types.Schema - if err := k.cdc.Unmarshal(value, &schema); err != nil { - return err - } - schemas = append(schemas, &schema) - return nil - }) - // Throw an error if pagination failed - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - return &types.QuerySchemasResponse{SchemaList: schemas, Pagination: pageRes}, nil -} diff --git a/x/ssi/keeper/msg_server_create_did.go b/x/ssi/keeper/msg_server_create_did.go deleted file mode 100644 index 058c2fc..0000000 --- a/x/ssi/keeper/msg_server_create_did.go +++ /dev/null @@ -1,60 +0,0 @@ -package keeper - -import ( - "context" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/hypersign-protocol/hid-node/x/ssi/types" - utils "github.com/hypersign-protocol/hid-node/x/ssi/utils" -) - -func (k msgServer) CreateDID(goCtx context.Context, msg *types.MsgCreateDID) (*types.MsgCreateDIDResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - didMsg := msg.GetDidDocString() - did := msg.GetDidDocString().GetId() - // Checks if the DID has a valid format - if !utils.IsValidDid(did) { - return nil, types.ErrBadRequestIsNotDid.Wrap(did) - } - - // Checks if the DidDoc is a valid format - didDocCheck := utils.IsValidDidDoc(msg.DidDocString) - if didDocCheck != "" { - return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, didDocCheck) - } - - // Signature check - if err := k.VerifySignature(&ctx, didMsg, didMsg.GetSigners(), msg.GetSignatures()); err != nil { - return nil, err - } - - // Checks if the DID is already present in the store - if k.HasDid(ctx, did) { - return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID already exists %s", did)) - } - - if k.ValidateDidControllers(&ctx, did, didMsg.GetController(), didMsg.GetVerificationMethod()) != nil { - return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, "DID controller is not valid") - } - - var didSpec = types.Did{ - Context: didMsg.GetContext(), - Id: didMsg.GetId(), - Controller: didMsg.GetController(), - AlsoKnownAs: didMsg.GetAlsoKnownAs(), - VerificationMethod: didMsg.GetVerificationMethod(), - Authentication: didMsg.GetAuthentication(), - AssertionMethod: didMsg.GetAssertionMethod(), - KeyAgreement: didMsg.GetKeyAgreement(), - CapabilityInvocation: didMsg.GetCapabilityInvocation(), - Created: didMsg.GetCreated(), - Updated: didMsg.GetUpdated(), - } - // Add a DID to the store and get back the ID - id := k.AppendDID(ctx, didSpec) - // Return the Id of the DID - return &types.MsgCreateDIDResponse{Id: id}, nil -} diff --git a/x/ssi/keeper/msg_server_update_did.go b/x/ssi/keeper/msg_server_did.go similarity index 53% rename from x/ssi/keeper/msg_server_update_did.go rename to x/ssi/keeper/msg_server_did.go index 6a61b27..0143ed9 100644 --- a/x/ssi/keeper/msg_server_update_did.go +++ b/x/ssi/keeper/msg_server_did.go @@ -7,8 +7,60 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/hypersign-protocol/hid-node/x/ssi/types" + utils "github.com/hypersign-protocol/hid-node/x/ssi/utils" ) +func (k msgServer) CreateDID(goCtx context.Context, msg *types.MsgCreateDID) (*types.MsgCreateDIDResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + didMsg := msg.GetDidDocString() + did := didMsg.GetId() + // Checks if the DID has a valid format + if !utils.IsValidDid(did) { + return nil, types.ErrBadRequestIsNotDid.Wrap(did) + } + + // Checks if the DidDoc is a valid format + didDocCheck := utils.IsValidDidDoc(msg.DidDocString) + if didDocCheck != "" { + return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, didDocCheck) + } + + // Signature check + if err := k.VerifySignature(&ctx, didMsg, didMsg.GetSigners(), msg.GetSignatures()); err != nil { + return nil, err + } + + // Checks if the DID is already present in the store + if k.HasDid(ctx, did) { + return nil, sdkerrors.Wrap(types.ErrDidDocExists, fmt.Sprintf("DID already exists %s", did)) + } + + if k.ValidateDidControllers(&ctx, did, didMsg.GetController(), didMsg.GetVerificationMethod()) != nil { + return nil, sdkerrors.Wrap(types.ErrInvalidDidDoc, "DID controller is not valid") + } + + var didSpec = types.Did{ + Context: didMsg.GetContext(), + Id: didMsg.GetId(), + Controller: didMsg.GetController(), + AlsoKnownAs: didMsg.GetAlsoKnownAs(), + VerificationMethod: didMsg.GetVerificationMethod(), + Authentication: didMsg.GetAuthentication(), + AssertionMethod: didMsg.GetAssertionMethod(), + KeyAgreement: didMsg.GetKeyAgreement(), + CapabilityInvocation: didMsg.GetCapabilityInvocation(), + CapabilityDelegation: didMsg.GetCapabilityDelegation(), + Service: didMsg.GetService(), + Created: didMsg.GetCreated(), + Updated: didMsg.GetUpdated(), + } + // Add a DID to the store and get back the ID + id := k.AppendDID(ctx, didSpec) + // Return the Id of the DID + return &types.MsgCreateDIDResponse{Id: id}, nil +} + func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*types.MsgUpdateDIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) @@ -55,6 +107,7 @@ func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*t AssertionMethod: didMsg.GetAssertionMethod(), KeyAgreement: didMsg.GetKeyAgreement(), CapabilityInvocation: didMsg.GetCapabilityInvocation(), + Service: didMsg.GetService(), Created: didMsg.GetCreated(), Updated: didMsg.GetUpdated(), } @@ -66,4 +119,4 @@ func (k msgServer) UpdateDID(goCtx context.Context, msg *types.MsgUpdateDID) (*t } return &types.MsgUpdateDIDResponse{UpdateId: didSpec.Id}, nil -} +} \ No newline at end of file diff --git a/x/ssi/keeper/msg_server_create_schema.go b/x/ssi/keeper/msg_server_schema.go similarity index 100% rename from x/ssi/keeper/msg_server_create_schema.go rename to x/ssi/keeper/msg_server_schema.go diff --git a/x/ssi/keeper/schema.go b/x/ssi/keeper/schema.go index 56320e0..c23a246 100644 --- a/x/ssi/keeper/schema.go +++ b/x/ssi/keeper/schema.go @@ -10,13 +10,13 @@ import ( ) func (k Keeper) GetSchemaCount(ctx sdk.Context) uint64 { - // Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-") + // Get the store using storeKey and SchemaCountKey (which is "Schema-count-") store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.SchemaCountKey)) - // Convert the PostCountKey to bytes + // Convert the SchemaCountKey to bytes byteKey := []byte(types.SchemaCountKey) // Get the value of the count bz := store.Get(byteKey) - // Return zero if the count value is not found (for example, it's the first post) + // Return zero if the count value is not found if bz == nil { return 0 } @@ -24,64 +24,36 @@ func (k Keeper) GetSchemaCount(ctx sdk.Context) uint64 { return binary.BigEndian.Uint64(bz) } -// Check whether the given DID is already present in the store +// Check whether the given Schema already exists in the store func (k Keeper) HasSchema(ctx sdk.Context, id string) bool { extractedID := utils.ExtractIDFromSchema(id) store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.SchemaKey)) return store.Has(utils.UnsafeStrToBytes(extractedID)) } -// Retrieves the DID from the store -// func (k Keeper) GetDid(ctx *sdk.Context, id string) (*types.DidDocStructCreateDID, error) { -// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) - -// if !k.HasDid(*ctx, id) { -// return nil, sdkerrors.ErrNotFound -// } - -// // TODO: Currently, we can interchange DidDocStructCreateDID with DidDocStructUpdateDID -// // as they are similar. They need to have a similar Interface -// var value types.DidDocStructCreateDID -// var bytes = store.Get([]byte(id)) -// if err := k.cdc.Unmarshal(bytes, &value); err != nil { -// return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidType, err.Error()) -// } - -// return &value, nil -// } - func (k Keeper) SetSchemaCount(ctx sdk.Context, count uint64) { - // Get the store using storeKey (which is "blog") and PostCountKey (which is "Post-count-") + // Get the store using storeKey and SchemaCountKey (which is "Schema-count-") store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.SchemaCountKey)) - // Convert the PostCountKey to bytes + // Convert the SchemaCountKey to bytes byteKey := []byte(types.SchemaCountKey) // Convert count from uint64 to string and get bytes bz := make([]byte, 8) binary.BigEndian.PutUint64(bz, count) - // Set the value of Post-count- to count + // Set the value of Schema-count- to count store.Set(byteKey, bz) } -// SetDid set a specific did in the store -// func (k Keeper) SetDid(ctx sdk.Context, did types.Did) error { -// store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.DidKey)) -// b := k.cdc.MustMarshal(&did) -// store.Set([]byte(did.Id), b) -// return nil -// } - func (k Keeper) AppendSchema(ctx sdk.Context, schema types.Schema) uint64 { - // Get the current number of posts in the store + // Get the current number of Schemas in the store count := k.GetSchemaCount(ctx) // Get the store store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.SchemaKey)) - // Convert the post ID into bytes - // Marshal the post into bytes + // Marshal the Schema into bytes schemaBytes := k.cdc.MustMarshal(&schema) // Strip the id part from schema.ID schemaID := utils.ExtractIDFromSchema(schema.Id) store.Set(utils.UnsafeStrToBytes(schemaID), schemaBytes) - // Update the post count + // Update the Schema count k.SetSchemaCount(ctx, count+1) return count } diff --git a/x/ssi/keeper/verify.go b/x/ssi/keeper/verify.go index c648d28..8eaa808 100644 --- a/x/ssi/keeper/verify.go +++ b/x/ssi/keeper/verify.go @@ -45,7 +45,7 @@ func VerifyIdentitySignature(signer types.Signer, signatures []*types.SignInfo, return result, nil } -func (k msgServer) VerifySignatureOnDidUpdate(ctx *sdk.Context, oldDIDDoc *types.DidDocStructCreateDID, newDIDDoc *types.DidDocStructUpdateDID, signatures []*types.SignInfo) error { +func (k msgServer) VerifySignatureOnDidUpdate(ctx *sdk.Context, oldDIDDoc *types.Did, newDIDDoc *types.Did, signatures []*types.SignInfo) error { var signers []types.Signer oldController := oldDIDDoc.Controller @@ -84,8 +84,7 @@ func (k msgServer) VerifySignatureOnDidUpdate(ctx *sdk.Context, oldDIDDoc *types return nil } -// TODO: Implement this when `controller` field is added -func AppendSignerIfNeed(signers []types.Signer, controller string, msg *types.DidDocStructUpdateDID) []types.Signer { +func AppendSignerIfNeed(signers []types.Signer, controller string, msg *types.Did) []types.Signer { for _, signer := range signers { if signer.Signer == controller { return signers @@ -108,7 +107,7 @@ func AppendSignerIfNeed(signers []types.Signer, controller string, msg *types.Di // of the DID controllers. If so, then the signature is valid, which is an approach as opposed to the earlier // implementation where all the signatures of all DIDs present in DID controller were expected. This needs to be verified. // Link to DID Controller Spec: https://www.w3.org/TR/did-core/#did-controller -func (k *Keeper) VerifySignature(ctx *sdk.Context, msg types.IdentityMsg, signers []types.Signer, signatures []*types.SignInfo) error { +func (k *Keeper) VerifySignature(ctx *sdk.Context, msg *types.Did, signers []types.Signer, signatures []*types.SignInfo) error { var validArr []types.ValidDid if len(signers) == 0 { @@ -171,7 +170,7 @@ func (k *Keeper) VerifySignatureOnCreateSchema(ctx *sdk.Context, msg *types.Sche signingInput := msg.GetSignBytes() for _, signer := range signers { - // TODO: Understand stateValue part of it on Cheqd + // TODO: Uncomment when Schema is being implemented properly // if signer.PublicKeyStruct == nil { // state, err := k.GetDid(ctx, signer.Signer) // if err != nil { diff --git a/x/ssi/types/did.go b/x/ssi/types/did.go index 0328048..2e6ec5f 100644 --- a/x/ssi/types/did.go +++ b/x/ssi/types/did.go @@ -13,3 +13,29 @@ func (v VerificationMethod) GetPublicKey() ([]byte, error) { return nil, ErrInvalidPublicKey.Wrapf("verification method '%s' public key not found", v.Id) } + +// TODO: Implement the following without the field Creator +// func accAddrByKeyRef(keyring keyring.Keyring, keyRef string) (sdk.AccAddress, error) { +// // Firstly check if the keyref is a key name of a key registered in a keyring +// info, err := keyring.Key(keyRef) + +// if err == nil { +// return info.GetAddress(), nil +// } + +// if !sdkerr.IsOf(err, sdkerr.ErrIO, sdkerr.ErrKeyNotFound) { +// return nil, err +// } + +// // Fallback: convert keyref to address +// return sdk.AccAddressFromBech32(keyRef) +// } + +// func (msg *MsgCreateDID) GetSigners() []sdk.AccAddress { +// ctx := client +// signerAccAddr, err := accAddrByKeyRef(ctx.Keyring, ctx.From) +// if err != nil { +// panic(err) +// } +// return []sdk.AccAddress{signerAccAddr} +// } \ No newline at end of file diff --git a/x/ssi/types/did.pb.go b/x/ssi/types/did.pb.go index b792bab..7fde4ef 100644 --- a/x/ssi/types/did.pb.go +++ b/x/ssi/types/did.pb.go @@ -32,8 +32,10 @@ type Did struct { AssertionMethod []string `protobuf:"bytes,7,rep,name=assertionMethod,proto3" json:"assertionMethod,omitempty"` KeyAgreement []string `protobuf:"bytes,8,rep,name=keyAgreement,proto3" json:"keyAgreement,omitempty"` CapabilityInvocation []string `protobuf:"bytes,9,rep,name=capabilityInvocation,proto3" json:"capabilityInvocation,omitempty"` - Created string `protobuf:"bytes,10,opt,name=created,proto3" json:"created,omitempty"` - Updated string `protobuf:"bytes,11,opt,name=updated,proto3" json:"updated,omitempty"` + CapabilityDelegation []string `protobuf:"bytes,10,rep,name=capabilityDelegation,proto3" json:"capabilityDelegation,omitempty"` + Service []*Service `protobuf:"bytes,11,rep,name=service,proto3" json:"service,omitempty"` + Created string `protobuf:"bytes,12,opt,name=created,proto3" json:"created,omitempty"` + Updated string `protobuf:"bytes,13,opt,name=updated,proto3" json:"updated,omitempty"` } func (m *Did) Reset() { *m = Did{} } @@ -132,6 +134,20 @@ func (m *Did) GetCapabilityInvocation() []string { return nil } +func (m *Did) GetCapabilityDelegation() []string { + if m != nil { + return m.CapabilityDelegation + } + return nil +} + +func (m *Did) GetService() []*Service { + if m != nil { + return m.Service + } + return nil +} + func (m *Did) GetCreated() string { if m != nil { return m.Created @@ -146,37 +162,229 @@ func (m *Did) GetUpdated() string { return "" } +type VerificationMethod struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Controller string `protobuf:"bytes,3,opt,name=controller,proto3" json:"controller,omitempty"` + PublicKeyMultibase string `protobuf:"bytes,4,opt,name=publicKeyMultibase,proto3" json:"publicKeyMultibase,omitempty"` +} + +func (m *VerificationMethod) Reset() { *m = VerificationMethod{} } +func (m *VerificationMethod) String() string { return proto.CompactTextString(m) } +func (*VerificationMethod) ProtoMessage() {} +func (*VerificationMethod) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{1} +} +func (m *VerificationMethod) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VerificationMethod) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VerificationMethod.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VerificationMethod) XXX_Merge(src proto.Message) { + xxx_messageInfo_VerificationMethod.Merge(m, src) +} +func (m *VerificationMethod) XXX_Size() int { + return m.Size() +} +func (m *VerificationMethod) XXX_DiscardUnknown() { + xxx_messageInfo_VerificationMethod.DiscardUnknown(m) +} + +var xxx_messageInfo_VerificationMethod proto.InternalMessageInfo + +func (m *VerificationMethod) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *VerificationMethod) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *VerificationMethod) GetController() string { + if m != nil { + return m.Controller + } + return "" +} + +func (m *VerificationMethod) GetPublicKeyMultibase() string { + if m != nil { + return m.PublicKeyMultibase + } + return "" +} + +type Service struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + ServiceEndpoint string `protobuf:"bytes,3,opt,name=serviceEndpoint,proto3" json:"serviceEndpoint,omitempty"` +} + +func (m *Service) Reset() { *m = Service{} } +func (m *Service) String() string { return proto.CompactTextString(m) } +func (*Service) ProtoMessage() {} +func (*Service) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{2} +} +func (m *Service) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Service) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Service.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Service) XXX_Merge(src proto.Message) { + xxx_messageInfo_Service.Merge(m, src) +} +func (m *Service) XXX_Size() int { + return m.Size() +} +func (m *Service) XXX_DiscardUnknown() { + xxx_messageInfo_Service.DiscardUnknown(m) +} + +var xxx_messageInfo_Service proto.InternalMessageInfo + +func (m *Service) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Service) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Service) GetServiceEndpoint() string { + if m != nil { + return m.ServiceEndpoint + } + return "" +} + +type SignInfo struct { + VerificationMethodId string `protobuf:"bytes,1,opt,name=verification_method_id,json=verificationMethodId,proto3" json:"verification_method_id,omitempty"` + Signature string `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *SignInfo) Reset() { *m = SignInfo{} } +func (m *SignInfo) String() string { return proto.CompactTextString(m) } +func (*SignInfo) ProtoMessage() {} +func (*SignInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_cddfa22cf6c6aba3, []int{3} +} +func (m *SignInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SignInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SignInfo.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SignInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignInfo.Merge(m, src) +} +func (m *SignInfo) XXX_Size() int { + return m.Size() +} +func (m *SignInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SignInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SignInfo proto.InternalMessageInfo + +func (m *SignInfo) GetVerificationMethodId() string { + if m != nil { + return m.VerificationMethodId + } + return "" +} + +func (m *SignInfo) GetSignature() string { + if m != nil { + return m.Signature + } + return "" +} + func init() { proto.RegisterType((*Did)(nil), "hypersignprotocol.hidnode.ssi.Did") + proto.RegisterType((*VerificationMethod)(nil), "hypersignprotocol.hidnode.ssi.VerificationMethod") + proto.RegisterType((*Service)(nil), "hypersignprotocol.hidnode.ssi.Service") + proto.RegisterType((*SignInfo)(nil), "hypersignprotocol.hidnode.ssi.SignInfo") } func init() { proto.RegisterFile("ssi/v1/did.proto", fileDescriptor_cddfa22cf6c6aba3) } var fileDescriptor_cddfa22cf6c6aba3 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xc1, 0x6e, 0xda, 0x30, - 0x18, 0xc7, 0x09, 0xd9, 0x60, 0x98, 0x09, 0x26, 0x6b, 0x07, 0x6b, 0xd2, 0xa2, 0x88, 0xc3, 0x94, - 0x0b, 0x89, 0x60, 0x4f, 0xc0, 0xb4, 0xcb, 0xb4, 0xf6, 0xc2, 0xa1, 0x87, 0xde, 0x4c, 0xfc, 0x95, - 0x7c, 0x6a, 0xb0, 0x23, 0xdb, 0x50, 0xf2, 0x16, 0x7d, 0x96, 0x3e, 0x45, 0x8f, 0x1c, 0x7b, 0xac, - 0xe0, 0x45, 0xaa, 0x98, 0x50, 0x51, 0x8a, 0x7a, 0xfc, 0xff, 0xff, 0xbf, 0xcf, 0xfe, 0xfc, 0x97, - 0xc9, 0x37, 0x63, 0x30, 0x59, 0x8d, 0x12, 0x81, 0x22, 0x2e, 0xb4, 0xb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 0xcc, 0x15, 0xaf, 0x81, 0x5b, 0x10, 0x8c, 0xb8, 0x8e, 0x0f, 0xb2, 0x4a, 0x96, 0x85, 0x70, 0x49, - 0x77, 0x9f, 0xd4, 0xf2, 0xcf, 0xc5, 0xe3, 0x36, 0xf0, 0x36, 0xdb, 0xc0, 0x7b, 0xde, 0x06, 0xde, - 0xfd, 0x2e, 0x68, 0x6c, 0x76, 0x41, 0xe3, 0x69, 0x17, 0x34, 0xae, 0xc7, 0x73, 0xb4, 0xd9, 0x72, - 0x16, 0xa7, 0x6a, 0x91, 0xbc, 0x16, 0x39, 0x3c, 0x34, 0x99, 0x64, 0x28, 0x86, 0x55, 0x95, 0xc9, - 0x3a, 0xa9, 0x3e, 0x82, 0x2d, 0x0b, 0x30, 0xb3, 0x96, 0x8b, 0x7f, 0xbf, 0x04, 0x00, 0x00, 0xff, - 0xff, 0x12, 0x99, 0xae, 0xaa, 0x4d, 0x02, 0x00, 0x00, + // 501 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xc1, 0x6e, 0xda, 0x40, + 0x10, 0xc5, 0x40, 0x43, 0x18, 0xd2, 0xa4, 0x5a, 0x45, 0xd5, 0x1e, 0x5a, 0x0b, 0x71, 0x88, 0xb8, + 0xc4, 0x56, 0x68, 0x3f, 0xa0, 0xa9, 0xd2, 0x03, 0x4a, 0x73, 0x21, 0x52, 0x2b, 0xf5, 0xd0, 0xc8, + 0x78, 0x27, 0x78, 0x54, 0xb3, 0x6b, 0xed, 0xae, 0x69, 0xf8, 0x83, 0x1e, 0xfb, 0x19, 0xfd, 0x94, + 0x1e, 0x73, 0xec, 0xb1, 0x82, 0x1f, 0xa9, 0xbc, 0x18, 0x42, 0x00, 0xb5, 0xbd, 0x31, 0xef, 0xbd, + 0x61, 0x67, 0xe6, 0x3d, 0xc3, 0x33, 0x63, 0x28, 0x9c, 0x9c, 0x85, 0x82,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x11, 0xd9, 0x24, 0x1f, 0x06, 0xb1, 0x1a, 0x87, + 0x2b, 0x33, 0x4f, 0x97, 0x6e, 0x86, 0x09, 0x89, 0xd3, 0xc2, 0xce, 0xf0, 0x2e, 0x2c, 0x3e, 0xf1, + 0x62, 0x2d, 0x33, 0xdc, 0x73, 0xf4, 0xab, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x83, 0xf3, + 0xd4, 0xf6, 0x03, 0x00, 0x00, } func (m *Did) Marshal() (dAtA []byte, err error) { @@ -204,14 +412,37 @@ func (m *Did) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Updated) i = encodeVarintDid(dAtA, i, uint64(len(m.Updated))) i-- - dAtA[i] = 0x5a + dAtA[i] = 0x6a } if len(m.Created) > 0 { i -= len(m.Created) copy(dAtA[i:], m.Created) i = encodeVarintDid(dAtA, i, uint64(len(m.Created))) i-- - dAtA[i] = 0x52 + dAtA[i] = 0x62 + } + if len(m.Service) > 0 { + for iNdEx := len(m.Service) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Service[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDid(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } + if len(m.CapabilityDelegation) > 0 { + for iNdEx := len(m.CapabilityDelegation) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.CapabilityDelegation[iNdEx]) + copy(dAtA[i:], m.CapabilityDelegation[iNdEx]) + i = encodeVarintDid(dAtA, i, uint64(len(m.CapabilityDelegation[iNdEx]))) + i-- + dAtA[i] = 0x52 + } } if len(m.CapabilityInvocation) > 0 { for iNdEx := len(m.CapabilityInvocation) - 1; iNdEx >= 0; iNdEx-- { @@ -300,6 +531,138 @@ func (m *Did) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *VerificationMethod) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VerificationMethod) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VerificationMethod) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PublicKeyMultibase) > 0 { + i -= len(m.PublicKeyMultibase) + copy(dAtA[i:], m.PublicKeyMultibase) + i = encodeVarintDid(dAtA, i, uint64(len(m.PublicKeyMultibase))) + i-- + dAtA[i] = 0x22 + } + if len(m.Controller) > 0 { + i -= len(m.Controller) + copy(dAtA[i:], m.Controller) + i = encodeVarintDid(dAtA, i, uint64(len(m.Controller))) + i-- + dAtA[i] = 0x1a + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintDid(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintDid(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Service) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Service) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Service) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ServiceEndpoint) > 0 { + i -= len(m.ServiceEndpoint) + copy(dAtA[i:], m.ServiceEndpoint) + i = encodeVarintDid(dAtA, i, uint64(len(m.ServiceEndpoint))) + i-- + dAtA[i] = 0x1a + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintDid(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintDid(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SignInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SignInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SignInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintDid(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.VerificationMethodId) > 0 { + i -= len(m.VerificationMethodId) + copy(dAtA[i:], m.VerificationMethodId) + i = encodeVarintDid(dAtA, i, uint64(len(m.VerificationMethodId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintDid(dAtA []byte, offset int, v uint64) int { offset -= sovDid(v) base := offset @@ -369,6 +732,18 @@ func (m *Did) Size() (n int) { n += 1 + l + sovDid(uint64(l)) } } + if len(m.CapabilityDelegation) > 0 { + for _, s := range m.CapabilityDelegation { + l = len(s) + n += 1 + l + sovDid(uint64(l)) + } + } + if len(m.Service) > 0 { + for _, e := range m.Service { + l = e.Size() + n += 1 + l + sovDid(uint64(l)) + } + } l = len(m.Created) if l > 0 { n += 1 + l + sovDid(uint64(l)) @@ -380,11 +755,74 @@ func (m *Did) Size() (n int) { return n } -func sovDid(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozDid(x uint64) (n int) { - return sovDid(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func (m *VerificationMethod) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.Controller) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.PublicKeyMultibase) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + return n +} + +func (m *Service) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.Type) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.ServiceEndpoint) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + return n +} + +func (m *SignInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.VerificationMethodId) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovDid(uint64(l)) + } + return n +} + +func sovDid(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDid(x uint64) (n int) { + return sovDid(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *Did) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -396,28 +834,384 @@ func (m *Did) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowDid } - if iNdEx >= l { + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Did: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Did: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Controller = append(m.Controller, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AlsoKnownAs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AlsoKnownAs = append(m.AlsoKnownAs, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VerificationMethod = append(m.VerificationMethod, &VerificationMethod{}) + if err := m.VerificationMethod[len(m.VerificationMethod)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssertionMethod", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssertionMethod = append(m.AssertionMethod, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyAgreement", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyAgreement = append(m.KeyAgreement, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CapabilityInvocation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CapabilityInvocation = append(m.CapabilityInvocation, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CapabilityDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.CapabilityDelegation = append(m.CapabilityDelegation, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Did: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Did: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDid + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDid + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Service = append(m.Service, &Service{}) + if err := m.Service[len(m.Service)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -445,11 +1239,11 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) + m.Created = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 13: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Updated", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -477,11 +1271,61 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Id = string(dAtA[iNdEx:postIndex]) + m.Updated = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VerificationMethod) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VerificationMethod: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VerificationMethod: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -509,11 +1353,11 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Controller = append(m.Controller, string(dAtA[iNdEx:postIndex])) + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AlsoKnownAs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -541,13 +1385,13 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AlsoKnownAs = append(m.AlsoKnownAs, string(dAtA[iNdEx:postIndex])) + m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowDid @@ -557,29 +1401,27 @@ func (m *Did) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthDid } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthDid } if postIndex > l { return io.ErrUnexpectedEOF } - m.VerificationMethod = append(m.VerificationMethod, &VerificationMethod{}) - if err := m.VerificationMethod[len(m.VerificationMethod)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Controller = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PublicKeyMultibase", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -607,11 +1449,61 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex])) + m.PublicKeyMultibase = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Service) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Service: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Service: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssertionMethod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -639,11 +1531,11 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssertionMethod = append(m.AssertionMethod, string(dAtA[iNdEx:postIndex])) + m.Id = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyAgreement", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -671,11 +1563,11 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.KeyAgreement = append(m.KeyAgreement, string(dAtA[iNdEx:postIndex])) + m.Type = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CapabilityInvocation", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ServiceEndpoint", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -703,11 +1595,61 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.CapabilityInvocation = append(m.CapabilityInvocation, string(dAtA[iNdEx:postIndex])) + m.ServiceEndpoint = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 10: + default: + iNdEx = preIndex + skippy, err := skipDid(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDid + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SignInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDid + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SignInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SignInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethodId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -735,11 +1677,11 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Created = string(dAtA[iNdEx:postIndex]) + m.VerificationMethodId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 11: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Updated", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -767,7 +1709,7 @@ func (m *Did) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Updated = string(dAtA[iNdEx:postIndex]) + m.Signature = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/ssi/types/errors.go b/x/ssi/types/errors.go index 819fab6..71ca6da 100644 --- a/x/ssi/types/errors.go +++ b/x/ssi/types/errors.go @@ -18,5 +18,6 @@ var ( ErrDidDocNotFound = sdkerrors.Register(ModuleName, 108, "DID Doc not found") ErrSchemaExists = sdkerrors.Register(ModuleName, 109, "Schema already exists") ErrInvalidSchemaID = sdkerrors.Register(ModuleName, 110, "Invalid schema Id") - ErrBadRequestInvalidVerMethod = sdkerrors.Register(ModuleName, 111, "invalid verification method") + ErrBadRequestInvalidVerMethod = sdkerrors.Register(ModuleName, 111, "Invalid verification method") + ErrInvalidService = sdkerrors.Register(ModuleName, 112, "Invalid Service") ) diff --git a/x/ssi/types/message_create_did.go b/x/ssi/types/message_create_did.go deleted file mode 100644 index 839cbf7..0000000 --- a/x/ssi/types/message_create_did.go +++ /dev/null @@ -1,107 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const TypeMsgCreateDID = "create_did" - -var _ sdk.Msg = &MsgCreateDID{} - -func NewMsgCreateDID(did string, didDocString *DidDocStructCreateDID) *MsgCreateDID { - return &MsgCreateDID{ - DidDocString: didDocString, - } -} - -func (msg *MsgCreateDID) Route() string { - return RouterKey -} - -func (msg *MsgCreateDID) Type() string { - return TypeMsgCreateDID -} - -// TODO: Implement the following without the field Creator -// func accAddrByKeyRef(keyring keyring.Keyring, keyRef string) (sdk.AccAddress, error) { -// // Firstly check if the keyref is a key name of a key registered in a keyring -// info, err := keyring.Key(keyRef) - -// if err == nil { -// return info.GetAddress(), nil -// } - -// if !sdkerr.IsOf(err, sdkerr.ErrIO, sdkerr.ErrKeyNotFound) { -// return nil, err -// } - -// // Fallback: convert keyref to address -// return sdk.AccAddressFromBech32(keyRef) -// } - -// func (msg *MsgCreateDID) GetSigners() []sdk.AccAddress { -// ctx := client -// signerAccAddr, err := accAddrByKeyRef(ctx.Keyring, ctx.From) -// if err != nil { -// panic(err) -// } -// return []sdk.AccAddress{signerAccAddr} -// } - -func (msg *MsgCreateDID) GetSigners() []sdk.AccAddress { - creator, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - panic(err) - } - return []sdk.AccAddress{creator} -} - -func (msg *DidDocStructCreateDID) GetSigners() []Signer { - if len(msg.Controller) > 0 { - result := make([]Signer, len(msg.Controller)) - - for i, controller := range msg.Controller { - if controller == msg.Id { - result[i] = Signer{ - Signer: controller, - Authentication: msg.Authentication, - VerificationMethod: msg.VerificationMethod, - } - } else { - result[i] = Signer{ - Signer: controller, - } - } - } - - return result - } - - if len(msg.Authentication) > 0 { - return []Signer{ - { - Signer: msg.Id, - Authentication: msg.Authentication, - VerificationMethod: msg.VerificationMethod, - }, - } - } - - return []Signer{} -} - -func (msg *MsgCreateDID) GetSignBytes() []byte { - return ModuleCdc.MustMarshal(msg) -} - -func (msg *DidDocStructCreateDID) GetSignBytes() []byte { - return ModuleCdc.MustMarshal(msg) -} - -func (msg *MsgCreateDID) ValidateBasic() error { - did := msg.GetDidDocString().GetId() - if did == "" { - return ErrBadRequestIsRequired.Wrap("DID") - } - return nil -} diff --git a/x/ssi/types/message_update_did.go b/x/ssi/types/message_did.go similarity index 57% rename from x/ssi/types/message_update_did.go rename to x/ssi/types/message_did.go index e1994f6..1f5a91b 100644 --- a/x/ssi/types/message_update_did.go +++ b/x/ssi/types/message_did.go @@ -5,11 +5,93 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// Did Type Methods + +func (msg *Did) GetSigners() []Signer { + if len(msg.Controller) > 0 { + result := make([]Signer, len(msg.Controller)) + + for i, controller := range msg.Controller { + if controller == msg.Id { + result[i] = Signer{ + Signer: controller, + Authentication: msg.Authentication, + VerificationMethod: msg.VerificationMethod, + } + } else { + result[i] = Signer{ + Signer: controller, + } + } + } + + return result + } + + if len(msg.Authentication) > 0 { + return []Signer{ + { + Signer: msg.Id, + Authentication: msg.Authentication, + VerificationMethod: msg.VerificationMethod, + }, + } + } + + return []Signer{} +} + +func (msg *Did) GetSignBytes() []byte { + return ModuleCdc.MustMarshal(msg) +} + +// MsgCreateDID Type Methods + +const TypeMsgCreateDID = "create_did" + +var _ sdk.Msg = &MsgCreateDID{} + +func NewMsgCreateDID(did string, didDocString *Did) *MsgCreateDID { + return &MsgCreateDID{ + DidDocString: didDocString, + } +} + +func (msg *MsgCreateDID) Route() string { + return RouterKey +} + +func (msg *MsgCreateDID) Type() string { + return TypeMsgCreateDID +} + +func (msg *MsgCreateDID) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreateDID) GetSignBytes() []byte { + return ModuleCdc.MustMarshal(msg) +} + +func (msg *MsgCreateDID) ValidateBasic() error { + did := msg.GetDidDocString().GetId() + if did == "" { + return ErrBadRequestIsRequired.Wrap("DID") + } + return nil +} + +// MsgUpdateDID Type Methods + const TypeMsgUpdateDID = "update_did" var _ sdk.Msg = &MsgUpdateDID{} -func NewMsgUpdateDID(creator string, didDocString *DidDocStructUpdateDID, signatures []*SignInfo) *MsgUpdateDID { +func NewMsgUpdateDID(creator string, didDocString *Did, signatures []*SignInfo) *MsgUpdateDID { return &MsgUpdateDID{ Creator: creator, DidDocString: didDocString, @@ -38,11 +120,6 @@ func (msg *MsgUpdateDID) GetSignBytes() []byte { return sdk.MustSortJSON(bz) } -func (msg *DidDocStructUpdateDID) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(msg) - return sdk.MustSortJSON(bz) -} - func (msg *MsgUpdateDID) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { @@ -50,37 +127,3 @@ func (msg *MsgUpdateDID) ValidateBasic() error { } return nil } - -func (msg *DidDocStructUpdateDID) GetSigners() []Signer { - if len(msg.Controller) > 0 { - result := make([]Signer, len(msg.Controller)) - - for i, controller := range msg.Controller { - if controller == msg.Id { - result[i] = Signer{ - Signer: controller, - Authentication: msg.Authentication, - VerificationMethod: msg.VerificationMethod, - } - } else { - result[i] = Signer{ - Signer: controller, - } - } - } - - return result - } - - if len(msg.Authentication) > 0 { - return []Signer{ - { - Signer: msg.Id, - Authentication: msg.Authentication, - VerificationMethod: msg.VerificationMethod, - }, - } - } - - return []Signer{} -} diff --git a/x/ssi/types/message_create_schema.go b/x/ssi/types/message_schema.go similarity index 100% rename from x/ssi/types/message_create_schema.go rename to x/ssi/types/message_schema.go diff --git a/x/ssi/types/query.pb.go b/x/ssi/types/query.pb.go index 779992d..5545b97 100644 --- a/x/ssi/types/query.pb.go +++ b/x/ssi/types/query.pb.go @@ -422,7 +422,7 @@ func (m *QueryGetDidDocByIdRequest) GetDidDocId() string { } type QueryGetDidDocByIdResponse struct { - DidDoc *DidDocStructCreateDID `protobuf:"bytes,1,opt,name=didDoc,proto3" json:"didDoc,omitempty"` + DidDoc *Did `protobuf:"bytes,1,opt,name=didDoc,proto3" json:"didDoc,omitempty"` } func (m *QueryGetDidDocByIdResponse) Reset() { *m = QueryGetDidDocByIdResponse{} } @@ -458,7 +458,7 @@ func (m *QueryGetDidDocByIdResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetDidDocByIdResponse proto.InternalMessageInfo -func (m *QueryGetDidDocByIdResponse) GetDidDoc() *DidDocStructCreateDID { +func (m *QueryGetDidDocByIdResponse) GetDidDoc() *Did { if m != nil { return m.DidDoc } @@ -563,53 +563,53 @@ func init() { func init() { proto.RegisterFile("ssi/v1/query.proto", fileDescriptor_0f525f26163d85f3) } var fileDescriptor_0f525f26163d85f3 = []byte{ - // 733 bytes of a gzipped FileDescriptorProto + // 721 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x4f, 0x13, 0x41, 0x14, 0xc7, 0xbb, 0x08, 0x15, 0x1e, 0x31, 0x9a, 0xa1, 0x2a, 0x6c, 0xb4, 0x92, 0x4d, 0x10, 0x7f, - 0xb1, 0x4b, 0x0b, 0x82, 0x1e, 0x34, 0x4a, 0x2b, 0xa4, 0x09, 0x07, 0x2c, 0x07, 0x13, 0x12, 0x0f, - 0xdb, 0xdd, 0xc9, 0x76, 0x0d, 0xdd, 0x59, 0x3a, 0x53, 0x42, 0x43, 0xb8, 0xf8, 0x17, 0x98, 0x78, - 0xf7, 0xe8, 0xc1, 0x9b, 0x89, 0xff, 0x81, 0x17, 0x0e, 0x1e, 0x48, 0x8c, 0x89, 0x27, 0x63, 0xc0, - 0x3f, 0xc4, 0x74, 0xe6, 0x95, 0xee, 0xd2, 0x4a, 0xb7, 0xde, 0x76, 0xdf, 0xcc, 0xf7, 0xbd, 0xcf, - 0xfb, 0x35, 0x40, 0x38, 0xf7, 0xad, 0xdd, 0x9c, 0xb5, 0xd3, 0xa0, 0xf5, 0xa6, 0x19, 0xd6, 0x99, - 0x60, 0xe4, 0x66, 0xb5, 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x56, 0x42, 0x26, 0x94, 0xa3, 0xc8, - 0x78, 0x8d, 0x99, 0x2a, 0x73, 0xbb, 0x00, 0x64, 0x15, 0xa0, 0x53, 0x77, 0xf4, 0x7c, 0xdb, 0x54, - 0x4d, 0x32, 0x5b, 0x4d, 0x32, 0xd5, 0x40, 0x60, 0x93, 0xcc, 0x0d, 0xdb, 0xa3, 0xa8, 0x2d, 0x47, - 0x94, 0xc6, 0x47, 0x0d, 0x32, 0x71, 0xff, 0x88, 0xfd, 0x02, 0x40, 0x11, 0xac, 0xfb, 0x5c, 0x4c, - 0x6a, 0xd3, 0x17, 0x92, 0xa3, 0x47, 0x84, 0x64, 0x2d, 0xc6, 0x39, 0x24, 0x39, 0x67, 0xfb, 0x72, - 0x2a, 0x86, 0x18, 0xe8, 0x14, 0x5c, 0x8f, 0x70, 0x16, 0x58, 0x23, 0x10, 0xed, 0x61, 0x98, 0x87, - 0xc9, 0xee, 0x23, 0x4c, 0x23, 0x03, 0x23, 0x4e, 0xcb, 0x20, 0x4b, 0x34, 0x5c, 0x56, 0x3f, 0xc6, - 0x32, 0x4c, 0xb5, 0xbb, 0x55, 0xf4, 0xdd, 0x22, 0x73, 0x56, 0x9a, 0x25, 0x37, 0xd2, 0x66, 0x57, - 0x1a, 0x3b, 0x6d, 0x6e, 0xff, 0x1b, 0x6f, 0x40, 0xef, 0x25, 0xc4, 0x60, 0xeb, 0x90, 0x56, 0x37, - 0xb1, 0x21, 0x8b, 0x7d, 0xea, 0xa5, 0x5c, 0x6c, 0x8a, 0x7a, 0xc3, 0x11, 0x85, 0x3a, 0xb5, 0x05, - 0x2d, 0x96, 0x8a, 0x65, 0xf4, 0x71, 0x9a, 0xb1, 0xba, 0xd5, 0x33, 0xe3, 0xd8, 0xd1, 0x79, 0x19, - 0xe7, 0x7f, 0x8c, 0xc2, 0x88, 0x94, 0x90, 0x0f, 0x1a, 0xa4, 0xd5, 0xdc, 0x93, 0x5c, 0x1f, 0xbe, - 0xee, 0xc5, 0x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 0x9b, 0x8e, 0xc7, 0x50, 0x5b, 0x88, 0x28, + 0xad, 0x8f, 0x06, 0x64, 0xe2, 0xfe, 0x11, 0xfb, 0x39, 0x80, 0x26, 0xd8, 0xe0, 0x32, 0x1c, 0x37, + 0x26, 0xcf, 0x25, 0x47, 0x8f, 0x08, 0xc9, 0x5a, 0x8c, 0x73, 0x40, 0x71, 0x4e, 0xf7, 0xe4, 0xd4, + 0x0c, 0x31, 0xd0, 0x09, 0xb8, 0x1a, 0xe1, 0x5c, 0x16, 0x35, 0x3f, 0x6c, 0x0e, 0xc3, 0x2c, 0x8c, + 0x77, 0x1e, 0x61, 0x1a, 0x19, 0x18, 0x2a, 0x35, 0x0c, 0xaa, 0x44, 0x83, 0x05, 0xfd, 0x63, 0x2d, + 0xc2, 0x44, 0xb3, 0x5b, 0x2b, 0xdc, 0x5d, 0x11, 0xa5, 0xa5, 0xfa, 0xba, 0x1b, 0x69, 0xb3, 0xab, + 0x8c, 0xad, 0x36, 0x37, 0xff, 0xad, 0xd7, 0x60, 0x76, 0x13, 0x62, 0xb0, 0x47, 0x90, 0xd6, 0x37, + 0xb1, 0x21, 0x56, 0x8f, 0x7a, 0xad, 0x70, 0xb7, 0x80, 0x8a, 0xd3, 0xfc, 0xb4, 0xdb, 0xae, 0xf9, + 0xc5, 0x8e, 0xce, 0xca, 0x2f, 0xff, 0x63, 0x18, 0x86, 0x94, 0x84, 0x7c, 0x30, 0x20, 0xad, 0xa7, + 0x9c, 0xe4, 0x7a, 0xd0, 0x74, 0xae, 0x99, 0x99, 0xef, 0x47, 0xa2, 0x89, 0xac, 0x99, 0xb7, 0xdf, + 0xff, 0xbc, 0x1f, 0x98, 0x26, 0x53, 0xb4, 0x43, 0x4b, 0x51, 0x4b, 0x1b, 0x4b, 0xae, 0xb7, 0x8d, + 0x7c, 0x35, 0x60, 0xe4, 0x74, 0x69, 0xc8, 0x7c, 0x92, 0x80, 0xed, 0x8b, 0x69, 0xde, 0xef, 0x53, + 0x85, 0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0xfc, 0xed, 0x29, 0x8f, 0x61, 0x3d, 0x60, 0xb2, 0x98, + 0x56, 0xc7, 0x73, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x5d, 0x06, 0x1a, 0xc3, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2186,7 +2186,7 @@ func (m *QueryGetDidDocByIdResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.DidDoc == nil { - m.DidDoc = &DidDocStructCreateDID{} + m.DidDoc = &Did{} } if err := m.DidDoc.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/ssi/types/tx.pb.go b/x/ssi/types/tx.pb.go index eb95652..39b8272 100644 --- a/x/ssi/types/tx.pb.go +++ b/x/ssi/types/tx.pb.go @@ -28,9 +28,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgCreateDID struct { - DidDocString *DidDocStructCreateDID `protobuf:"bytes,1,opt,name=didDocString,proto3" json:"didDocString,omitempty"` - Signatures []*SignInfo `protobuf:"bytes,2,rep,name=signatures,proto3" json:"signatures,omitempty"` - Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` + DidDocString *Did `protobuf:"bytes,1,opt,name=didDocString,proto3" json:"didDocString,omitempty"` + Signatures []*SignInfo `protobuf:"bytes,2,rep,name=signatures,proto3" json:"signatures,omitempty"` + Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` } func (m *MsgCreateDID) Reset() { *m = MsgCreateDID{} } @@ -66,7 +66,7 @@ func (m *MsgCreateDID) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCreateDID proto.InternalMessageInfo -func (m *MsgCreateDID) GetDidDocString() *DidDocStructCreateDID { +func (m *MsgCreateDID) GetDidDocString() *Did { if m != nil { return m.DidDocString } @@ -87,322 +87,6 @@ func (m *MsgCreateDID) GetCreator() string { return "" } -type DidDocStructCreateDID struct { - Context []string `protobuf:"bytes,1,rep,name=context,proto3" json:"context,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - Controller []string `protobuf:"bytes,3,rep,name=controller,proto3" json:"controller,omitempty"` - AlsoKnownAs []string `protobuf:"bytes,4,rep,name=alsoKnownAs,proto3" json:"alsoKnownAs,omitempty"` - VerificationMethod []*VerificationMethod `protobuf:"bytes,5,rep,name=verificationMethod,proto3" json:"verificationMethod,omitempty"` - Authentication []string `protobuf:"bytes,6,rep,name=authentication,proto3" json:"authentication,omitempty"` - AssertionMethod []string `protobuf:"bytes,7,rep,name=assertionMethod,proto3" json:"assertionMethod,omitempty"` - KeyAgreement []string `protobuf:"bytes,8,rep,name=keyAgreement,proto3" json:"keyAgreement,omitempty"` - CapabilityInvocation []string `protobuf:"bytes,9,rep,name=capabilityInvocation,proto3" json:"capabilityInvocation,omitempty"` - Created string `protobuf:"bytes,10,opt,name=created,proto3" json:"created,omitempty"` - Updated string `protobuf:"bytes,11,opt,name=updated,proto3" json:"updated,omitempty"` -} - -func (m *DidDocStructCreateDID) Reset() { *m = DidDocStructCreateDID{} } -func (m *DidDocStructCreateDID) String() string { return proto.CompactTextString(m) } -func (*DidDocStructCreateDID) ProtoMessage() {} -func (*DidDocStructCreateDID) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{1} -} -func (m *DidDocStructCreateDID) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DidDocStructCreateDID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DidDocStructCreateDID.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DidDocStructCreateDID) XXX_Merge(src proto.Message) { - xxx_messageInfo_DidDocStructCreateDID.Merge(m, src) -} -func (m *DidDocStructCreateDID) XXX_Size() int { - return m.Size() -} -func (m *DidDocStructCreateDID) XXX_DiscardUnknown() { - xxx_messageInfo_DidDocStructCreateDID.DiscardUnknown(m) -} - -var xxx_messageInfo_DidDocStructCreateDID proto.InternalMessageInfo - -func (m *DidDocStructCreateDID) GetContext() []string { - if m != nil { - return m.Context - } - return nil -} - -func (m *DidDocStructCreateDID) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *DidDocStructCreateDID) GetController() []string { - if m != nil { - return m.Controller - } - return nil -} - -func (m *DidDocStructCreateDID) GetAlsoKnownAs() []string { - if m != nil { - return m.AlsoKnownAs - } - return nil -} - -func (m *DidDocStructCreateDID) GetVerificationMethod() []*VerificationMethod { - if m != nil { - return m.VerificationMethod - } - return nil -} - -func (m *DidDocStructCreateDID) GetAuthentication() []string { - if m != nil { - return m.Authentication - } - return nil -} - -func (m *DidDocStructCreateDID) GetAssertionMethod() []string { - if m != nil { - return m.AssertionMethod - } - return nil -} - -func (m *DidDocStructCreateDID) GetKeyAgreement() []string { - if m != nil { - return m.KeyAgreement - } - return nil -} - -func (m *DidDocStructCreateDID) GetCapabilityInvocation() []string { - if m != nil { - return m.CapabilityInvocation - } - return nil -} - -func (m *DidDocStructCreateDID) GetCreated() string { - if m != nil { - return m.Created - } - return "" -} - -func (m *DidDocStructCreateDID) GetUpdated() string { - if m != nil { - return m.Updated - } - return "" -} - -type DidDocStructUpdateDID struct { - Context []string `protobuf:"bytes,1,rep,name=context,proto3" json:"context,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - Controller []string `protobuf:"bytes,3,rep,name=controller,proto3" json:"controller,omitempty"` - AlsoKnownAs []string `protobuf:"bytes,4,rep,name=alsoKnownAs,proto3" json:"alsoKnownAs,omitempty"` - VerificationMethod []*VerificationMethod `protobuf:"bytes,5,rep,name=verificationMethod,proto3" json:"verificationMethod,omitempty"` - Authentication []string `protobuf:"bytes,6,rep,name=authentication,proto3" json:"authentication,omitempty"` - AssertionMethod []string `protobuf:"bytes,7,rep,name=assertionMethod,proto3" json:"assertionMethod,omitempty"` - KeyAgreement []string `protobuf:"bytes,8,rep,name=keyAgreement,proto3" json:"keyAgreement,omitempty"` - CapabilityInvocation []string `protobuf:"bytes,9,rep,name=capabilityInvocation,proto3" json:"capabilityInvocation,omitempty"` - Created string `protobuf:"bytes,10,opt,name=created,proto3" json:"created,omitempty"` - Updated string `protobuf:"bytes,11,opt,name=updated,proto3" json:"updated,omitempty"` -} - -func (m *DidDocStructUpdateDID) Reset() { *m = DidDocStructUpdateDID{} } -func (m *DidDocStructUpdateDID) String() string { return proto.CompactTextString(m) } -func (*DidDocStructUpdateDID) ProtoMessage() {} -func (*DidDocStructUpdateDID) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{2} -} -func (m *DidDocStructUpdateDID) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DidDocStructUpdateDID) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DidDocStructUpdateDID.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DidDocStructUpdateDID) XXX_Merge(src proto.Message) { - xxx_messageInfo_DidDocStructUpdateDID.Merge(m, src) -} -func (m *DidDocStructUpdateDID) XXX_Size() int { - return m.Size() -} -func (m *DidDocStructUpdateDID) XXX_DiscardUnknown() { - xxx_messageInfo_DidDocStructUpdateDID.DiscardUnknown(m) -} - -var xxx_messageInfo_DidDocStructUpdateDID proto.InternalMessageInfo - -func (m *DidDocStructUpdateDID) GetContext() []string { - if m != nil { - return m.Context - } - return nil -} - -func (m *DidDocStructUpdateDID) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *DidDocStructUpdateDID) GetController() []string { - if m != nil { - return m.Controller - } - return nil -} - -func (m *DidDocStructUpdateDID) GetAlsoKnownAs() []string { - if m != nil { - return m.AlsoKnownAs - } - return nil -} - -func (m *DidDocStructUpdateDID) GetVerificationMethod() []*VerificationMethod { - if m != nil { - return m.VerificationMethod - } - return nil -} - -func (m *DidDocStructUpdateDID) GetAuthentication() []string { - if m != nil { - return m.Authentication - } - return nil -} - -func (m *DidDocStructUpdateDID) GetAssertionMethod() []string { - if m != nil { - return m.AssertionMethod - } - return nil -} - -func (m *DidDocStructUpdateDID) GetKeyAgreement() []string { - if m != nil { - return m.KeyAgreement - } - return nil -} - -func (m *DidDocStructUpdateDID) GetCapabilityInvocation() []string { - if m != nil { - return m.CapabilityInvocation - } - return nil -} - -func (m *DidDocStructUpdateDID) GetCreated() string { - if m != nil { - return m.Created - } - return "" -} - -func (m *DidDocStructUpdateDID) GetUpdated() string { - if m != nil { - return m.Updated - } - return "" -} - -type VerificationMethod struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Controller string `protobuf:"bytes,3,opt,name=controller,proto3" json:"controller,omitempty"` - PublicKeyMultibase string `protobuf:"bytes,4,opt,name=publicKeyMultibase,proto3" json:"publicKeyMultibase,omitempty"` -} - -func (m *VerificationMethod) Reset() { *m = VerificationMethod{} } -func (m *VerificationMethod) String() string { return proto.CompactTextString(m) } -func (*VerificationMethod) ProtoMessage() {} -func (*VerificationMethod) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{3} -} -func (m *VerificationMethod) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VerificationMethod) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VerificationMethod.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VerificationMethod) XXX_Merge(src proto.Message) { - xxx_messageInfo_VerificationMethod.Merge(m, src) -} -func (m *VerificationMethod) XXX_Size() int { - return m.Size() -} -func (m *VerificationMethod) XXX_DiscardUnknown() { - xxx_messageInfo_VerificationMethod.DiscardUnknown(m) -} - -var xxx_messageInfo_VerificationMethod proto.InternalMessageInfo - -func (m *VerificationMethod) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *VerificationMethod) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *VerificationMethod) GetController() string { - if m != nil { - return m.Controller - } - return "" -} - -func (m *VerificationMethod) GetPublicKeyMultibase() string { - if m != nil { - return m.PublicKeyMultibase - } - return "" -} - type MsgCreateDIDResponse struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } @@ -411,7 +95,7 @@ func (m *MsgCreateDIDResponse) Reset() { *m = MsgCreateDIDResponse{} } func (m *MsgCreateDIDResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateDIDResponse) ProtoMessage() {} func (*MsgCreateDIDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{4} + return fileDescriptor_73a1aa6c7279248b, []int{1} } func (m *MsgCreateDIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -447,69 +131,17 @@ func (m *MsgCreateDIDResponse) GetId() uint64 { return 0 } -type SignInfo struct { - VerificationMethodId string `protobuf:"bytes,1,opt,name=verification_method_id,json=verificationMethodId,proto3" json:"verification_method_id,omitempty"` - Signature string `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (m *SignInfo) Reset() { *m = SignInfo{} } -func (m *SignInfo) String() string { return proto.CompactTextString(m) } -func (*SignInfo) ProtoMessage() {} -func (*SignInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{5} -} -func (m *SignInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SignInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SignInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SignInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignInfo.Merge(m, src) -} -func (m *SignInfo) XXX_Size() int { - return m.Size() -} -func (m *SignInfo) XXX_DiscardUnknown() { - xxx_messageInfo_SignInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_SignInfo proto.InternalMessageInfo - -func (m *SignInfo) GetVerificationMethodId() string { - if m != nil { - return m.VerificationMethodId - } - return "" -} - -func (m *SignInfo) GetSignature() string { - if m != nil { - return m.Signature - } - return "" -} - type MsgUpdateDID struct { - DidDocString *DidDocStructUpdateDID `protobuf:"bytes,1,opt,name=didDocString,proto3" json:"didDocString,omitempty"` - Signatures []*SignInfo `protobuf:"bytes,2,rep,name=signatures,proto3" json:"signatures,omitempty"` - Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` + DidDocString *Did `protobuf:"bytes,1,opt,name=didDocString,proto3" json:"didDocString,omitempty"` + Signatures []*SignInfo `protobuf:"bytes,2,rep,name=signatures,proto3" json:"signatures,omitempty"` + Creator string `protobuf:"bytes,3,opt,name=creator,proto3" json:"creator,omitempty"` } func (m *MsgUpdateDID) Reset() { *m = MsgUpdateDID{} } func (m *MsgUpdateDID) String() string { return proto.CompactTextString(m) } func (*MsgUpdateDID) ProtoMessage() {} func (*MsgUpdateDID) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{6} + return fileDescriptor_73a1aa6c7279248b, []int{2} } func (m *MsgUpdateDID) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -538,7 +170,7 @@ func (m *MsgUpdateDID) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateDID proto.InternalMessageInfo -func (m *MsgUpdateDID) GetDidDocString() *DidDocStructUpdateDID { +func (m *MsgUpdateDID) GetDidDocString() *Did { if m != nil { return m.DidDocString } @@ -567,7 +199,7 @@ func (m *MsgUpdateDIDResponse) Reset() { *m = MsgUpdateDIDResponse{} } func (m *MsgUpdateDIDResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateDIDResponse) ProtoMessage() {} func (*MsgUpdateDIDResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{7} + return fileDescriptor_73a1aa6c7279248b, []int{3} } func (m *MsgUpdateDIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -613,7 +245,7 @@ func (m *MsgCreateSchema) Reset() { *m = MsgCreateSchema{} } func (m *MsgCreateSchema) String() string { return proto.CompactTextString(m) } func (*MsgCreateSchema) ProtoMessage() {} func (*MsgCreateSchema) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{8} + return fileDescriptor_73a1aa6c7279248b, []int{4} } func (m *MsgCreateSchema) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -671,7 +303,7 @@ func (m *MsgCreateSchemaResponse) Reset() { *m = MsgCreateSchemaResponse func (m *MsgCreateSchemaResponse) String() string { return proto.CompactTextString(m) } func (*MsgCreateSchemaResponse) ProtoMessage() {} func (*MsgCreateSchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_73a1aa6c7279248b, []int{9} + return fileDescriptor_73a1aa6c7279248b, []int{5} } func (m *MsgCreateSchemaResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -709,11 +341,7 @@ func (m *MsgCreateSchemaResponse) GetId() uint64 { func init() { proto.RegisterType((*MsgCreateDID)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateDID") - proto.RegisterType((*DidDocStructCreateDID)(nil), "hypersignprotocol.hidnode.ssi.DidDocStructCreateDID") - proto.RegisterType((*DidDocStructUpdateDID)(nil), "hypersignprotocol.hidnode.ssi.DidDocStructUpdateDID") - proto.RegisterType((*VerificationMethod)(nil), "hypersignprotocol.hidnode.ssi.VerificationMethod") proto.RegisterType((*MsgCreateDIDResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateDIDResponse") - proto.RegisterType((*SignInfo)(nil), "hypersignprotocol.hidnode.ssi.SignInfo") proto.RegisterType((*MsgUpdateDID)(nil), "hypersignprotocol.hidnode.ssi.MsgUpdateDID") proto.RegisterType((*MsgUpdateDIDResponse)(nil), "hypersignprotocol.hidnode.ssi.MsgUpdateDIDResponse") proto.RegisterType((*MsgCreateSchema)(nil), "hypersignprotocol.hidnode.ssi.MsgCreateSchema") @@ -723,51 +351,34 @@ func init() { func init() { proto.RegisterFile("ssi/v1/tx.proto", fileDescriptor_73a1aa6c7279248b) } var fileDescriptor_73a1aa6c7279248b = []byte{ - // 697 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x6a, 0xdb, 0x4a, - 0x14, 0xce, 0xd8, 0xbe, 0x49, 0x7c, 0x6c, 0x12, 0x98, 0x9b, 0x7b, 0xaf, 0x30, 0xb7, 0xc2, 0x08, - 0x9a, 0xba, 0x94, 0xc8, 0x44, 0x09, 0xdd, 0x75, 0x91, 0xd6, 0x50, 0x4c, 0xea, 0x8d, 0x43, 0x4b, - 0xe9, 0xa2, 0x41, 0x96, 0x26, 0xd2, 0x50, 0x79, 0x46, 0x68, 0x46, 0x6e, 0xfc, 0x06, 0x5d, 0xf6, - 0x5d, 0xfa, 0x0a, 0x5d, 0x14, 0xba, 0xc9, 0xb2, 0xd0, 0x4d, 0x49, 0x5e, 0xa4, 0x68, 0x2c, 0xc9, - 0xf2, 0x4f, 0xeb, 0xa4, 0x85, 0x42, 0xa1, 0x3b, 0xcf, 0x39, 0xdf, 0xf9, 0xce, 0x37, 0xe7, 0x1b, - 0x8e, 0x0c, 0xdb, 0x42, 0xd0, 0xf6, 0x68, 0xbf, 0x2d, 0xcf, 0xcd, 0x30, 0xe2, 0x92, 0xe3, 0x5b, - 0xfe, 0x38, 0x24, 0x91, 0xa0, 0x1e, 0x53, 0x67, 0x87, 0x07, 0xa6, 0x4f, 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x4b, 0xd8, 0xdb, 0xe7, - 0xed, 0xe4, 0x7f, 0x50, 0xb2, 0x65, 0xc4, 0x60, 0x5d, 0xa5, 0x0f, 0xbe, 0x06, 0x00, 0x00, 0xff, - 0xff, 0xdf, 0x0f, 0xc7, 0x2b, 0x4b, 0x09, 0x00, 0x00, + // 425 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xee, 0x24, 0x52, 0xcd, 0x6b, 0xb1, 0x12, 0x05, 0x43, 0xc0, 0x50, 0x02, 0x6a, 0x45, 0x9a, + 0x60, 0x0a, 0xde, 0xbc, 0x68, 0x50, 0x0a, 0xf6, 0x92, 0xe2, 0xc5, 0x5b, 0x9b, 0x19, 0x93, 0x01, + 0x93, 0x09, 0x99, 0xb4, 0xb4, 0xff, 0xc2, 0xff, 0xe2, 0xc9, 0x7f, 0xe0, 0xb1, 0xc7, 0x85, 0xbd, + 0x2c, 0xed, 0x1f, 0x59, 0x32, 0x69, 0xd2, 0xb4, 0xcb, 0x6e, 0xdb, 0xbd, 0xed, 0xf1, 0xbd, 0xf9, + 0xde, 0xfb, 0xbe, 0xef, 0xbd, 0xc7, 0x40, 0x87, 0x73, 0x6a, 0xcf, 0x3f, 0xd8, 0xd9, 0xc2, 0x4a, + 0x52, 0x96, 0x31, 0xf5, 0x55, 0xb8, 0x4c, 0x48, 0xca, 0x69, 0x10, 0x8b, 0xd8, 0x67, 0xbf, 0xad, + 0x90, 0xe2, 0x98, 0x61, 0x62, 0x71, 0x4e, 0xf5, 0xe7, 0x5b, 0x3c, 0xf7, 0x43, 0x12, 0x4d, 0x8a, + 0x1a, 0xfd, 0xd9, 0x36, 0x89, 0x29, 0x2e, 0x32, 0xe6, 0x3f, 0x04, 0xed, 0x11, 0x0f, 0xbe, 0xa4, + 0x64, 0x92, 0x11, 0x77, 0xe8, 0xaa, 0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xab, 0xc0, + 0xa7, 0xd0, 0xdd, 0x5c, 0xf1, 0x1c, 0xda, 0x7b, 0x2b, 0xb4, 0x4e, 0xd5, 0x5c, 0xe0, 0xf5, 0x8f, + 0xe7, 0xe1, 0x4b, 0xde, 0xcf, 0xdf, 0xff, 0xaf, 0x0d, 0xb4, 0x5a, 0x1b, 0xe8, 0x6a, 0x6d, 0xa0, + 0x3f, 0x1b, 0xa3, 0xb1, 0xda, 0x18, 0x8d, 0x8b, 0x8d, 0xd1, 0xf8, 0xe9, 0x04, 0x34, 0x0b, 0x67, + 0x53, 0xcb, 0x67, 0x91, 0x5d, 0xf5, 0xee, 0x97, 0xcd, 0xed, 0x90, 0xe2, 0x7e, 0xde, 0xdd, 0x5e, + 0xd8, 0xf9, 0x3f, 0x93, 0x2d, 0x13, 0xc2, 0xa7, 0x4d, 0xf1, 0x3c, 0xb8, 0x0e, 0x00, 0x00, 0xff, + 0xff, 0x25, 0x54, 0x5e, 0x8b, 0xc0, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -978,7 +589,7 @@ func (m *MsgCreateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DidDocStructCreateDID) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateDIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -988,360 +599,30 @@ func (m *DidDocStructCreateDID) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DidDocStructCreateDID) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateDIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DidDocStructCreateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateDIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Updated) > 0 { - i -= len(m.Updated) - copy(dAtA[i:], m.Updated) - i = encodeVarintTx(dAtA, i, uint64(len(m.Updated))) - i-- - dAtA[i] = 0x5a - } - if len(m.Created) > 0 { - i -= len(m.Created) - copy(dAtA[i:], m.Created) - i = encodeVarintTx(dAtA, i, uint64(len(m.Created))) + if m.Id != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Id)) i-- - dAtA[i] = 0x52 - } - if len(m.CapabilityInvocation) > 0 { - for iNdEx := len(m.CapabilityInvocation) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.CapabilityInvocation[iNdEx]) - copy(dAtA[i:], m.CapabilityInvocation[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.CapabilityInvocation[iNdEx]))) - i-- - dAtA[i] = 0x4a - } + dAtA[i] = 0x8 } - if len(m.KeyAgreement) > 0 { - for iNdEx := len(m.KeyAgreement) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.KeyAgreement[iNdEx]) - copy(dAtA[i:], m.KeyAgreement[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.KeyAgreement[iNdEx]))) - i-- - dAtA[i] = 0x42 - } - } - if len(m.AssertionMethod) > 0 { - for iNdEx := len(m.AssertionMethod) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AssertionMethod[iNdEx]) - copy(dAtA[i:], m.AssertionMethod[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.AssertionMethod[iNdEx]))) - i-- - dAtA[i] = 0x3a - } - } - if len(m.Authentication) > 0 { - for iNdEx := len(m.Authentication) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Authentication[iNdEx]) - copy(dAtA[i:], m.Authentication[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authentication[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.VerificationMethod) > 0 { - for iNdEx := len(m.VerificationMethod) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VerificationMethod[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if len(m.AlsoKnownAs) > 0 { - for iNdEx := len(m.AlsoKnownAs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AlsoKnownAs[iNdEx]) - copy(dAtA[i:], m.AlsoKnownAs[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.AlsoKnownAs[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.Controller) > 0 { - for iNdEx := len(m.Controller) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Controller[iNdEx]) - copy(dAtA[i:], m.Controller[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Controller[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x12 - } - if len(m.Context) > 0 { - for iNdEx := len(m.Context) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Context[iNdEx]) - copy(dAtA[i:], m.Context[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Context[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DidDocStructUpdateDID) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DidDocStructUpdateDID) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DidDocStructUpdateDID) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Updated) > 0 { - i -= len(m.Updated) - copy(dAtA[i:], m.Updated) - i = encodeVarintTx(dAtA, i, uint64(len(m.Updated))) - i-- - dAtA[i] = 0x5a - } - if len(m.Created) > 0 { - i -= len(m.Created) - copy(dAtA[i:], m.Created) - i = encodeVarintTx(dAtA, i, uint64(len(m.Created))) - i-- - dAtA[i] = 0x52 - } - if len(m.CapabilityInvocation) > 0 { - for iNdEx := len(m.CapabilityInvocation) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.CapabilityInvocation[iNdEx]) - copy(dAtA[i:], m.CapabilityInvocation[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.CapabilityInvocation[iNdEx]))) - i-- - dAtA[i] = 0x4a - } - } - if len(m.KeyAgreement) > 0 { - for iNdEx := len(m.KeyAgreement) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.KeyAgreement[iNdEx]) - copy(dAtA[i:], m.KeyAgreement[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.KeyAgreement[iNdEx]))) - i-- - dAtA[i] = 0x42 - } - } - if len(m.AssertionMethod) > 0 { - for iNdEx := len(m.AssertionMethod) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AssertionMethod[iNdEx]) - copy(dAtA[i:], m.AssertionMethod[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.AssertionMethod[iNdEx]))) - i-- - dAtA[i] = 0x3a - } - } - if len(m.Authentication) > 0 { - for iNdEx := len(m.Authentication) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Authentication[iNdEx]) - copy(dAtA[i:], m.Authentication[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authentication[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if len(m.VerificationMethod) > 0 { - for iNdEx := len(m.VerificationMethod) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.VerificationMethod[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if len(m.AlsoKnownAs) > 0 { - for iNdEx := len(m.AlsoKnownAs) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AlsoKnownAs[iNdEx]) - copy(dAtA[i:], m.AlsoKnownAs[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.AlsoKnownAs[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.Controller) > 0 { - for iNdEx := len(m.Controller) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Controller[iNdEx]) - copy(dAtA[i:], m.Controller[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Controller[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x12 - } - if len(m.Context) > 0 { - for iNdEx := len(m.Context) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Context[iNdEx]) - copy(dAtA[i:], m.Context[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Context[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *VerificationMethod) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VerificationMethod) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VerificationMethod) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.PublicKeyMultibase) > 0 { - i -= len(m.PublicKeyMultibase) - copy(dAtA[i:], m.PublicKeyMultibase) - i = encodeVarintTx(dAtA, i, uint64(len(m.PublicKeyMultibase))) - i-- - dAtA[i] = 0x22 - } - if len(m.Controller) > 0 { - i -= len(m.Controller) - copy(dAtA[i:], m.Controller) - i = encodeVarintTx(dAtA, i, uint64(len(m.Controller))) - i-- - dAtA[i] = 0x1a - } - if len(m.Type) > 0 { - i -= len(m.Type) - copy(dAtA[i:], m.Type) - i = encodeVarintTx(dAtA, i, uint64(len(m.Type))) - i-- - dAtA[i] = 0x12 - } - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateDIDResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgCreateDIDResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateDIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Id != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *SignInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SignInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SignInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.VerificationMethodId) > 0 { - i -= len(m.VerificationMethodId) - copy(dAtA[i:], m.VerificationMethodId) - i = encodeVarintTx(dAtA, i, uint64(len(m.VerificationMethodId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgUpdateDID) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + return len(dAtA) - i, nil +} + +func (m *MsgUpdateDID) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } return dAtA[:n], nil } @@ -1540,260 +821,80 @@ func (m *MsgCreateDID) Size() (n int) { return n } -func (m *DidDocStructCreateDID) Size() (n int) { +func (m *MsgCreateDIDResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Context) > 0 { - for _, s := range m.Context { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.Id) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Id != 0 { + n += 1 + sovTx(uint64(m.Id)) } - if len(m.Controller) > 0 { - for _, s := range m.Controller { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } + return n +} + +func (m *MsgUpdateDID) Size() (n int) { + if m == nil { + return 0 } - if len(m.AlsoKnownAs) > 0 { - for _, s := range m.AlsoKnownAs { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } + var l int + _ = l + if m.DidDocString != nil { + l = m.DidDocString.Size() + n += 1 + l + sovTx(uint64(l)) } - if len(m.VerificationMethod) > 0 { - for _, e := range m.VerificationMethod { + if len(m.Signatures) > 0 { + for _, e := range m.Signatures { l = e.Size() n += 1 + l + sovTx(uint64(l)) } } - if len(m.Authentication) > 0 { - for _, s := range m.Authentication { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.AssertionMethod) > 0 { - for _, s := range m.AssertionMethod { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.KeyAgreement) > 0 { - for _, s := range m.KeyAgreement { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.CapabilityInvocation) > 0 { - for _, s := range m.CapabilityInvocation { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.Created) + l = len(m.Creator) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Updated) + return n +} + +func (m *MsgUpdateDIDResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.UpdateId) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *DidDocStructUpdateDID) Size() (n int) { +func (m *MsgCreateSchema) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Context) > 0 { - for _, s := range m.Context { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.Id) + l = len(m.Creator) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Controller) > 0 { - for _, s := range m.Controller { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.AlsoKnownAs) > 0 { - for _, s := range m.AlsoKnownAs { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } + if m.Schema != nil { + l = m.Schema.Size() + n += 1 + l + sovTx(uint64(l)) } - if len(m.VerificationMethod) > 0 { - for _, e := range m.VerificationMethod { + if len(m.Signatures) > 0 { + for _, e := range m.Signatures { l = e.Size() n += 1 + l + sovTx(uint64(l)) } } - if len(m.Authentication) > 0 { - for _, s := range m.Authentication { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.AssertionMethod) > 0 { - for _, s := range m.AssertionMethod { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.KeyAgreement) > 0 { - for _, s := range m.KeyAgreement { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - if len(m.CapabilityInvocation) > 0 { - for _, s := range m.CapabilityInvocation { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.Created) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Updated) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *VerificationMethod) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Type) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Controller) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.PublicKeyMultibase) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateDIDResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovTx(uint64(m.Id)) - } - return n -} - -func (m *SignInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.VerificationMethodId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateDID) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DidDocString != nil { - l = m.DidDocString.Size() - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Signatures) > 0 { - for _, e := range m.Signatures { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgUpdateDIDResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UpdateId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateSchema) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Schema != nil { - l = m.Schema.Size() - n += 1 + l + sovTx(uint64(l)) - } - if len(m.Signatures) > 0 { - for _, e := range m.Signatures { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - return n -} - -func (m *MsgCreateSchemaResponse) Size() (n int) { - if m == nil { - return 0 + return n +} + +func (m *MsgCreateSchemaResponse) Size() (n int) { + if m == nil { + return 0 } var l int _ = l @@ -1868,7 +969,7 @@ func (m *MsgCreateDID) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.DidDocString == nil { - m.DidDocString = &DidDocStructCreateDID{} + m.DidDocString = &Did{} } if err := m.DidDocString.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1961,7 +1062,7 @@ func (m *MsgCreateDID) Unmarshal(dAtA []byte) error { } return nil } -func (m *DidDocStructCreateDID) Unmarshal(dAtA []byte) error { +func (m *MsgCreateDIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1984,145 +1085,17 @@ func (m *DidDocStructCreateDID) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: DidDocStructCreateDID: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateDIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: DidDocStructCreateDID: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateDIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Controller = append(m.Controller, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AlsoKnownAs", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AlsoKnownAs = append(m.AlsoKnownAs, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethod", wireType) - } - var msglen int + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2132,983 +1105,11 @@ func (m *DidDocStructCreateDID) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VerificationMethod = append(m.VerificationMethod, &VerificationMethod{}) - if err := m.VerificationMethod[len(m.VerificationMethod)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssertionMethod", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AssertionMethod = append(m.AssertionMethod, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyAgreement", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.KeyAgreement = append(m.KeyAgreement, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CapabilityInvocation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CapabilityInvocation = append(m.CapabilityInvocation, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Created = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Updated", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Updated = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DidDocStructUpdateDID) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DidDocStructUpdateDID: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DidDocStructUpdateDID: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Controller = append(m.Controller, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AlsoKnownAs", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AlsoKnownAs = append(m.AlsoKnownAs, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VerificationMethod = append(m.VerificationMethod, &VerificationMethod{}) - if err := m.VerificationMethod[len(m.VerificationMethod)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssertionMethod", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AssertionMethod = append(m.AssertionMethod, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyAgreement", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.KeyAgreement = append(m.KeyAgreement, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CapabilityInvocation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CapabilityInvocation = append(m.CapabilityInvocation, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Created = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Updated", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Updated = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VerificationMethod) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VerificationMethod: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VerificationMethod: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Controller", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Controller = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PublicKeyMultibase", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PublicKeyMultibase = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgCreateDIDResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgCreateDIDResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateDIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SignInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SignInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SignInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethodId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VerificationMethodId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -3189,7 +1190,7 @@ func (m *MsgUpdateDID) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.DidDocString == nil { - m.DidDocString = &DidDocStructUpdateDID{} + m.DidDocString = &Did{} } if err := m.DidDocString.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/ssi/utils/did_vars.go b/x/ssi/utils/did_vars.go new file mode 100644 index 0000000..798e875 --- /dev/null +++ b/x/ssi/utils/did_vars.go @@ -0,0 +1,8 @@ +package utils + +var ServiceTypes = []string{ + "LinkedDomains", + "DIDCommMessaging", +} + +var DidPrefix string = "did:hs:" \ No newline at end of file diff --git a/x/ssi/utils/utils.go b/x/ssi/utils/utils.go index 7c56f8e..f83dfbc 100644 --- a/x/ssi/utils/utils.go +++ b/x/ssi/utils/utils.go @@ -2,7 +2,6 @@ package utils import ( "crypto/ed25519" - "encoding/base64" "errors" "fmt" "regexp" @@ -11,16 +10,64 @@ import ( "github.com/hypersign-protocol/hid-node/x/ssi/types" ) -var did_prefix string = "did:hs:" - // Checks whether the given string is a valid DID func IsValidDid(did string) bool { - return strings.HasPrefix(did, did_prefix) + return strings.HasPrefix(did, DidPrefix) } // Checks whether the ID in the DidDoc is a valid string -func IsValidDidDocID(didDoc *types.DidDocStructCreateDID) bool { - return strings.HasPrefix(didDoc.GetId(), did_prefix) +func IsValidDidDocID(didDoc *types.Did) bool { + return strings.HasPrefix(didDoc.GetId(), DidPrefix) +} + +// Cheks whether the Service is valid +func ValidateServices(services []*types.Service) error { + for idx, service := range services { + if !IsValidDidFragment(service.Id) { + return types.ErrInvalidService.Wrapf("Service ID %s is Invalid", service.Id) + } + + if !IsValidDidServiceType(service.Type) { + return types.ErrInvalidService.Wrapf("Service Type %s is Invalid", service.Type) + } + + if DuplicateServiceExists(service.Id, services[idx+1:]) { + return types.ErrInvalidService.Wrapf("Service with Id: %s is duplicate", service.Id) + } + } + return nil +} + +// Check for valid DID fragment +func IsValidDidFragment(didUrl string) bool { + if !strings.Contains(didUrl, "#") { + return false + } + + did, _ := SplitDidUrlIntoDid(didUrl) + hasPrefix := IsValidDid(did) + return hasPrefix +} + +// Check Valid DID service type +func IsValidDidServiceType(sType string) bool { + for _, val := range ServiceTypes { + if val == sType { + return true + } + } + return false +} + +func DuplicateServiceExists(serviceId string, services []*types.Service) bool { + did, _ := SplitDidUrlIntoDid(serviceId) + for _, s := range services { + sDid, _ := SplitDidUrlIntoDid(s.Id) + if did == sDid { + return true + } + } + return false } // Check whether the fields whose values are array of DIDs are valid DID @@ -34,16 +81,17 @@ func IsValidDIDArray(didArray []string) bool { } // Checks whether the DidDoc string is valid -func IsValidDidDoc(didDoc *types.DidDocStructCreateDID) string { +func IsValidDidDoc(didDoc *types.Did) string { didArrayMap := map[string][]string{ "authentication": didDoc.GetAuthentication(), "assertionMethod": didDoc.GetAssertionMethod(), "keyAgreement": didDoc.GetKeyAgreement(), "capabilityInvocation": didDoc.GetCapabilityInvocation(), + "capabilityDelegation": didDoc.GetCapabilityDelegation(), } nonEmptyFields := map[string]string{ - "id": didDoc.GetId(), + "id": didDoc.GetId(), } // Invalid ID check @@ -64,36 +112,15 @@ func IsValidDidDoc(didDoc *types.DidDocStructCreateDID) string { return fmt.Sprintf("The field %s must have a value", field) } } - return "" -} -func VerifyIdentitySignature(signer types.Signer, signatures []*types.SignInfo, signingInput []byte) (bool, error) { - result := true - foundOne := false - - for _, info := range signatures { - did, _ := SplitDidUrlIntoDid(info.VerificationMethodId) - if did == signer.Signer { - pubKey, err := FindPublicKey(signer, info.VerificationMethodId) - if err != nil { - return false, err - } - - signature, err := base64.StdEncoding.DecodeString(info.Signature) - if err != nil { - return false, err - } - - result = result && ed25519.Verify(pubKey, signingInput, signature) - foundOne = true - } + // Valid Services Check + err := ValidateServices(didDoc.GetService()) + if err != nil { + return fmt.Sprint(err) } - if !foundOne { - return false, fmt.Errorf("signature %s not found", signer.Signer) - } + return "" - return result, nil } func SplitDidUrlIntoDid(didUrl string) (string, string) {