Feature/update dockerfile (#6)

* chore: remove unused new.Dockerfile

* feat: add DID model definitions

* fix: Fix EncodePublicKey method in KeyInfo struct

* feat: Update `EncodePublicKey` to be the inverse of `DecodePublicKey`

* refactor: update AssetInfo protobuf definition

* fix: update default assets with correct asset types

* fix: Initialize IPFS client and check for mounted directories

* feat: Improve IPFS client initialization and mount checking

* feat: Add local filesystem check for IPFS and IPNS

* fix: Use Unixfs().Get() instead of Cat() for IPFS and IPNS content retrieval

* feat: Update GetCID and GetIPNS functions to read data from IPFS node

* fix: Ensure IPFS client is initialized before pinning CID

* feat: Add AddFile and AddFolder methods

* feat: add IPFS file system abstraction

* feat: Implement IPFS file, location, and filesystem abstractions

* refactor: remove unused functions and types

* refactor: remove unused FileSystem interface

* feat: add initial wasm entrypoint

* feat: add basic vault command operations

* docs: add vault module features

* test: remove test for MsgUpdateParams

* refactor: Replace PrimaryKey with Property struct in zkprop.go

* feat: Update the `CreateWitness` and `CreateAccumulator` and `VerifyWitness` and `UpdateAccumulator` to Use the new `Accumulator` and `Witness` types. Then Clean up the code in the file and refactor the marshalling methods

* <no value>

* feat: add KeyCurve and KeyType to KeyInfo in genesis

* feat: add WASM build step to devbox.json

* feat: Add zkgate.go file

* feat: Uncomment and modify zkgate code to work with Property struct

* feat: Merge zkgate.go and zkprop.go logic

* feat: implement API endpoints for profile management

* refactor: remove unused template file

* feat(orm): remove unused ORM models

* feat: add persistent SQLite database support in WASM

* fix: Update module names in protobuf files

* feat: Add method to initialize SQLite database

* fix: update go-sqlite3 dependency to version 1.14.23

* feat: introduce database layer

* feat: Implement database layer for Vault node

* feature/update-dockerfile

* feat: Add keyshares table

* fix: Reorder the SQL statements in the tables.go file

* feat: Update the `createCredentialsTable` method to match the proper Credential struct

* feat: Update createProfilesTable and add createPropertiesTable

* feat: Add constant SQL queries to queries.go and use prepared statements in db.go

* feat: Add createKeysharesTable to internal/db/db.go

* feat: Update `createPermissionsTable` to match Permissions struct

* feat: Add database enum types

* feat: Add DIDNamespace and PermissionScope enums

* feat: Add DBConfig and DBOption types

* feat: Update the db implementation to use the provided go library

* fix: update db implementation to use go-sqlite3 v0.18.2

* fix: Refactor database connection and statement handling

* feat: Simplify db.go implementation

* feat: Convert constant SQL queries to functions in queries.go and update db.go to use prepared statements

* feat: Add models.go file with database table structs

* fix: Remove unused statement map and prepare statements

diff --git a/internal/db/db.go b/internal/db/db.go
index 201d09b..d4d4d4e 100644
--- a/internal/db/db.go
+++ b/internal/db/db.go
@@ -32,11 +32,6 @@ func Open(config *DBConfig) (*DB, error) {
 		Conn: conn,
 	}

-	if err := createTables(db); err != nil {
-		conn.Close()
-		return nil, fmt.Errorf("failed to create tables: %w", err)
-	}
-
 	return db, nil
 }

@@ -61,114 +56,3 @@ func createTables(db *DB) error {
 	return nil
 }

-// AddAccount adds a new account to the database
-func (db *DB) AddAccount(name, address string) error {
-	return db.Exec(insertAccountQuery(name, address))
-}
-
-// AddAsset adds a new asset to the database
-func (db *DB) AddAsset(name, symbol string, decimals int, chainID int64) error {
-	return db.Exec(insertAssetQuery(name, symbol, decimals, chainID))
-}
-
-// AddChain adds a new chain to the database
-func (db *DB) AddChain(name, networkID string) error {
-	return db.Exec(insertChainQuery(name, networkID))
-}
-
-// AddCredential adds a new credential to the database
-func (db *DB) AddCredential(
-	handle, controller, attestationType, origin string,
-	credentialID, publicKey []byte,
-	transport string,
-	signCount uint32,
-	userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) error {
-	return db.Exec(insertCredentialQuery(
-		handle,
-		controller,
-		attestationType,
-		origin,
-		credentialID,
-		publicKey,
-		transport,
-		signCount,
-		userPresent,
-		userVerified,
-		backupEligible,
-		backupState,
-		cloneWarning,
-	))
-}
-
-// AddProfile adds a new profile to the database
-func (db *DB) AddProfile(
-	id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) error {
-	return db.statements["insertProfile"].Exec(
-		id, subject, controller, originURI, publicMetadata, privateMetadata,
-	)
-}
-
-// AddProperty adds a new property to the database
-func (db *DB) AddProperty(
-	profileID, key, accumulator, propertyKey string,
-) error {
-	return db.statements["insertProperty"].Exec(
-		profileID, key, accumulator, propertyKey,
-	)
-}
-
-// AddPermission adds a new permission to the database
-func (db *DB) AddPermission(
-	serviceID string,
-	grants []DIDNamespace,
-	scopes []PermissionScope,
-) error {
-	grantsJSON, err := json.Marshal(grants)
-	if err != nil {
-		return fmt.Errorf("failed to marshal grants: %w", err)
-	}
-
-	scopesJSON, err := json.Marshal(scopes)
-	if err != nil {
-		return fmt.Errorf("failed to marshal scopes: %w", err)
-	}
-
-	return db.statements["insertPermission"].Exec(
-		serviceID, string(grantsJSON), string(scopesJSON),
-	)
-}
-
-// GetPermission retrieves the permission for the given service ID
-func (db *DB) GetPermission(serviceID string) ([]DIDNamespace, []PermissionScope, error) {
-	row := db.statements["getPermission"].QueryRow(serviceID)
-
-	var grantsJSON, scopesJSON string
-	if err := row.Scan(&grantsJSON, &scopesJSON); err != nil {
-		return nil, nil, fmt.Errorf("failed to get permission: %w", err)
-	}
-
-	var grants []DIDNamespace
-	if err := json.Unmarshal([]byte(grantsJSON), &grants); err != nil {
-		return nil, nil, fmt.Errorf("failed to unmarshal grants: %w", err)
-	}
-
-	var scopes []PermissionScope
-	if err := json.Unmarshal([]byte(scopesJSON), &scopes); err != nil {
-		return nil, nil, fmt.Errorf("failed to unmarshal scopes: %w", err)
-	}
-
-	return grants, scopes, nil
-}
-
-// Close closes the database connection and finalizes all prepared statements
-func (db *DB) Close() error {
-	for _, stmt := range db.statements {
-		stmt.Finalize()
-	}
-	return db.Conn.Close()
-}
diff --git a/internal/db/queries.go b/internal/db/queries.go
index 807d701..e69de29 100644
--- a/internal/db/queries.go
+++ b/internal/db/queries.go
@@ -1,79 +0,0 @@
-package db
-
-import "fmt"
-
-// Account queries
-func insertAccountQuery(name, address string) string {
-	return fmt.Sprintf(`INSERT INTO accounts (name, address) VALUES (%s, %s)`, name, address)
-}
-
-// Asset queries
-func insertAssetQuery(name, symbol string, decimals int, chainID int64) string {
-	return fmt.Sprintf(
-		`INSERT INTO assets (name, symbol, decimals, chain_id) VALUES (%s, %s, %d, %d)`,
-		name,
-		symbol,
-		decimals,
-		chainID,
-	)
-}
-
-// Chain queries
-func insertChainQuery(name string, networkID string) string {
-	return fmt.Sprintf(`INSERT INTO chains (name, network_id) VALUES (%s, %d)`, name, networkID)
-}
-
-// Credential queries
-func insertCredentialQuery(
-	handle, controller, attestationType, origin string,
-	credentialID, publicKey []byte,
-	transport string,
-	signCount uint32,
-	userPresent, userVerified, backupEligible, backupState, cloneWarning bool,
-) string {
-	return fmt.Sprintf(`INSERT INTO credentials (
-		handle, controller, attestation_type, origin,
-		credential_id, public_key, transport, sign_count,
-		user_present, user_verified, backup_eligible,
-		backup_state, clone_warning
-	) VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %t, %t, %t, %t, %t)`,
-		handle, controller, attestationType, origin,
-		credentialID, publicKey, transport, signCount,
-		userPresent, userVerified, backupEligible,
-		backupState, cloneWarning)
-}
-
-// Profile queries
-func insertProfileQuery(
-	id, subject, controller, originURI, publicMetadata, privateMetadata string,
-) string {
-	return fmt.Sprintf(`INSERT INTO profiles (
-		id, subject, controller, origin_uri,
-		public_metadata, private_metadata
-	) VALUES (%s, %s, %s, %s, %s, %s)`,
-		id, subject, controller, originURI,
-		publicMetadata, privateMetadata)
-}
-
-// Property queries
-func insertPropertyQuery(profileID, key, accumulator, propertyKey string) string {
-	return fmt.Sprintf(`INSERT INTO properties (
-		profile_id, key, accumulator, property_key
-	) VALUES (%s, %s, %s, %s)`,
-		profileID, key, accumulator, propertyKey)
-}
-
-// Permission queries
-func insertPermissionQuery(serviceID, grants, scopes string) string {
-	return fmt.Sprintf(
-		`INSERT INTO permissions (service_id, grants, scopes) VALUES (%s, %s, %s)`,
-		serviceID,
-		grants,
-		scopes,
-	)
-}
-
-// GetPermission query
-func getPermissionQuery(serviceID string) string {
-	return fmt.Sprintf(`SELECT grants, scopes FROM permissions WHERE service_id = %s`, serviceID)
-}

* fix: update Makefile to use sonrd instead of wasmd

* feat: Add targets for templ and vault in Makefile and use only make in devbox.json

* feat: add SQLite database support

* bump: version 0.6.0 → 0.7.0

* refactor: upgrade actions to latest versions
This commit is contained in:
Prad Nukala
2024-09-05 01:24:57 -04:00
committed by GitHub
parent fd82cf4f3d
commit 8010e6b069
123 changed files with 24666 additions and 14591 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/onsonr/hway/api
default: github.com/onsonr/sonr/api
except:
- buf.build/googleapis/googleapis
- buf.build/cosmos/gogo-proto
+1 -1
View File
@@ -1,5 +1,5 @@
version: v1
name: buf.build/didao/sonr
name: buf.build/onsonr/sonr
deps:
- buf.build/cosmos/cosmos-sdk:9000fcc585a046c9881271d53dd40c34
- buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31
+2 -2
View File
@@ -1,6 +1,6 @@
syntax = "proto3";
package onsonr.hway.did.module.v1;
package onsonr.sonr.did.module.v1;
import "cosmos/app/v1alpha1/module.proto";
@@ -8,6 +8,6 @@ import "cosmos/app/v1alpha1/module.proto";
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import : "github.com/onsonr/hway"
go_import : "github.com/onsonr/sonr"
};
}
+1 -1
View File
@@ -1,7 +1,7 @@
syntax = "proto3";
package did.v1;
option go_package = "github.com/onsonr/hway/x/did/types";
option go_package = "github.com/onsonr/sonr/x/did/types";
message BtcAccount {}
+101
View File
@@ -0,0 +1,101 @@
syntax = "proto3";
package did.v1;
option go_package = "github.com/onsonr/sonr/x/did/types";
// 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;
}
// 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_BLS12377 = 6;
KEY_ALGORITHM_KECCAK256 = 7;
}
// KeyCurve defines the key curve
enum KeyCurve {
KEY_CURVE_UNSPECIFIED = 0;
KEY_CURVE_P256 = 1;
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;
}
// KeyEncoding defines the key encoding
enum KeyEncoding {
KEY_ENCODING_UNSPECIFIED = 0;
KEY_ENCODING_RAW = 1;
KEY_ENCODING_HEX = 2;
KEY_ENCODING_MULTIBASE = 3;
KEY_ENCODING_JWK = 4;
}
// KeyRole defines the kind of key
enum KeyRole {
KEY_ROLE_UNSPECIFIED = 0;
// Blockchain key types
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;
}
// PermissionScope define the Capabilities Controllers can grant for Services
enum PermissionScope {
PERMISSION_SCOPE_UNSPECIFIED = 0;
PERMISSION_SCOPE_BASIC_INFO = 1;
PERMISSION_SCOPE_RECORDS_READ = 2;
PERMISSION_SCOPE_RECORDS_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;
}
+73 -90
View File
@@ -1,10 +1,11 @@
syntax = "proto3";
package did.v1;
import "gogoproto/gogo.proto";
import "amino/amino.proto";
import "did/v1/constants.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/hway/x/did/types";
option go_package = "github.com/onsonr/sonr/x/did/types";
// GenesisState defines the module genesis state
message GenesisState {
@@ -18,7 +19,7 @@ message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
// Whitelisted Assets
// Whitelisted Assets
repeated AssetInfo whitelisted_assets = 1;
// Whitelisted Blockchains
@@ -27,117 +28,99 @@ message Params {
// Whitelisted Key Types
repeated KeyInfo allowed_public_keys = 3;
// Whitlested Validator nodes with Public DID Resolvers
repeated ValidatorInfo public_validators = 4;
// OpenIDConfig defines the base openid configuration across all did services
OpenIDConfig openid_config = 4;
}
// AssetInfo defines the asset info
message AssetInfo {
string id = 1;
string denom = 2;
string symbol = 3;
string asset_type = 4;
string origin_chain = 5;
string origin_denom = 6;
int32 decimals = 7;
string description = 8;
string image_url = 9;
string coingecko_id = 10;
bool is_enabled = 11;
string ibc_path = 12;
string ibc_channel = 13;
string ibc_port = 14;
// 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
AssetType asset_type = 4;
// The name of the asset
string name = 5;
// The Method of the did namespace
string method = 6;
// The icon url
string icon_url = 7;
}
// ChainInfo defines the chain info
message ChainInfo {
string id = 1;
string chain_id = 2;
string name = 3;
string symbol = 4;
string bech32_prefix = 5;
string genesis_time = 6;
}
string id = 1;
string chain_id = 2;
string name = 3;
string symbol = 4;
repeated ValidatorInfo validators = 5;
}
// KeyInfo defines information for accepted PubKey types
message KeyInfo {
KeyType kind = 1;
string algorithm = 2; // e.g., "ES256", "EdDSA", "ES256K"
string curve = 3; // e.g., "P-256", "Ed25519", "secp256k1"
string encoding = 4; // e.g., "hex", "base64", "multibase"
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"
}
// OpenIDConfig defines the base openid configuration across all did services
message OpenIDConfig {
string issuer = 1;
string authorization_endpoint = 2;
string token_endpoint = 3;
string userinfo_endpoint = 4;
repeated string scopes_supported = 5;
repeated string response_types_supported = 6;
repeated string response_modes_supported = 7;
repeated string grant_types_supported = 8;
repeated string acr_values_supported = 9;
repeated string subject_types_supported = 10;
}
// ValidatorInfo defines information for accepted Validator nodes
message ValidatorInfo {
repeated Endpoint grpc_endpoints = 5;
repeated Endpoint rest_endpoints = 6;
ExplorerInfo explorer = 7;
FeeInfo fee_info = 8;
string moniker = 1;
repeated Endpoint grpc_endpoints = 2;
repeated Endpoint rest_endpoints = 3;
ExplorerInfo explorer = 4;
FeeInfo fee_info = 5;
IBCChannel ibc_channel = 6;
// Endpoint defines an endpoint
message Endpoint {
string url = 1;
bool is_primary = 2;
string url = 1;
bool is_primary = 2;
}
// ExplorerInfo defines the explorer info
message ExplorerInfo {
string name = 1;
string url = 2;
string name = 1;
string url = 2;
}
// FeeInfo defines a fee info
message FeeInfo {
string base_denom = 1;
repeated string fee_rates = 2;
int32 init_gas_limit = 3;
bool is_simulable = 4;
double gas_multiply = 5;
string base_denom = 1;
repeated string fee_rates = 2;
int32 init_gas_limit = 3;
bool is_simulable = 4;
double gas_multiply = 5;
}
// IBCChannel defines the IBC channel info
message IBCChannel {
string id = 1;
string port = 2;
}
}
// 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;
}
// KeyKTind defines the kind of key
enum KeyType {
KEY_TYPE_UNSPECIFIED = 0;
// Blockchain key types
KEY_TYPE_SECP256K1 = 1; // cross-chain
KEY_TYPE_ED25519 = 2; // validators
KEY_TYPE_KECCAK = 3; // ethereum addresses
KEY_TYPE_BLS12381 = 4; // zero-knowledge
KEY_TYPE_X25519 = 5; // multisig
KEY_TYPE_SCHNORR = 6; // mpc
// Webauthn and FIDO key types
KEY_TYPE_WEBAUTHN = 7; // passkey authentication
KEY_TYPE_FIDO = 8; // fido2 authentication
}
// PermissionScope define the Capabilities Controllers can grant for Services
enum PermissionScope {
PERMISSION_SCOPE_UNSPECIFIED = 0;
PERMISSION_SCOPE_BASIC_INFO = 1;
PERMISSION_SCOPE_RECORDS_READ = 2;
PERMISSION_SCOPE_RECORDS_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;
}
+50 -19
View File
@@ -2,17 +2,15 @@ syntax = "proto3";
package did.v1;
import "did/v1/constants.proto";
import "did/v1/genesis.proto";
import "gogoproto/gogo.proto";
option go_package = "github.com/onsonr/hway/x/did/types";
option go_package = "github.com/onsonr/sonr/x/did/types";
// DID defines a parsed DID string
message DID {
string id = 1;
DIDNamespace method = 2;
string network = 3;
string identifier = 4;
repeated string paths = 5;
// Accumulator defines a BLS accumulator
message Accumulator {
bytes accumulator = 1;
}
// Credential defines a WebAuthn credential
@@ -23,7 +21,16 @@ message Credential {
repeated string transport = 4;
string subject = 6;
string controller = 7;
}
}
// DID defines a parsed DID string
message DID {
DIDNamespace method = 1;
string network = 2;
string subject = 3;
string identifier = 4;
repeated string paths = 5;
}
// Document defines a DID document
message Document {
@@ -33,6 +40,7 @@ message Document {
repeated string assertion_method = 5;
repeated string capability_delegation = 7;
repeated string capability_invocation = 8;
repeated string service = 9;
}
// Metadata defines additional information provided to a did
@@ -42,7 +50,7 @@ message Metadata {
map<string, Property> private = 3;
}
// Permissions contains a list of grants and access control rules for
// Permissions contains a list of grants and access control rules for
// a Service.
message Permissions {
repeated DIDNamespace grants = 1;
@@ -54,9 +62,7 @@ message Profile {
string id = 1;
string subject = 2;
string controller = 3;
repeated Credential credentials = 4;
repeated VerificationMethod attestations = 5;
Metadata metadata = 6;
Metadata metadata = 4;
}
// Property defines a Zero-Knowledge accumulator which can be used to
@@ -68,17 +74,42 @@ message Property {
// PubKey defines a public key for a did
message PubKey {
DIDNamespace namespace = 1;
bytes key = 2;
KeyType kind = 3;
string multibase = 5;
map<string, string> jwks = 6;
KeyRole role = 1;
KeyAlgorithm algorithm = 2;
KeyEncoding encoding = 3;
bytes raw = 4;
string hex = 5;
string multibase = 6;
map<string, string> jwk = 7;
}
// Service defines a Decentralized Service on the Sonr Blockchain
message Service {
string id = 1;
string controller = 2;
string origin = 3;
Permissions permissions = 4;
OpenIDConfig openid = 5;
Metadata metadata = 6;
}
// Token defines a macron token
message Token {
string id = 1;
string controller = 2;
bytes macron = 3;
}
// VerificationMethod defines a verification method
message VerificationMethod {
string id = 1;
string controller = 2;
PubKey public_key = 3;
DIDNamespace method = 3;
PubKey public_key = 4;
Service service = 7;
}
// Witness defines a BLS witness
message Witness {
bytes witness = 1;
}
+48 -66
View File
@@ -1,47 +1,52 @@
syntax = "proto3";
package did.v1;
import "google/api/annotations.proto";
import "did/v1/genesis.proto";
import "did/v1/models.proto";
import "google/api/annotations.proto";
option go_package = "github.com/onsonr/hway/x/did/types";
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(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/did/params";
}
// Params queries all parameters of the module.
rpc Params(QueryRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/did/params";
}
// Accounts returns associated wallet accounts with the DID.
rpc Accounts(QueryAccountsRequest) returns (QueryAccountsResponse) {
option (google.api.http).get = "/did/{did}/accounts";
}
// Accounts returns associated wallet accounts with the DID.
rpc Accounts(QueryRequest) returns (QueryAccountsResponse) {
option (google.api.http).get = "/did/{did}/accounts";
}
// Credentials returns associated credentials with the DID and Service Origin.
rpc Credentials(QueryCredentialsRequest) returns (QueryCredentialsResponse) {
option (google.api.http).get = "/did/{did}/{origin}/credentials";
}
// Credentials returns associated credentials with the DID and Service Origin.
rpc Credentials(QueryRequest) returns (QueryCredentialsResponse) {
option (google.api.http).get = "/service/{origin}/{subject}/credentials";
}
// Identities returns associated identity with the DID.
rpc Identities(QueryIdentitiesRequest) returns (QueryIdentitiesResponse) {
option (google.api.http).get = "/did/{did}/identities";
}
// Resolve queries the DID document by its id.
rpc Resolve(QueryRequest) returns (QueryResolveResponse) {
option (google.api.http).get = "/did/{did}";
}
// Resolve queries the DID document by its id.
rpc Resolve(QueryResolveRequest) returns (QueryResolveResponse) {
option (google.api.http).get = "/did/resolve/{did}";
}
// Service returns associated ServiceInfo for a given Origin
rpc Service(QueryRequest) returns (QueryServiceResponse) {
option (google.api.http).get = "/service/{origin}";
}
// Service returns associated ServiceInfo for a given Origin
rpc Service(QueryServiceRequest) returns (QueryServiceResponse) {
option (google.api.http).get = "/did/service/{origin}";
}
// Token returns the current authentication token for the client.
rpc Token(QueryRequest) returns (QueryTokenResponse) {
option (google.api.http).post = "/token";
}
}
// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}
// Queryequest is the request type for the Query/Params RPC method.
message QueryRequest {
string did = 1;
string origin = 2;
string subject = 3;
repeated Credential credentials = 4;
}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
@@ -49,57 +54,34 @@ message QueryParamsResponse {
Params params = 1;
}
// QueryAccountsRequest is the request type for the Query/Exists RPC method.
message QueryAccountsRequest {
string did = 1;
}
// QueryAccountsResponse is the response type for the Query/Exists RPC method.
message QueryAccountsResponse {
bool exists = 1;
}
// QueryCredentialsRequest is the request type for the Query/Exists RPC method.
message QueryCredentialsRequest {
string did = 1;
string origin = 2;
bool exists = 1;
}
// QueryCredentialsResponse is the response type for the Query/Exists RPC method.
message QueryCredentialsResponse {
map<string, bytes> credentials = 1;
}
// QueryIdentitiesRequest is the request type for the Query/Exists RPC method.
message QueryIdentitiesRequest {
string did = 1;
}
// QueryIdentitiesResponse is the response type for the Query/Exists RPC method.
message QueryIdentitiesResponse {
bool exists = 1;
repeated VerificationMethod verificationMethod = 2;
}
// QueryResolveRequest is the request type for the Query/Resolve RPC method.
message QueryResolveRequest {
string did = 1;
bool success = 1;
string subject = 2;
string origin = 3;
repeated Credential credentials = 4;
string error = 5;
}
// QueryResolveResponse is the response type for the Query/Resolve RPC method.
message QueryResolveResponse {
// document is the DID document
Document document = 1;
}
// QueryServiceRequest is the request type for the Query/LoginOptions RPC method.
message QueryServiceRequest {
string origin = 1;
// document is the DID document
Document document = 1;
}
// QueryLoginOptionsResponse is the response type for the Query/LoginOptions RPC method.
message QueryServiceResponse {
// options is the PublicKeyCredentialAttestationOptions
string options = 1;
Service service = 1;
}
// QueryTokenResponse is the response type for the Query/LoginOptions RPC method.
message QueryTokenResponse {
bool success = 1;
Token token = 2;
string error = 3;
}
+98 -14
View File
@@ -2,17 +2,32 @@ syntax = "proto3";
package did.v1;
option go_package = "github.com/onsonr/hway/x/did/types";
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";
// Assertion represents strongly created credentials (e.g., Passkeys, SSH, GPG, Native Secure Enclaave)
message Assertion {
option (cosmos.orm.v1.table) = {
id: 1
id: 1
primary_key: {fields: "id"}
index: {
id: 1
fields: "subject,origin"
unique: true
}
index: {
id: 2
fields: "controller,origin"
unique: true
}
index: {
id: 3
fields: "controller,credential_label"
unique: true
}
};
// The unique identifier of the attestation
@@ -27,8 +42,17 @@ message Assertion {
// The value of the linked identifier
bytes credential_id = 4;
// The display label of the attestation
string credential_label = 5;
// The origin of the attestation
string origin = 6;
// The subject of the attestation
string subject = 7;
// Metadata is optional additional information about the assertion
Metadata metadata = 5;
Metadata metadata = 8;
}
// Attestation represents linked identifiers (e.g., Crypto Accounts, Github, Email, Phone)
@@ -36,7 +60,16 @@ message Attestation {
option (cosmos.orm.v1.table) = {
id: 2
primary_key: {fields: "id"}
index: { id: 1, fields: "subject,origin", unique: true }
index: {
id: 1
fields: "subject,origin"
unique: true
}
index: {
id: 2
fields: "controller,origin"
unique: true
}
};
// The unique identifier of the attestation
@@ -58,12 +91,21 @@ message Attestation {
Metadata metadata = 6;
}
// Controller represents a Sonr DWN Vault
message Controller {
option (cosmos.orm.v1.table) = {
id: 3
primary_key: {fields: "id"}
index: {
id: 1
fields: "address"
unique: true
}
index: {
id: 2
fields: "vault_cid"
unique: true
}
};
// The unique identifier of the controller
@@ -72,8 +114,11 @@ message Controller {
// The DID of the controller
string address = 2;
// Aliases of the controller
repeated string aliases = 3;
// PubKey is the verification method
PubKey public_key = 4;
PubKey public_key = 4;
// The vault address or identifier
string vault_cid = 5;
@@ -84,6 +129,20 @@ message Delegation {
option (cosmos.orm.v1.table) = {
id: 4
primary_key: {fields: "id"}
index: {
id: 1
fields: "account_address,chain_id"
unique: true
}
index: {
id: 2
fields: "controller,account_label"
unique: true
}
index: {
id: 3
fields: "controller,chain_id"
}
};
// The unique identifier of the delegation
@@ -93,17 +152,36 @@ message Delegation {
string controller = 2;
// Resolved from module parameters
string chain_info_id = 3;
string chain_index = 3;
// The delegation proof or verification method
PubKey public_key = 4;
PubKey public_key = 4;
// The Account Address
string account_address = 5;
// The Account label
string account_label = 6;
// The Chain ID
string chain_id = 7;
}
// Service represents a service in a DID Document
message Service {
// ServiceRecord represents a decentralized service in a DID Document
message ServiceRecord {
option (cosmos.orm.v1.table) = {
id: 5
primary_key: {fields: "id"}
index: {
id: 1
fields: "origin_uri"
unique: true
}
index: {
id: 2
fields: "controller,origin_uri"
unique: true
}
};
// The ID of the service
@@ -113,14 +191,20 @@ message Service {
string service_type = 2;
// The controller DID of the service
string controller_did = 3;
string controller = 3;
// The domain name of the service
string origin_uri = 4;
// The description of the service
string description = 5;
// The service endpoint
map<string, string> service_endpoints = 5;
map<string, string> service_endpoints = 6;
// Scopes is the Authorization Grants of the service
Permissions permissions = 6;
Permissions permissions = 7;
// Metadata is optional additional information about the service
Metadata metadata = 8;
}
+120 -68
View File
@@ -3,34 +3,37 @@ syntax = "proto3";
package did.v1;
import "cosmos/msg/v1/msg.proto";
import "did/v1/models.proto";
import "did/v1/genesis.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
option go_package = "github.com/onsonr/hway/x/did/types";
import "did/v1/constants.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";
// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
option (cosmos.msg.v1.service) = true;
// UpdateParams defines a governance operation for updating the parameters.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
// Authenticate asserts the given controller is the owner of the given address.
rpc Authenticate(MsgAuthenticate) returns (MsgAuthenticateResponse);
// Authorize asserts the given controller is the owner of the given address.
rpc Authorize(MsgAuthorize) returns (MsgAuthorizeResponse);
// ProveWitness is an operation to prove the controller has a valid property using ZK Accumulators.
rpc ProveWitness(MsgProveWitness) returns (MsgProveWitnessResponse);
// AllocateVault assembles a sqlite3 database in a local directory and returns the CID of the database.
// this operation is called by services initiating a controller registration.
rpc AllocateVault(MsgAllocateVault) returns (MsgAllocateVaultResponse);
// SyncVault synchronizes the controller with the Vault Motr DWN WASM Wallet.
rpc SyncVault(MsgSyncVault) returns (MsgSyncVaultResponse);
// SyncVault synchronizes the controller with the Vault Motr DWN WASM Wallet.
rpc SyncVault(MsgSyncVault) returns (MsgSyncVaultResponse);
// RegisterController initializes a controller with the given authentication set, address, cid, publicKey, and user-defined alias.
rpc RegisterController(MsgRegisterController) returns (MsgRegisterControllerResponse);
// RegisterController initializes a controller with the given authentication set, address, cid, publicKey, and user-defined alias.
rpc RegisterController(MsgRegisterController) returns (MsgRegisterControllerResponse);
// RegisterService initializes a Service with a given permission scope and URI. The domain must have a valid TXT record containing the public key.
rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse);
// RegisterService initializes a Service with a given permission scope and URI. The domain must have a valid TXT record containing the public key.
rpc RegisterService(MsgRegisterService) returns (MsgRegisterServiceResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
@@ -43,9 +46,10 @@ message MsgUpdateParams {
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];
// token is the macron token to authenticate the operation.
Token token = 3;
}
// MsgUpdateParamsResponse defines the response structure for executing a
@@ -54,25 +58,28 @@ message MsgUpdateParams {
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}
// MsgAuthenticate is the message type for the Authenticate RPC.
message MsgAuthenticate {
option (cosmos.msg.v1.signer) = "authority";
// MsgAllocateVault is the message type for the AllocateVault RPC.
message MsgAllocateVault {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// authority is the address of the service account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Controller is the address of the controller to authenticate.
string controller = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// subject is a unique human-defined identifier to associate with the vault.
string subject = 2;
// Address is the address to authenticate.
string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Origin is the origin of the request in wildcard form.
string origin = 4;
// token is the macron token to authenticate the operation.
Token token = 3;
}
// MsgAuthenticateResponse is the response type for the Authenticate RPC.
message MsgAuthenticateResponse {}
// MsgAllocateVaultResponse is the response type for the AllocateVault RPC.
message MsgAllocateVaultResponse {
// CID is the content identifier of the vault.
string cid = 1;
// ExpiryBlock is the block number at which the vault will expire.
int64 expiry_block = 2;
}
// MsgProveWitness is the message type for the ProveWitness RPC.
message MsgProveWitness {
@@ -86,6 +93,9 @@ message MsgProveWitness {
// Witness Value is the bytes of the witness.
bytes witness = 3;
// token is the macron token to authenticate the operation.
Token token = 4;
}
// MsgProveWitnessResponse is the response type for the ProveWitness RPC.
@@ -100,12 +110,9 @@ message MsgSyncVault {
// controller is the address of the controller to sync.
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// cid is the IPFS content identifier.
string cid = 2;
// Macroon is the public token to authenticate the operation.
bytes macron = 3;
// Token is the public token to authenticate the operation.
Token token = 3;
}
// MsgSyncVaultResponse is the response type for the SyncVault RPC.
@@ -115,45 +122,90 @@ message MsgSyncVaultResponse {
// MsgRegisterController is the message type for the InitializeController RPC.
message MsgRegisterController {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Assertions is the list of assertions to initialize the controller with.
string cid = 2;
// Keyshares is the list of keyshares to initialize the controller with.
repeated bytes keyshares = 3;
// Verifications is the list of verifications to initialize the controller with.
repeated bytes verifications = 4;
}
// MsgRegisterControllerResponse is the response type for the InitializeController RPC.
message MsgRegisterControllerResponse {
// Controller is the address of the initialized controller.
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Accounts are a Address Map and Supported coin Denoms for the controller
map<string, string> accounts = 2;
}
// MsgRegisterService is the message type for the RegisterService RPC.
message MsgRegisterService {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Assertions is the list of assertions to initialize the controller with.
string cid = 2;
// Origin is the origin of the request in wildcard form.
string origin = 3;
// Credential is the list of keyshares to initialize the controller with.
repeated Credential authentication = 4;
// token is the macron token to authenticate the operation.
Token token = 5;
}
// MsgRegisterControllerResponse is the response type for the InitializeController RPC.
message MsgRegisterControllerResponse {
// Success returns true if the specified cid is valid and not already encrypted.
bool success = 1;
// Controller is the address of the initialized controller.
string controller = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Accounts are a Address Map and Supported coin Denoms for the controller
map<string, string> accounts = 3;
}
// MsgAuthorize is the message type for the Authorize RPC.
message MsgAuthorize {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Controller is the address of the controller to authenticate.
string controller = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Address is the address to authenticate.
string address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Origin is the origin of the request in wildcard form.
string origin = 4;
// token is the macron token to authenticate the operation.
Token token = 5;
}
// MsgAuthorizeResponse is the response type for the Authorize RPC.
message MsgAuthorizeResponse {
bool success = 1;
Token token = 2;
}
// MsgRegisterService is the message type for the RegisterService RPC.
message MsgRegisterService {
option (cosmos.msg.v1.signer) = "controller";
// authority is the address of the governance account.
string controller = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// origin is the origin of the request in wildcard form.
string origin_uri = 2;
// PermissionScope is the scope of the service.
repeated PermissionScope scopes = 3;
// Permissions is the scope of the service.
Permissions scopes = 3;
// Description is the description of the service
string description = 4;
// service_endpoints is the endpoints of the service
map<string, string> service_endpoints = 5;
// Metadata is optional additional information about the service
Metadata metadata = 6;
// token is the macron token to authenticate the operation.
Token token = 7;
}
// MsgRegisterServiceResponse is the response type for the RegisterService RPC.
message MsgRegisterServiceResponse {
bool success = 1;
string did = 2;
}
+2 -2
View File
@@ -1,6 +1,6 @@
syntax = "proto3";
package onsonr.hway.oracle.module.v1;
package onsonr.sonr.oracle.module.v1;
import "cosmos/app/v1alpha1/module.proto";
@@ -8,6 +8,6 @@ import "cosmos/app/v1alpha1/module.proto";
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
message Module {
option (cosmos.app.v1alpha1.module) = {
go_import : "github.com/onsonr/hway"
go_import : "github.com/onsonr/sonr"
};
}
+1 -1
View File
@@ -2,7 +2,7 @@ syntax = "proto3";
package oracle.v1;
option go_package = "github.com/onsonr/hway/x/oracle/types";
option go_package = "github.com/onsonr/sonr/x/oracle/types";
import "gogoproto/gogo.proto";
+2 -2
View File
@@ -2,6 +2,6 @@ syntax = "proto3";
package oracle.v1;
option go_package = "github.com/onsonr/hway/x/oracle/types";
option go_package = "github.com/onsonr/sonr/x/oracle/types";
import "gogoproto/gogo.proto";
import "gogoproto/gogo.proto";
+2 -2
View File
@@ -2,6 +2,6 @@ syntax = "proto3";
package oracle.v1;
option go_package = "github.com/onsonr/hway/x/oracle/types";
option go_package = "github.com/onsonr/sonr/x/oracle/types";
import "gogoproto/gogo.proto";
import "gogoproto/gogo.proto";