Skip to content

Commit

Permalink
feat: remove net prefix from did doc id
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddyMc authored and noandrea committed Mar 30, 2022
1 parent 1ff3530 commit 241bfa7
Show file tree
Hide file tree
Showing 18 changed files with 542 additions and 537 deletions.
5 changes: 2 additions & 3 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# For further details check https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners
# default owners
* @allinbits/cosmoscashteam
* @elesto-dao/elesto-core

# add member of the technical writing team for docs
# here pattern matches on any docs folder in the repo
# docs/ @allinbits/cosmoscash @barriebyron

# docs/ @elesto-dao/elesto-core @barriebyron
14 changes: 13 additions & 1 deletion app/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func init() {
simapp.GetSimulatorFlags()
}

// fauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of
// an IAVLStore for faster simulation speed.
func fauxMerkleModeOpt(bapp *baseapp.BaseApp) {
bapp.SetFauxMerkleMode()
}

type SimApp interface {
cosmoscmd.App
GetBaseApp() *baseapp.BaseApp
Expand Down Expand Up @@ -112,6 +118,7 @@ func TestFullAppSimulation(t *testing.T) {
0,
encoding,
simapp.EmptyAppOptions{},
fauxMerkleModeOpt,
)

simApp, ok := app.(SimApp)
Expand Down Expand Up @@ -174,6 +181,7 @@ func BenchmarkFullAppSimulation(b *testing.B) {
0,
encoding,
simapp.EmptyAppOptions{},
fauxMerkleModeOpt,
)

simApp, ok := app.(SimApp)
Expand Down Expand Up @@ -231,6 +239,7 @@ func TestAppSimulationAfterImport(t *testing.T) {
0,
encoding,
simapp.EmptyAppOptions{},
fauxMerkleModeOpt,
)
simApp1, ok := app1.(SimApp)
require.True(t, ok, "can't use simapp")
Expand Down Expand Up @@ -279,10 +288,12 @@ func TestAppSimulationAfterImport(t *testing.T) {
true,
map[int64]bool{},
app.DefaultNodeHome,
0,
1,
encoding,
simapp.EmptyAppOptions{},
fauxMerkleModeOpt,
)

simApp2, ok := newApp.(SimApp)
require.True(t, ok, "can't use simapp")

Expand Down Expand Up @@ -354,6 +365,7 @@ func TestAppStateDeterminism(t *testing.T) {
0,
encoding,
simapp.EmptyAppOptions{},
fauxMerkleModeOpt,
)
simApp, ok := app.(SimApp)
require.True(t, ok, "can't use simapp")
Expand Down
17 changes: 8 additions & 9 deletions docs/Explanation/ADR/adr-003-did.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,26 @@ The namespace specific identifier is defined by the following ABNF:

```ABNF
cosmos-did = "did:cosmos:" identifier-type
identifier-type = cosmos-key / cosmos-network
identifier-type = cosmos-key / unique-identifier
cosmos-key = "key:" 1*255id-char "1" 20*255HEXDIG
cosmos-network = "net:" 1*255id-char ":" unique-identifier
unique-identifier = 38*255id-char
id-char = ALPHA / DIGIT / (ALPHA "-") / (DIGIT "-")
id-char = ALPHA / DIGIT / (ALPHA "-") / (DIGIT "-") / (ALPHA ":") / (DIGIT ":")
```

For the `unique-identifier` it is RECOMMENDED to use a UUID.

The `identifier-type` distinguishes between two DID types:

1. The `key` type, inspired from the [`did:key`](https://w3c-ccg.github.io/did-method-key/) method
2. The `net` type that identifies the DID and the originating network of the DID
2. The `unique-identifier` type that identifies the DID and the originating network of the DID

DIDs of `key` type are ephemeral and immutable. DIDs of `key` type are always generated from the Cosmos blockchain address they refer to. For example, see these DIDs of `key` type:

- `did:cosmos:key:elesto1ts9ejqg7k4ht2sm53hycty875362yqxqmt9grj`

DIDs of `net` type are persistent and mutable. DIDs of `net` type are stored in the node database and can be created and updated according to rules described in the [DID Operations](#did-operations) section. For example, see this DID of `net` type:

- `did:cosmos:net:elesto:806e557e-ecdb-4e80-ab0d-a82ad35c9ceb`
- `did:cosmos:elesto:806e557e-ecdb-4e80-ab0d-a82ad35c9ceb`


##### DID Operations
Expand Down Expand Up @@ -142,20 +141,20 @@ This example shows a DID document that was resolved using the gRPC interface:
"context": [
"https://www.w3.org/ns/did/v1"
],
"id": "did:cosmos:net:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e",
"id": "did:cosmos:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e",
"controller": [
"did:cosmos:key:cosmos1sl48sj2jjed7enrv3lzzplr9wc2f5js5tzjph8"
],
"verificationMethod": [
{
"controller": "did:cosmos:net:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e",
"id": "did:cosmos:net:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e#cosmos1x5hrv0hngmg8gls5cft7nphqs83njj25pwxpt0",
"controller": "did:cosmos:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e",
"id": "did:cosmos:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e#cosmos1x5hrv0hngmg8gls5cft7nphqs83njj25pwxpt0",
"publicKeyMultibase": "0248a5178d7a90ec187b3c3d533a4385db905f6fcdaac5026859ca5ef7b0b1c3b5",
"type": "EcdsaSecp256k1VerificationKey2019"
}
],
"authentication": [
"did:cosmos:net:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e#cosmos1x5hrv0hngmg8gls5cft7nphqs83njj25pwxpt0"
"did:cosmos:elesto:900d82bc-2bfe-45a7-ab22-a8d11773568e#cosmos1x5hrv0hngmg8gls5cft7nphqs83njj25pwxpt0"
]
},
}
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/minio/highwayhash v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
Expand Down Expand Up @@ -120,7 +119,7 @@ require (
)

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EU
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI=
filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM=
github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU=
github.com/AlecAivazis/survey/v2 v2.1.1/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk=
github.com/Antonboom/errname v0.1.4/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM=
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
Expand Down Expand Up @@ -415,6 +411,8 @@ github.com/cosmos/ibc-go v1.2.2/go.mod h1:XmYjsRFOs6Q9Cz+CSsX21icNoH27vQKb3squgn
github.com/cosmos/ibc-go/v2 v2.0.2/go.mod h1:XUmW7wmubCRhIEAGtMGS+5IjiSSmcAwihoN/yPGd6Kk=
github.com/cosmos/ibc-go/v3 v3.0.0 h1:XUNplHVS51Q2gMnTFsFsH9QJ7flsovMamnltKbEgPQ4=
github.com/cosmos/ibc-go/v3 v3.0.0/go.mod h1:Mb+1NXiPOLd+CPFlOC6BKeAUaxXlhuWenMmRiUiSmwY=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU=
github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76/go.mod h1:0mkLWIoZuQ7uBoospo5Q9zIpqq6rYCPJDSUdeCJvPM8=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY=
github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI=
Expand Down Expand Up @@ -929,6 +927,8 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -1047,7 +1047,6 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
Expand Down
16 changes: 8 additions & 8 deletions scripts/seeds/01_identifier_seeds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ elestod tx did create-did regulator \
--from regulator \
--chain-id elesto -y --broadcast-mode block

elestod query did did did:cosmos:net:elesto:regulator --output json | jq
elestod query did did did:cosmos:elesto:regulator --output json | jq

echo "Create a DID doc for the EMTi (by the validator)"
elestod tx did create-did emti --from validator \
--chain-id elesto -y --broadcast-mode block

elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Add the EMTi account verification method to the the EMTi DID doc (by the validator account)"
elestod tx did add-verification-method emti $(elestod keys show emti -p) \
--from validator \
--chain-id elesto -y --broadcast-mode block

elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Add a service to the EMTi DID doc (by the EMTi account)"
elestod tx did add-service emti service:emti-agent DIDComm "https://agents.elesto.app.beta.starport.cloud/emti" \
--from emti \
--chain-id elesto -y --broadcast-mode block

elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Adding a verification relationship from decentralized did for validator"
elestod tx did set-verification-relationship emti $(elestod keys show validator -a) --relationship assertionMethod --relationship capabilityInvocation \
--from emti \
--chain-id elesto -y --broadcast-mode block

elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Revoking verification method from decentralized did for user: validator"
elestod tx did revoke-verification-method emti $(elestod keys show validator -a) \
--from emti \
--chain-id elesto -y --broadcast-mode block

echo "Querying did"
elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Deleting service from EMTi did document (by EMTi user)"
elestod tx did delete-service emti service:emti-agent \
Expand All @@ -53,12 +53,12 @@ elestod tx did add-controller emti $(elestod keys show alice -a) \
--chain-id elesto -y --broadcast-mode block

echo "Querying did"
elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq

echo "Remove a controller from the EMTi did document (by alice user)"
elestod tx did delete-controller emti $(elestod keys show alice -a) \
--from alice \
--chain-id elesto -y --broadcast-mode block

echo "Querying did"
elestod query did did did:cosmos:net:elesto:emti --output json | jq
elestod query did did did:cosmos:elesto:emti --output json | jq
18 changes: 9 additions & 9 deletions x/did/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDidDocument() {
s.Run(tc.name, func() {
tc.malleate()
cmd := cli.GetCmdQueryIdentifer()
identifiertoquery := "did:cosmos:net:" + clientCtx.ChainID + ":" + identifier
identifiertoquery := "did:cosmos:" + clientCtx.ChainID + ":" + identifier
args := []string{
identifiertoquery,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand Down Expand Up @@ -199,7 +199,7 @@ func (s *IntegrationTestSuite) TestNewCreateDidDocumentCmd() {

//pull out the just created document
cmd = cli.GetCmdQueryIdentifer()
identifiertoquery := "did:cosmos:net:" + clientCtx.ChainID + ":" + tc.args[0]
identifiertoquery := "did:cosmos:" + clientCtx.ChainID + ":" + tc.args[0]
argstemp := []string{
identifiertoquery,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
Expand Down Expand Up @@ -262,7 +262,7 @@ func (s *IntegrationTestSuite) TestNewAddControllerCmd() {
//check for update
cmd = cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier1,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier1,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -350,7 +350,7 @@ func (s *IntegrationTestSuite) TestNewDeleteControllerCmd() {
//check for update
cmd = cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier1,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier1,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -412,7 +412,7 @@ func (s *IntegrationTestSuite) TestNewAddVerificationCmd() {
//check for update
cmd = cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -471,7 +471,7 @@ func (s *IntegrationTestSuite) TestNewSetVerificationRelationshipsCmd() {
tc.malleate()
cmd := cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -544,7 +544,7 @@ func (s *IntegrationTestSuite) TestNewRevokeVerificationCmd() {
tc.malleate()
cmd := cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -629,7 +629,7 @@ func (s *IntegrationTestSuite) TestNewAddServiceCmd() {
//check for update
cmd = cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down Expand Up @@ -708,7 +708,7 @@ func (s *IntegrationTestSuite) TestNewDeleteServiceCmd() {
//check for update
cmd = cli.GetCmdQueryIdentifer()
argsTemp := []string{
"did:cosmos:net:" + clientCtx.ChainID + ":" + identifier,
"did:cosmos:" + clientCtx.ChainID + ":" + identifier,
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
}
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, argsTemp)
Expand Down
2 changes: 1 addition & 1 deletion x/did/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func GetCmdQueryIdentifer() *cobra.Command {
cmd := &cobra.Command{
Use: "did [id]",
Short: "Query for an did",
Example: "elestod query did did did:cosmos:net:elesto:bob",
Example: "elestod query did did did:cosmos:elesto:bob",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand Down
1 change: 0 additions & 1 deletion x/did/did.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ func (didDoc *DidDocument) SetVerificationRelationships(methodID string, relatio

// setRelationships overwrite relationships for a did document
func (didDoc *DidDocument) setRelationships(methodID string, relationships ...VerificationRelationship) {

// first remove existing relationships
for _, vr := range supportedRelationships {
vrs := didDoc.getRelationships(vr)
Expand Down
Loading

0 comments on commit 241bfa7

Please sign in to comment.