feature/migrate models (#16)

* feat: add new supported attestation formats to genesis

* feat: refactor keyType to keytype enum

* refactor: remove unused imports and code

* refactor: update main.go to use src package

* refactor: move web-related structs from  to

* refactor: move client middleware package to root

* refactor: remove unused IndexedDB dependency

* feat: update worker implementation to use

* feat: add Caddyfile and Caddy configuration for vault service

* refactor(config): move keyshare and address to Motr config

* fix: validate service origin in AllocateVault

* chore: remove IndexedDB configuration

* feat: add support for IPNS-based vault access
This commit is contained in:
Prad Nukala
2024-09-19 02:04:22 -04:00
committed by GitHub
parent 6d8bd8fc85
commit 96e6486c43
151 changed files with 10997 additions and 21705 deletions
+45 -118
View File
@@ -10,17 +10,6 @@ option go_package = "github.com/onsonr/sonr/x/did/types";
message GenesisState {
// Params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// GlobalIntegrity defines a zkp integrity proof for the entire DID namespace
GlobalIntegrity global_integrity = 2;
}
// GlobalIntegrity defines a zkp integrity proof for the entire DID namespace
message GlobalIntegrity {
string controller = 1;
string seed = 2;
bytes accumulator = 3;
uint64 count = 4;
}
// Params defines the set of module parameters.
@@ -60,7 +49,7 @@ message AssetInfo {
string symbol = 3;
// The coin name
AssetType asset_type = 4;
string asset_type = 4;
// The name of the asset
string name = 5;
@@ -69,116 +58,54 @@ message AssetInfo {
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 {
KeyRole role = 1;
KeyAlgorithm algorithm = 2; // e.g., "ES256", "EdDSA", "ES256K"
KeyEncoding encoding = 3; // e.g., "hex", "base64", "multibase"
KeyCurve curve = 4; // e.g., "P256", "P384", "P521", "X25519", "X448", "Ed25519", "Ed448", "secp256k1"
KeyType type = 5; // e.g., "Octet", "Elliptic", "RSA", "Symmetric", "HMAC"
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"
}
// AssetType defines the type of asset: native, wrapped, staking, pool, or unspecified
enum AssetType {
ASSET_TYPE_UNSPECIFIED = 0;
ASSET_TYPE_NATIVE = 1;
ASSET_TYPE_WRAPPED = 2;
ASSET_TYPE_STAKING = 3;
ASSET_TYPE_POOL = 4;
ASSET_TYPE_IBC = 5;
ASSET_TYPE_CW20 = 6;
// 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)
}
}
// DIDNamespace define the different namespaces of DID
enum DIDNamespace {
DID_NAMESPACE_UNSPECIFIED = 0;
DID_NAMESPACE_IPFS = 1;
DID_NAMESPACE_SONR = 2;
DID_NAMESPACE_BITCOIN = 3;
DID_NAMESPACE_ETHEREUM = 4;
DID_NAMESPACE_IBC = 5;
DID_NAMESPACE_WEBAUTHN = 6;
DID_NAMESPACE_DWN = 7;
DID_NAMESPACE_SERVICE = 8;
}
// KeyAlgorithm defines the key algorithm
enum KeyAlgorithm {
KEY_ALGORITHM_UNSPECIFIED = 0;
KEY_ALGORITHM_ES256 = 1;
KEY_ALGORITHM_ES384 = 2;
KEY_ALGORITHM_ES512 = 3;
KEY_ALGORITHM_EDDSA = 4;
KEY_ALGORITHM_ES256K = 5;
KEY_ALGORITHM_ECDSA = 6; // Fixed typo from EDCSA to ECDSA
}
// KeyCurve defines the key curve
enum KeyCurve {
KEY_CURVE_UNSPECIFIED = 0;
KEY_CURVE_P256 = 1; // NIST P-256
KEY_CURVE_P384 = 2;
KEY_CURVE_P521 = 3;
KEY_CURVE_X25519 = 4;
KEY_CURVE_X448 = 5;
KEY_CURVE_ED25519 = 6;
KEY_CURVE_ED448 = 7;
KEY_CURVE_SECP256K1 = 8;
KEY_CURVE_BLS12381 = 9;
KEY_CURVE_KECCAK256 = 10;
}
// KeyEncoding defines the key encoding
enum KeyEncoding {
KEY_ENCODING_UNSPECIFIED = 0;
KEY_ENCODING_RAW = 1;
KEY_ENCODING_HEX = 2;
KEY_ENCODING_MULTIBASE = 3;
}
// KeyRole defines the kind of key
enum KeyRole {
KEY_ROLE_UNSPECIFIED = 0;
KEY_ROLE_AUTHENTICATION = 1; // Passkeys and FIDO
KEY_ROLE_ASSERTION = 2; // Zk Identifiers
KEY_ROLE_DELEGATION = 3; // ETH,BTC,IBC addresses
KEY_ROLE_INVOCATION = 4; // DWN Controllers
}
// KeyType defines the key type
enum KeyType {
KEY_TYPE_UNSPECIFIED = 0;
KEY_TYPE_OCTET = 1;
KEY_TYPE_ELLIPTIC = 2;
KEY_TYPE_RSA = 3;
KEY_TYPE_SYMMETRIC = 4;
KEY_TYPE_HMAC = 5;
KEY_TYPE_MPC = 6;
KEY_TYPE_ZK = 7;
KEY_TYPE_WEBAUTHN = 8;
KEY_TYPE_BIP32 = 9;
}
enum KeyshareRole {
KEYSHARE_ROLE_UNSPECIFIED = 0;
KEYSHARE_ROLE_USER = 1;
KEYSHARE_ROLE_VALIDATOR = 2;
}
// PermissionScope define the Capabilities Controllers can grant for Services
enum PermissionScope {
PERMISSION_SCOPE_UNSPECIFIED = 0;
PERMISSION_SCOPE_BASIC_INFO = 1;
PERMISSION_SCOPE_PERMISSIONS_READ = 2;
PERMISSION_SCOPE_PERMISSIONS_WRITE = 3;
PERMISSION_SCOPE_TRANSACTIONS_READ = 4;
PERMISSION_SCOPE_TRANSACTIONS_WRITE = 5;
PERMISSION_SCOPE_WALLETS_READ = 6;
PERMISSION_SCOPE_WALLETS_CREATE = 7;
PERMISSION_SCOPE_WALLETS_SUBSCRIBE = 8;
PERMISSION_SCOPE_WALLETS_UPDATE = 9;
PERMISSION_SCOPE_TRANSACTIONS_VERIFY = 10;
PERMISSION_SCOPE_TRANSACTIONS_BROADCAST = 11;
PERMISSION_SCOPE_ADMIN_USER = 12;
PERMISSION_SCOPE_ADMIN_VALIDATOR = 13;
// 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;
}
-107
View File
@@ -1,107 +0,0 @@
syntax = "proto3";
package did.v1;
import "did/v1/genesis.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
message Credential {
string subject = 1;
string attestation_type = 2;
string origin = 3;
bytes credential_id = 4;
bytes public_key = 5;
repeated string transport = 6;
uint32 sign_count = 7;
bool user_present = 8;
bool user_verified = 9;
bool backup_eligible = 10;
bool backup_state = 11;
bool clone_warning = 12;
}
// 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;
}
// Keyshare defines a keyshare from the MPC protocol
message Keyshare {
map<string, string> metadata = 1;
map<string, bytes> payloads = 2;
string protocol = 3;
bytes public_key = 4;
uint32 version = 5;
int32 role = 6; // 0 =none, 1 = validator, 2 = user
}
// Permissions contains a list of grants and access control rules for
// a Service.
message Permissions {
repeated DIDNamespace grants = 1;
repeated PermissionScope scopes = 2;
}
// PubKey defines a public key for a did
message PubKey {
KeyRole role = 1;
KeyAlgorithm algorithm = 2;
KeyEncoding encoding = 3;
KeyCurve curve = 4;
KeyType 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;
Permissions permissions = 7;
}
// ServicceInfo defines a Decentralized Service on the Sonr Blockchain
message ServiceInfo {
bool exists = 1;
string origin = 2;
string fingerprint = 3;
Service service = 4;
}
// FirstPartyCaveat defines a first party caveat
message FirstPartyCaveat {
Permissions scope = 1;
int64 exp = 2;
string cnf = 3;
string aud = 4;
}
// ThirdPartyCaveat defines a third party caveat
message ThirdPartyCaveat {
Permissions scope = 1;
int64 exp = 2;
string cnf = 3;
string aud = 4;
}
+6 -1
View File
@@ -2,7 +2,6 @@ syntax = "proto3";
package did.v1;
import "did/v1/genesis.proto";
import "did/v1/models.proto";
import "google/api/annotations.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -47,6 +46,12 @@ message QueryParamsResponse {
Params params = 1;
}
// QueryResolveResponse is the response type for the Query/Resolve RPC method.
message QueryResolveResponse {
// document is the DID document
Document document = 1;
}
// SyncRequest is the request type for the Sync RPC method.
message SyncRequest {
string did = 1;
+41 -25
View File
@@ -4,7 +4,6 @@ package did.v1;
import "cosmos/orm/v1/orm.proto";
import "did/v1/genesis.proto";
import "did/v1/models.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -15,7 +14,7 @@ message Alias {
primary_key: {fields: "id"}
index: {
id: 1
fields: "did,alias"
fields: "subject,origin"
unique: true
}
};
@@ -23,20 +22,11 @@ message Alias {
// The unique identifier of the alias
string id = 1;
// The DID of the alias
string did = 2;
// The alias of the DID
string alias = 3;
string subject = 2;
// Origin of the alias
string origin = 4;
// Permissions of the alias
repeated string scopes = 5;
// Expiration of the alias
int64 expiration = 6;
string origin = 3;
}
// Controller represents a Sonr DWN Vault
@@ -46,16 +36,26 @@ message Controller {
primary_key: {fields: "id"}
index: {
id: 1
fields: "address"
fields: "sonr_address"
unique: true
}
index: {
id: 2
fields: "vault_cid"
fields: "eth_address"
unique: true
}
index: {
id: 3
fields: "btc_address"
unique: true
}
index: {
id: 4
fields: "vault_cid"
unique: true
}
index: {
id: 5
fields: "status,vault_cid"
unique: true
}
@@ -65,22 +65,28 @@ message Controller {
string id = 1;
// The DID of the controller
string address = 2;
string sonr_address = 2;
// The DID of the controller
string eth_address = 3;
// The DID of the controller
string btc_address = 4;
// Aliases of the controller
repeated Alias aliases = 3;
repeated string aliases = 5;
// PubKey is the verification method
PubKey public_key = 4;
PubKey public_key = 6;
// The vault address or identifier
string vault_cid = 5;
string vault_cid = 7;
// The Authentications of the controller
repeated Credential authentication = 6;
repeated string authentication = 8;
// The Status of the claims for the controller
string status = 7;
string status = 9;
}
// Verification reprsents a method of verifying membership in a DID
@@ -90,7 +96,17 @@ message Verification {
primary_key: {fields: "id"}
index: {
id: 1
fields: "controller,method,issuer,subject"
fields: "issuer,subject"
unique: true
}
index: {
id: 2
fields: "controller,did_method,issuer"
unique: true
}
index: {
id: 3
fields: "verification_type,subject,issuer"
unique: true
}
};
@@ -102,7 +118,7 @@ message Verification {
string controller = 2;
// The DIDNamespace of the verification
DIDNamespace method = 3;
string did_method = 3;
// The value of the linked identifier
string issuer = 4;
@@ -113,6 +129,6 @@ message Verification {
// The public key of the verification
PubKey public_key = 6;
// The Verification Kind (Authentication, Assertion, CapabilityDelegation, CapabilityInvocation)
string kind = 7;
// The Verification Type (Authentication, Assertion, CapabilityDelegation, CapabilityInvocation)
string verification_type = 7;
}
+2 -3
View File
@@ -5,7 +5,6 @@ package did.v1;
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "did/v1/genesis.proto";
import "did/v1/models.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -77,7 +76,7 @@ message MsgAllocateVaultResponse {
int64 expiry_block = 2;
// RegistrationOptions is a json string of the PublicKeyCredentialCreationOptions for WebAuthn
string registration_options = 3;
string token = 3;
// IsLocalhost is a flag to indicate if the vault is localhost
bool localhost = 4;
@@ -123,7 +122,7 @@ message MsgAuthorizeService {
string origin = 2;
// Permissions is the scope of the service.
Permissions scopes = 3;
map<string, string> permissions = 3;
// token is the macron token to authenticate the operation.
string token = 4;