syntax = "proto3";
package did.v1;

import "did/v1/genesis.proto";
import "google/api/annotations.proto";

option go_package = "github.com/onsonr/sonr/x/did/types";

// Query provides defines the gRPC querier service.
service Query {
  // Params queries all parameters of the module.
  rpc Params(QueryRequest) returns (QueryParamsResponse) {
    option (google.api.http).get = "/did/v1/params";
  }

  // Resolve queries the DID document by its id.
  rpc Resolve(QueryRequest) returns (QueryResolveResponse) {
    option (google.api.http).get = "/did/v1/{did}";
  }

  // Sign signs a message with the DID document
  rpc Sign(QuerySignRequest) returns (QuerySignResponse) {
    option (google.api.http).post = "/did/v1/{did}/sign";
  }

  // Verify verifies a message with the DID document
  rpc Verify(QueryVerifyRequest) returns (QueryVerifyResponse) {
    option (google.api.http).post = "/did/v1/{did}/verify";
  }
}

// Queryequest is the request type for the Query/Params RPC method.
message QueryRequest {
  string did = 1;
  string origin = 2;
  string key = 3;
  string asset = 4;
}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
  // params defines the parameters of the module.
  Params params = 1;
}

// QueryResolveResponse is the response type for the Query/Resolve RPC method.
message QueryResolveResponse {
  // document is the DID document
  Document document = 1;
}

// QuerySignRequest is the request type for the Query/Sign RPC method.
message QuerySignRequest {
  string did = 1;
  string origin = 2;
  string key = 3;
  string asset = 4;
  string message = 5;
}

// QuerySignResponse is the response type for the Query/Sign RPC method.
message QuerySignResponse {
  // signature is the signature of the message
  string signature = 1;
}

// QueryVerifyRequest is the request type for the Query/Verify RPC method.
message QueryVerifyRequest {
  string did = 1;
  string origin = 2;
  string key = 3;
  string asset = 4;
  string message = 5;
  string signature = 6;
}

// QueryVerifyResponse is the response type for the Query/Verify RPC method.
message QueryVerifyResponse {
  // valid is the validity of the signature
  bool valid = 1;
}

// Document defines a DID document
message Document {
  string id = 1;
  string controller = 2; // The DID of the controller
  repeated string authentication = 3;
  repeated string assertion_method = 4;
  repeated string capability_delegation = 5;
  repeated string capability_invocation = 6;
  repeated string service = 7;
}
