feature/1110 abstract connected wallet operations (#1166)

- **refactor: refactor DID module types and move to controller package**
- **refactor: move controller creation and resolution logic to keeper**
- **refactor: update imports to reflect controller package move**
- **refactor: update protobuf definitions for DID module**
- **docs: update proto README to reflect changes**
- **refactor: move hway to gateway, update node modules, and refactor
pkl generation**
- **build: update pkl-gen task to use new pkl file paths**
- **refactor: refactor DWN WASM build and deployment process**
- **refactor: refactor DID controller implementation to use
account-based storage**
- **refactor: move DID controller interface to base file and update
implementation**
- **chore: migrate to google protobuf**
- **feat: Add v0.52.0 Interfaces for Acc Abstraction**
- **refactor: replace public_key with public_key_hex in Assertion
message**
- **refactor: remove unused PubKey, JSONWebKey, and RawKey message types
and related code**
This commit is contained in:
Prad Nukala
2024-11-18 19:04:10 -05:00
committed by GitHub
parent 01cb37e82e
commit bf94277b0f
190 changed files with 9345 additions and 14038 deletions
-6
View File
@@ -10,10 +10,6 @@ This directory contains the protobuf definitions for the Sonr blockchain.
The `did` directory contains the protobuf definitions for the DID module.
### `macaroon`
The `macaroon` directory contains the protobuf definitions for the Macaroon module.
### `service`
The `service` directory contains the protobuf definitions for the Service module.
@@ -21,5 +17,3 @@ The `service` directory contains the protobuf definitions for the Service module
### `vault`
The `vault` directory contains the protobuf definitions for the Vault module.
### `buf.gen.gogo.yaml`
+7 -2
View File
@@ -19,8 +19,13 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: e7f8d366f5264595bcc4cd4139af9973
digest: shake256:e5e5f1c12f82e028ea696faa43b4f9dc6258a6d1226282962a8c8b282e10946281d815884f574bd279ebd9cd7588629beb3db17b892af6c33b56f92f8f67f509
commit: c0913f24652a4cfc95f77d97443a5005
digest: shake256:0ef3248c6235d420fe61f373154adcde6b94e3297f82472b1d8d8c3747240b61b4a10405e2a6f8ac1c98816ac6e690ea7871024aa5ae0e035cd540214667ceed
- remote: buf.build
owner: onsonr
repository: thirdparty
commit: 915d759135b04de684c86d9cf5daf256
digest: shake256:13d0254ab4884f2d47f21d229dc3b17ea859f81d8283c021956ccd0da864228a939d055c8c85a86c66307fd7bd19654da6b3fb89fccd6c6d38ee46651a5951b5
- remote: buf.build
owner: protocolbuffers
repository: wellknowntypes
+1
View File
@@ -5,6 +5,7 @@ deps:
- buf.build/cosmos/cosmos-proto
- buf.build/cosmos/gogo-proto
- buf.build/googleapis/googleapis
- buf.build/onsonr/thirdparty
breaking:
use:
- FILE
+2 -2
View File
@@ -1,11 +1,11 @@
syntax = "proto3";
package onsonr.sonr.did.module.v1;
package did.module.v1;
import "cosmos/app/v1alpha1/module.proto";
// Module is the app config object of the module.
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr/x/did"};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr"};
}
+11 -57
View File
@@ -2,6 +2,7 @@ syntax = "proto3";
package did.v1;
import "amino/amino.proto";
import "did/v1/params.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -9,63 +10,16 @@ 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 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
// 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;
}
// 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"
}
message Keyshares {
string validator_cid = 1;
string user_cid = 2;
int64 last_updated_block = 3;
}
// PubKey defines a public key for a did
message PubKey {
string role = 1;
string key_type = 2;
RawKey raw_key = 3;
JSONWebKey jwk = 4;
}
// JWK represents a JSON Web Key
message JSONWebKey {
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)
}
message RawKey {
string algorithm = 1;
string encoding = 2;
string curve = 3;
bytes key = 4;
// 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;
}
+34
View File
@@ -0,0 +1,34 @@
syntax = "proto3";
package did.v1;
import "amino/amino.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
// 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
// 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;
}
// 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"
}
+1 -16
View File
@@ -2,6 +2,7 @@ syntax = "proto3";
package did.v1;
import "did/v1/genesis.proto";
import "did/v1/params.proto";
import "google/api/annotations.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -18,11 +19,6 @@ service Query {
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";
@@ -79,14 +75,3 @@ 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;
}
+86 -55
View File
@@ -9,9 +9,13 @@ option go_package = "github.com/onsonr/sonr/x/did/types";
message Assertion {
option (cosmos.orm.v1.table) = {
id : 1
primary_key : {fields : "did"}
index : {id : 1 fields : "controller,subject" unique : true}
id: 1
primary_key: {fields: "did"}
index: {
id: 1
fields: "controller,subject"
unique: true
}
};
// The unique identifier of the assertion
@@ -23,8 +27,8 @@ message Assertion {
// Origin of the authentication
string subject = 3;
// PubKey is the verification method
PubKey public_key = 4;
// string is the verification method
string public_key_hex = 4;
// AssertionType is the assertion type
string assertion_type = 5;
@@ -38,9 +42,13 @@ message Assertion {
message Authentication {
option (cosmos.orm.v1.table) = {
id : 2
primary_key : {fields : "did"}
index : {id : 1 fields : "controller,subject" unique : true}
id: 2
primary_key: {fields: "did"}
index: {
id: 1
fields: "controller,subject"
unique: true
}
};
// The unique identifier of the authentication
@@ -52,8 +60,8 @@ message Authentication {
// Origin of the authentication
string subject = 3;
// PubKey is the verification method
PubKey public_key = 4;
// string is the verification method
string public_key_hex = 4;
// CredentialID is the byte representation of the credential ID
bytes credential_id = 5;
@@ -65,15 +73,57 @@ message Authentication {
int64 creation_block = 7;
}
// Macaroon is a Macaroon message type.
message Biscuit {
option (cosmos.orm.v1.table) = {
id: 5
primary_key: {
fields: "id"
auto_increment: true
}
index: {
id: 1
fields: "subject,origin"
unique: true
}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
string macaroon = 6;
}
// Controller represents a Sonr DWN Vault
message Controller {
option (cosmos.orm.v1.table) = {
id : 3
primary_key : {fields : "number" auto_increment : true}
index : {id : 1 fields : "sonr_address" unique : true}
index : {id : 2 fields : "eth_address" unique : true}
index : {id : 3 fields : "btc_address" unique : true}
index : {id : 4 fields : "did" unique : true}
id: 3
primary_key: {
fields: "number"
auto_increment: true
}
index: {
id: 1
fields: "sonr_address"
unique: true
}
index: {
id: 2
fields: "eth_address"
unique: true
}
index: {
id: 3
fields: "btc_address"
unique: true
}
index: {
id: 4
fields: "did"
unique: true
}
};
// The unique identifier of the controller
@@ -91,8 +141,8 @@ message Controller {
// The DID of the controller
string btc_address = 5;
// PubKey is the verification method
PubKey public_key = 6;
// string is the verification method
string public_key_hex = 6;
// Pointer to the Keyshares
string ks_val = 7;
@@ -104,45 +154,26 @@ message Controller {
int64 creation_block = 9;
}
// Grant is a Grant message type.
message Grant {
option (cosmos.orm.v1.table) = {
id : 4
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
}
// Macaroon is a Macaroon message type.
message Macaroon {
option (cosmos.orm.v1.table) = {
id : 5
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "subject,origin" unique : true}
};
uint64 id = 1;
string controller = 2;
string subject = 3;
string origin = 4;
int64 expiry_height = 5;
string macaroon = 6;
}
// Verification represents a verification method
message Verification {
option (cosmos.orm.v1.table) = {
id : 6
primary_key : {fields : "did"}
index : {id : 1 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}
id: 6
primary_key: {fields: "did"}
index: {
id: 1
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
}
};
// The unique identifier of the verification
@@ -161,7 +192,7 @@ message Verification {
string subject = 5;
// The public key of the verification
PubKey public_key = 6;
string public_key_hex = 6;
// The verification method type
string verification_type = 7;
+11 -14
View File
@@ -5,6 +5,7 @@ package did.v1;
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "did/v1/genesis.proto";
import "did/v1/params.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/sonr/x/did/types";
@@ -21,16 +22,13 @@ service Msg {
rpc LinkAssertion(MsgLinkAssertion) returns (MsgLinkAssertionResponse);
// LinkAuthentication links an authentication to a controller.
rpc LinkAuthentication(MsgLinkAuthentication)
returns (MsgLinkAuthenticationResponse);
rpc LinkAuthentication(MsgLinkAuthentication) returns (MsgLinkAuthenticationResponse);
// UnlinkAssertion unlinks an assertion from a controller.
rpc UnlinkAssertion(MsgUnlinkAssertion)
returns (MsgUnlinkAssertionResponse);
rpc UnlinkAssertion(MsgUnlinkAssertion) returns (MsgUnlinkAssertionResponse);
// UnlinkAuthentication unlinks an authentication from a controller.
rpc UnlinkAuthentication(MsgUnlinkAuthentication)
returns (MsgUnlinkAuthenticationResponse);
rpc UnlinkAuthentication(MsgUnlinkAuthentication) returns (MsgUnlinkAuthenticationResponse);
// UpdateParams defines a governance operation for updating the parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
@@ -41,7 +39,7 @@ message MsgLinkAuthentication {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Subject is the subject of the authentication.
string subject = 2;
@@ -72,7 +70,7 @@ message MsgLinkAssertion {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Subject is the subject of the authentication.
string subject = 2;
@@ -95,13 +93,12 @@ message MsgLinkAssertionResponse {
string did = 2;
}
// MsgExecuteTx is the message type for the ExecuteTx RPC.
message MsgExecuteTx {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Messages is the list of messages to execute.
map<string, bytes> messages = 2;
@@ -121,7 +118,7 @@ message MsgUnlinkAssertion {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Assertion is the assertion of the authentication.
string assertion_did = 2;
@@ -146,7 +143,7 @@ message MsgUnlinkAuthentication {
option (cosmos.msg.v1.signer) = "controller";
// Controller is the address of the controller to authenticate.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Subject is the subject of the authentication.
string authentication_did = 2;
@@ -173,10 +170,10 @@ message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the parameters to update.
Params params = 2 [ (gogoproto.nullable) = false ];
Params params = 2 [(gogoproto.nullable) = false];
// token is the macron token to authenticate the operation.
string token = 3;
+2 -2
View File
@@ -1,11 +1,11 @@
syntax = "proto3";
package onsonr.sonr.service.module.v1;
package service.module.v1;
import "cosmos/app/v1alpha1/module.proto";
// Module is the app config object of the module.
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr/x/service"};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr"};
}
+18 -17
View File
@@ -9,9 +9,16 @@ option go_package = "github.com/onsonr/sonr/x/service/types";
message Metadata {
option (cosmos.orm.v1.table) = {
id : 1
primary_key : {fields : "id" auto_increment : true}
index : {id : 1 fields : "origin" unique : true}
id: 1
primary_key: {
fields: "id"
auto_increment: true
}
index: {
id: 1
fields: "origin"
unique: true
}
};
uint64 id = 1;
@@ -19,16 +26,20 @@ message Metadata {
string name = 3;
string description = 4;
string category = 5;
URI icon = 6;
string icon = 6;
repeated string tags = 7;
}
// Profile represents a DID alias
message Profile {
option (cosmos.orm.v1.table) = {
id : 2
primary_key : {fields : "id"}
index : {id : 1 fields : "subject,origin" unique : true}
id: 2
primary_key: {fields: "id"}
index: {
id: 1
fields: "subject,origin"
unique: true
}
};
// The unique identifier of the alias
@@ -43,13 +54,3 @@ message Profile {
// Controller of the alias
string controller = 4;
}
message URI {
enum Protocol {
HTTPS = 0;
IPFS = 1;
}
Protocol protocol = 1;
string uri = 2;
}
+3 -3
View File
@@ -29,12 +29,12 @@ message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [ (gogoproto.nullable) = false ];
Params params = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse defines the response structure for executing a
@@ -48,7 +48,7 @@ message MsgRegisterService {
option (cosmos.msg.v1.signer) = "controller";
// authority is the address of the governance account.
string controller = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// origin is the origin of the request in wildcard form. Requires valid TXT
// record in DNS.
+2 -2
View File
@@ -1,11 +1,11 @@
syntax = "proto3";
package onsonr.sonr.vault.module.v1;
package vault.module.v1;
import "cosmos/app/v1alpha1/module.proto";
// Module is the app config object of the module.
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr/x/vault"};
option (cosmos.app.v1alpha1.module) = {go_import: "github.com/onsonr/sonr"};
}