syntax = "proto3";
package did.v1;

import "amino/amino.proto";
import "gogoproto/gogo.proto";

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

// GenesisState defines the module genesis state
message GenesisState {
  // Params defines all the parameters of the module.
  Params params = 1 [(gogoproto.nullable) = false];
}

// Params defines the set of module parameters.
message Params {
  option (amino.name) = "did/params";
  option (gogoproto.equal) = true;
  option (gogoproto.goproto_stringer) = false;

  // Whitelisted Assets
  repeated AssetInfo whitelisted_assets = 1;

  // Whitelisted Key Types
  map<string, KeyInfo> allowed_public_keys = 2;

  // ConveyancePreference defines the conveyance preference
  string conveyance_preference = 3;

  // AttestationFormats defines the attestation formats
  repeated string attestation_formats = 4;
}

// AssetInfo defines the asset info
message AssetInfo {
  // The coin type index for bip44 path
  int64 index = 1;

  // The hrp for bech32 address
  string hrp = 2;

  // The coin symbol
  string symbol = 3;

  // The coin name
  string asset_type = 4;

  // The name of the asset
  string name = 5;

  // The icon url
  string icon_url = 6;
}

// 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;
}

// KeyInfo defines information for accepted PubKey types
message KeyInfo {
  string role = 1;
  string algorithm = 2; // e.g., "ES256", "EdDSA", "ES256K"
  string encoding = 3; // e.g., "hex", "base64", "multibase"
  string curve = 4; // e.g., "P256", "P384", "P521", "X25519", "X448",
  // "Ed25519", "Ed448", "secp256k1"
  string type = 5; // e.g., "Octet", "Elliptic", "RSA", "Symmetric", "HMAC"
}

// PubKey defines a public key for a did
message PubKey {
  string role = 1;
  string algorithm = 2;
  string encoding = 3;
  string curve = 4;
  string key_type = 5;
  bytes raw = 6;
  JWK jwk = 7;

  // JWK represents a JSON Web Key
  message JWK {
    string kty = 1; // Key Type
    string crv = 2; // Curve (for EC and OKP keys)
    string x = 3; // X coordinate (for EC and OKP keys)
    string y = 4; // Y coordinate (for EC keys)
    string n = 5; // Modulus (for RSA keys)
    string e = 6; // Exponent (for RSA keys)
  }
}

// Service defines a Decentralized Service on the Sonr Blockchain
message Service {
  string id = 1;
  string service_type = 2;
  string authority = 3;
  string origin = 4;
  string description = 5;
  map<string, string> service_endpoints = 6;
  map<string, string> permissions = 7;
}
