From aadca47de4862fff2eaf921a499ce75f392fbffc Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 30 Dec 2022 20:16:42 +0300 Subject: [PATCH 01/42] Make VerificationMethod validation as in spec --- app/migrations/helpers/protobuf.go | 19 ++++ app/migrations/helpers/protobuf_test.go | 18 ++++ app/migrations/migration_did_protobuf.go | 21 +--- tests/integration/cli_diddoc_negative_test.go | 28 +++--- .../cli_diddoc_pricing_negative_test.go | 7 +- tests/integration/cli_diddoc_pricing_test.go | 7 +- tests/integration/cli_diddoc_test.go | 6 +- .../integration/cli_resource_negative_test.go | 7 +- .../cli_resource_pricing_negative_test.go | 7 +- .../integration/cli_resource_pricing_test.go | 7 +- tests/integration/cli_resource_test.go | 10 +- .../payload/checksum/existing/v2/diddoc.json | 14 +-- .../payload/checksum/expected/v2/diddoc.json | 14 +-- .../indy_style/existing/v2/diddoc.json | 8 +- .../indy_style/existing/v2/diddoc_2.json | 8 +- .../indy_style/expected/v2/diddoc.json | 8 +- .../indy_style/expected/v2/diddoc_2.json | 8 +- .../payload/protobuf/expected/v2/diddoc.json | 8 +- .../protobuf/expected/v2/diddoc_2.json | 8 +- .../uuid/existing/v2/diddoc_lowcase.json | 8 +- .../uuid/existing/v2/diddoc_mixed.json | 8 +- .../uuid/existing/v2/diddoc_upper.json | 8 +- .../uuid/expected/v2/diddoc_lowcase.json | 8 +- .../uuid/expected/v2/diddoc_mixed.json | 8 +- .../uuid/expected/v2/diddoc_upper.json | 8 +- .../version_id/existing/v2/diddoc_hash.json | 8 +- .../version_id/expected/v2/diddoc_hash.json | 8 +- x/did/tests/create_diddoc_test.go | 30 +++--- x/did/tests/setup/setup_create_diddoc.go | 2 +- x/did/tests/setup/utils.go | 14 ++- x/did/tests/update_diddoc_test.go | 26 ++--- x/did/types/constant_test.go | 22 +++-- x/did/types/diddoc_verification_material.go | 82 ---------------- .../diddoc_verification_material_test.go | 65 ------------- x/did/types/diddoc_verification_method.go | 35 +++---- .../types/diddoc_verification_method_test.go | 95 +++++++++++++++++-- .../tx_msg_create_diddoc_payload_test.go | 4 +- .../tx_msg_update_did_doc_payload_test.go | 4 +- x/did/types/validate.go | 11 +++ x/did/utils/crypto.go | 4 + x/did/utils/encoding.go | 29 ++++++ 41 files changed, 340 insertions(+), 360 deletions(-) create mode 100644 app/migrations/helpers/protobuf.go create mode 100644 app/migrations/helpers/protobuf_test.go delete mode 100644 x/did/types/diddoc_verification_material.go delete mode 100644 x/did/types/diddoc_verification_material_test.go diff --git a/app/migrations/helpers/protobuf.go b/app/migrations/helpers/protobuf.go new file mode 100644 index 000000000..09e595232 --- /dev/null +++ b/app/migrations/helpers/protobuf.go @@ -0,0 +1,19 @@ +package helpers + +import ( + "github.com/multiformats/go-multibase" +) + +func BuildEd25519VerificationKey2020VerificationMaterial(publicKey string) (string, error) { + encoding, publicKeyBytes, err := multibase.Decode(publicKey) + if encoding != multibase.Base58BTC { + panic("Only Base58BTC encoding is supported") + } + if err != nil { + return "", err + } + multicodec := []byte{0xed, 0x01} + multicodecAndKey := append(multicodec, publicKeyBytes...) + keyStr, err := multibase.Encode(multibase.Base58BTC, multicodecAndKey) + return keyStr, err +} diff --git a/app/migrations/helpers/protobuf_test.go b/app/migrations/helpers/protobuf_test.go new file mode 100644 index 000000000..9a6ca3a76 --- /dev/null +++ b/app/migrations/helpers/protobuf_test.go @@ -0,0 +1,18 @@ +package helpers + +import ( + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = DescribeTable( + "Test BuildEd25519VerificationKey2020VerificationMaterial", + func(v1PubKey string, v2PubKey string) { + key, _ := BuildEd25519VerificationKey2020VerificationMaterial(v1PubKey) + Expect(key).To(Equal(v2PubKey)) + }, + + Entry("Valid: General convertion", "zDw21irq4wBfyTvxAG9L8PQj6b79iyTyzyV6XVj9SfyRR", "z6MksPH4K75WGjASaRnrwiHyEWH6QgRaPMEMfW1TL17TbCCo"), + // Mainnet case + Entry("Valid: Real case", "zF7rhDBfUt9d1gJPjx7s1JXfUY7oVWkYsWCo7fztHtepn", "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA"), +) diff --git a/app/migrations/migration_did_protobuf.go b/app/migrations/migration_did_protobuf.go index 3203c1663..3d9bfbaf8 100644 --- a/app/migrations/migration_did_protobuf.go +++ b/app/migrations/migration_did_protobuf.go @@ -140,9 +140,9 @@ func MigrateDidDoc(oldDid *didtypesv1.Did) didtypes.DidDoc { func MigrateType(t string) string { switch t { case didtypesv1.Ed25519VerificationKey2020: - return didtypes.Ed25519VerificationKey2020{}.Type() + return didtypes.Ed25519VerificationKey2020Type case didtypesv1.JSONWebKey2020: - return didtypes.JSONWebKey2020{}.Type() + return didtypes.JSONWebKey2020Type default: panic("Unknown type") } @@ -159,28 +159,15 @@ func MigrateVerificationMaterial(vm *didtypesv1.VerificationMethod) string { if err != nil { panic(err) } - - jwk2020 := didtypes.JSONWebKey2020{ - PublicKeyJwk: res, - } - res, err = json.Marshal(jwk2020) - if err != nil { - panic(err) - } - return string(res) case didtypesv1.Ed25519VerificationKey2020: - pkMulti := didtypes.Ed25519VerificationKey2020{ - PublicKeyMultibase: vm.PublicKeyMultibase, - } - - res, err := json.Marshal(pkMulti) + pkMulti, err := helpers.BuildEd25519VerificationKey2020VerificationMaterial(vm.PublicKeyMultibase) if err != nil { panic(err) } - return string(res) + return pkMulti default: panic("Unknown type") diff --git a/tests/integration/cli_diddoc_negative_test.go b/tests/integration/cli_diddoc_negative_test.go index a5e447221..2327276f4 100644 --- a/tests/integration/cli_diddoc_negative_test.go +++ b/tests/integration/cli_diddoc_negative_test.go @@ -11,9 +11,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" cli_types "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -33,8 +33,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -43,7 +42,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, @@ -68,8 +67,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582, err := multibase.Encode(multibase.Base58BTC, pubKey2) - Expect(err).To(BeNil()) + pubKeyMultibase582 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -78,7 +76,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase582) + "\"}", + VerificationMaterial: pubKeyMultibase582, }, }, Authentication: []string{keyId2}, @@ -166,8 +164,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -177,7 +174,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, @@ -203,7 +200,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, @@ -223,8 +220,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582, err := multibase.Encode(multibase.Base58BTC, pubKey2) - Expect(err).To(BeNil()) + pubKeyMultibase582 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -234,7 +230,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase582) + "\"}", + VerificationMaterial: pubKeyMultibase582, }, }, Authentication: []string{keyId2}, @@ -291,7 +287,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2AsExtraController, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: "{\"publicKeyMultibase\":\"" + string(pubKeyMultibase582) + "\"}", + VerificationMaterial: pubKeyMultibase582, }) followingUpdatedPayload.Authentication = append(followingUpdatedPayload.Authentication, keyId2AsExtraController) followingUpdatedPayload.CapabilityDelegation = []string{keyId} @@ -388,7 +384,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: followingUpdatedPayload.VerificationMethod[1].Id, VerificationMethodType: "NonSupportedVmType", Controller: followingUpdatedPayload.VerificationMethod[1].Controller, - VerificationMaterial: "{\"publicKeyMultibase\":\"pretty-long-public-key-multibase\"}", + VerificationMaterial: "pretty-long-public-key-multibase", }, } invalidVmTypePayload.VersionId = uuid.NewString() diff --git a/tests/integration/cli_diddoc_pricing_negative_test.go b/tests/integration/cli_diddoc_pricing_negative_test.go index 2814cb290..2f0249a16 100644 --- a/tests/integration/cli_diddoc_pricing_negative_test.go +++ b/tests/integration/cli_diddoc_pricing_negative_test.go @@ -12,7 +12,7 @@ import ( clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - "github.com/multiformats/go-multibase" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,8 +59,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -69,7 +68,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_diddoc_pricing_test.go b/tests/integration/cli_diddoc_pricing_test.go index f260d0e56..d406cd2a5 100644 --- a/tests/integration/cli_diddoc_pricing_test.go +++ b/tests/integration/cli_diddoc_pricing_test.go @@ -12,7 +12,7 @@ import ( clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - "github.com/multiformats/go-multibase" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -40,8 +40,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -50,7 +49,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index 1cb6847d2..3703f74e9 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -13,6 +13,7 @@ import ( "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" "github.com/multiformats/go-multibase" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -34,8 +35,7 @@ var _ = Describe("cheqd cli - positive did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -44,7 +44,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + pubKeyMultibase58 + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyID}, diff --git a/tests/integration/cli_resource_negative_test.go b/tests/integration/cli_resource_negative_test.go index e475fb663..6d8836735 100644 --- a/tests/integration/cli_resource_negative_test.go +++ b/tests/integration/cli_resource_negative_test.go @@ -12,8 +12,8 @@ import ( clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -39,8 +39,7 @@ var _ = Describe("cheqd cli - negative resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -49,7 +48,7 @@ var _ = Describe("cheqd cli - negative resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_negative_test.go b/tests/integration/cli_resource_pricing_negative_test.go index 60bbb3384..62f13c74a 100644 --- a/tests/integration/cli_resource_pricing_negative_test.go +++ b/tests/integration/cli_resource_pricing_negative_test.go @@ -13,9 +13,9 @@ import ( didtypes "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/google/uuid" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -60,8 +60,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -70,7 +69,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_test.go b/tests/integration/cli_resource_pricing_test.go index a4cccedc4..a4db895d8 100644 --- a/tests/integration/cli_resource_pricing_test.go +++ b/tests/integration/cli_resource_pricing_test.go @@ -13,8 +13,8 @@ import ( didtypes "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -42,8 +42,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -52,7 +51,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_test.go b/tests/integration/cli_resource_test.go index 2eaae56d9..96c2cfebf 100644 --- a/tests/integration/cli_resource_test.go +++ b/tests/integration/cli_resource_test.go @@ -12,8 +12,8 @@ import ( clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -35,8 +35,7 @@ var _ = Describe("cheqd cli - positive resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -134,8 +133,7 @@ var _ = Describe("cheqd cli - positive resource", func() { secondPubKey, secondPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - secondPubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, secondPubKey) - Expect(err).To(BeNil()) + secondPubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(secondPubKey) secondPayload := types.MsgCreateDidDocPayload{ Id: secondDid, @@ -144,7 +142,7 @@ var _ = Describe("cheqd cli - positive resource", func() { Id: secondKeyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: secondDid, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(secondPubKeyMultibase58) + "\"}", + VerificationMaterial: secondPubKeyMultibase58, }, }, Authentication: []string{secondKeyId}, diff --git a/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json b/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json index 7637cd9a5..b1623b591 100644 --- a/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json @@ -8,17 +8,17 @@ "authentication": [ "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1" ], - "assertionMethod": [], - "capabilityInvocation": [], - "capabilityDelegation": [], - "keyAgreement": [], - "alsoKnownAs": [], - "verificationMethod": [ + "assertion_method": [], + "capability_invocation": [], + "capability_delegation": [], + "key_agreement": [], + "also_known_as": [], + "verification_method": [ { "id": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb", - "verification_material": "{\"publicKeyMultibase\":\"z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS\"}" + "verification_material": "z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS" } ], "service": [] diff --git a/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json b/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json index 7637cd9a5..539ab1e72 100644 --- a/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json @@ -8,17 +8,17 @@ "authentication": [ "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1" ], - "assertionMethod": [], - "capabilityInvocation": [], - "capabilityDelegation": [], - "keyAgreement": [], - "alsoKnownAs": [], - "verificationMethod": [ + "assertion_method": [], + "capability_invocation": [], + "capability_delegation": [], + "key_agreement": [], + "allso_known_as": [], + "verification_method": [ { "id": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb", - "verification_material": "{\"publicKeyMultibase\":\"z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS\"}" + "verification_material": "z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS" } ], "service": [] diff --git a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json index 33273e571..5e317dfac 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "{\"publicKeyMultibase\":\"z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd\"}" + "verification_material": "z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "{\"publicKeyMultibase\":\"z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5\"}" + "verification_material": "z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "{\"publicKeyMultibase\":\"zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj\"}" + "verification_material": "zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "{\"publicKeyMultibase\":\"z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei\"}" + "verification_material": "z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json index 6a7efb6c9..89e5cd61e 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json +++ b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "{\"publicKeyMultibase\":\"z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X\"}" + "verification_material": "z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "{\"publicKeyMultibase\":\"zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w\"}" + "verification_material": "zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "{\"publicKeyMultibase\":\"z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy\"}" + "verification_material": "z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "{\"publicKeyMultibase\":\"z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL\"}" + "verification_material": "z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json index 79d8f2e1a..524199030 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "{\"publicKeyMultibase\":\"z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd\"}" + "verification_material": "z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "{\"publicKeyMultibase\":\"z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5\"}" + "verification_material": "z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "{\"publicKeyMultibase\":\"zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj\"}" + "verification_material": "zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "{\"publicKeyMultibase\":\"z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei\"}" + "verification_material": "z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json index 0d4fb0250..181b2d2b8 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json +++ b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "{\"publicKeyMultibase\":\"z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X\"}" + "verification_material": "z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "{\"publicKeyMultibase\":\"zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w\"}" + "verification_material": "zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "{\"publicKeyMultibase\":\"z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy\"}" + "verification_material": "z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "{\"publicKeyMultibase\":\"z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL\"}" + "verification_material": "z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc.json b/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc.json index ce4cdcf21..09d8954fd 100644 --- a/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE", - "verification_material": "{\"publicKeyMultibase\":\"z9KXGLghdcmYmHv2tVs9P4GNt6jzGXMtuVWM2cDuUrLD7\"}" + "verification_material": "z6MknmnJvvx4xK3EQQsbBS7DuMvsvKG7wF9GBXFxSVsVmYzV" }, { "id": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE", - "verification_material": "{\"publicKeyMultibase\":\"zARyYq78WYMC8dZAeKT1PLttgfsWMfqXe5PJCDexYM18U\"}" + "verification_material": "z6MkotEbRMNwstgbk41M11yEBzSgVSnD5imzmQD83vvZGDur" }, { "id": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE", - "verification_material": "{\"publicKeyMultibase\":\"z8zy7xEuLkTt6sLivVg7FEdaYyxD9QJMaH3kvPEvMzVP8\"}" + "verification_material": "z6MknTEAYV9n61NZyqZdBF565j8YoXUzpBbvy4frDWtNuiAW" }, { "id": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:GR4bwyhJMubXbHvHTGiYnE", - "verification_material": "{\"publicKeyMultibase\":\"z6RoXXGz8X1y4urbdLD1QHW7fAXc9LBw5AGaLQ3mV1Sj5\"}" + "verification_material": "z6Mkjt4a7XEZrZTY2MSL1myF8bfez6szk5BRrHVGEKjVvfWT" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc_2.json b/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc_2.json index 99fb86499..bd73053bb 100644 --- a/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc_2.json +++ b/tests/upgrade/unit/generated/payload/protobuf/expected/v2/diddoc_2.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez", - "verification_material": "{\"publicKeyMultibase\":\"z79qsUjmJ9xniX5giTtTbd3p9Zsc9yRqGJr4jMvgXUp35\"}" + "verification_material": "z6Mkkc6v4z1jVWHBdaXR9TRSU9N9PSt1PK5czryfCCeYQ2pT" }, { "id": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez", - "verification_material": "{\"publicKeyMultibase\":\"z4USV76ihz482Y2b6p9kLWHvRHGCzyhjoHHHuWG69pAre\"}" + "verification_material": "z6MkhvhXhLy9KbcVeXRoViiBMPUR6qUrPaz9yJCqLY4AjPe2" }, { "id": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez", - "verification_material": "{\"publicKeyMultibase\":\"z2AmSeQdDHgV8iadh1hhbz7rAN2wca8TVtKgUn9Ka1AMY\"}" + "verification_material": "z6Mkfd2VEesedDybq5UPhGfSqDQABcDTz1hraLbQcRHavP8v" }, { "id": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7RPNZSCSaQXTdYwFmQy6ez", - "verification_material": "{\"publicKeyMultibase\":\"z4N61VYXb7PCWMh1j7qqyGmHSThnCNFMmCRGnkqeBgnww\"}" + "verification_material": "z6MkhpM45nn2SvgyUBrRoQop7rqSHH43n8c7tSBib7cCc1jK" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json index 4b2edbe42..022b03cf0 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz\"}" + "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT\"}" + "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv\"}" + "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt\"}" + "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json index f3a1b12fa..8382f2bad 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "{\"publicKeyMultibase\":\"z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq\"}" + "verification_material": "z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "{\"publicKeyMultibase\":\"zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ\"}" + "verification_material": "zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "{\"publicKeyMultibase\":\"zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP\"}" + "verification_material": "zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "{\"publicKeyMultibase\":\"zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh\"}" + "verification_material": "zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json index 179bcb5f9..3fae1f88b 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "{\"publicKeyMultibase\":\"z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF\"}" + "verification_material": "z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "{\"publicKeyMultibase\":\"zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn\"}" + "verification_material": "zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "{\"publicKeyMultibase\":\"zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk\"}" + "verification_material": "zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "{\"publicKeyMultibase\":\"zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr\"}" + "verification_material": "zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json index 4b2edbe42..022b03cf0 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz\"}" + "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT\"}" + "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv\"}" + "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt\"}" + "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json index 63a2e6dad..1a2811e77 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "{\"publicKeyMultibase\":\"z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq\"}" + "verification_material": "z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "{\"publicKeyMultibase\":\"zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ\"}" + "verification_material": "zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "{\"publicKeyMultibase\":\"zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP\"}" + "verification_material": "zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "{\"publicKeyMultibase\":\"zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh\"}" + "verification_material": "zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json index a4874eae9..8fd2f48f5 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "{\"publicKeyMultibase\":\"z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF\"}" + "verification_material": "z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "{\"publicKeyMultibase\":\"zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn\"}" + "verification_material": "zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "{\"publicKeyMultibase\":\"zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk\"}" + "verification_material": "zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "{\"publicKeyMultibase\":\"zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr\"}" + "verification_material": "zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json b/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json index a5f5a041b..1eb22ea1a 100644 --- a/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json +++ b/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz\"}" + "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT\"}" + "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv\"}" + "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt\"}" + "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json b/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json index 14c7903b8..0ceebd1fc 100644 --- a/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json +++ b/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz\"}" + "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT\"}" + "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv\"}" + "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "{\"publicKeyMultibase\":\"z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt\"}" + "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" } ], "authentication": [ diff --git a/x/did/tests/create_diddoc_test.go b/x/did/tests/create_diddoc_test.go index 9a83278c1..207a26d7d 100644 --- a/x/did/tests/create_diddoc_test.go +++ b/x/did/tests/create_diddoc_test.go @@ -30,7 +30,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, @@ -65,7 +65,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.JSONWebKey2020{}.Type(), + VerificationMethodType: types.JSONWebKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildJSONWebKey2020VerificationMaterial(keypair.Public), }, @@ -106,7 +106,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: bobKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: anna.Did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, @@ -147,25 +147,25 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID1, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair1.Public), }, { Id: keyID2, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair2.Public), }, { Id: keyID3, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair3.Public), }, { Id: keyID4, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair4.Public), }, @@ -222,7 +222,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: bobKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bobDid, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, @@ -253,7 +253,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, @@ -281,7 +281,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, @@ -307,7 +307,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, @@ -344,7 +344,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: bobKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bobDid, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, @@ -370,7 +370,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, @@ -401,7 +401,7 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -436,7 +436,7 @@ var _ = Describe("Check upper/lower case for DID creation", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, diff --git a/x/did/tests/setup/setup_create_diddoc.go b/x/did/tests/setup/setup_create_diddoc.go index 9a679289e..484427d4f 100644 --- a/x/did/tests/setup/setup_create_diddoc.go +++ b/x/did/tests/setup/setup_create_diddoc.go @@ -40,7 +40,7 @@ func (s *TestSetup) BuildDidDocWithCustomDID(did string) DidDocInfo { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(keyPair.Public), }, diff --git a/x/did/tests/setup/utils.go b/x/did/tests/setup/utils.go index 014f8d7e2..53870266f 100644 --- a/x/did/tests/setup/utils.go +++ b/x/did/tests/setup/utils.go @@ -7,11 +7,10 @@ import ( mathrand "math/rand" "time" - "github.com/cheqd/cheqd-node/x/did/types" - "github.com/cheqd/cheqd-node/x/did/utils" "github.com/google/uuid" "github.com/lestrrat-go/jwx/jwk" "github.com/mr-tron/base58" + "github.com/multiformats/go-multibase" ) func randBase58Seq(bytes int) string { @@ -65,9 +64,10 @@ func GenerateKeyPair() KeyPair { } func BuildEd25519VerificationKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { - return utils.MustEncodeJSON(types.Ed25519VerificationKey2020{ - PublicKeyMultibase: utils.MustEncodeMultibaseBase58(publicKey), - }) + multicodec := []byte{0xed, 0x01} + multicodecAndKey := append(multicodec, publicKey...) + keyStr, _ := multibase.Encode(multibase.Base58BTC, multicodecAndKey) + return keyStr } func BuildJSONWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { @@ -81,7 +81,5 @@ func BuildJSONWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string panic(err) } - return utils.MustEncodeJSON(types.JSONWebKey2020{ - PublicKeyJwk: json.RawMessage(pubKeyJwkJSON), - }) + return string(pubKeyJwkJSON) } diff --git a/x/did/tests/update_diddoc_test.go b/x/did/tests/update_diddoc_test.go index a872ccdec..07322ac94 100644 --- a/x/did/tests/update_diddoc_test.go +++ b/x/did/tests/update_diddoc_test.go @@ -34,7 +34,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: bob.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bob.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(bob.KeyPair.Public), }, @@ -113,7 +113,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -171,7 +171,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -229,7 +229,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -268,7 +268,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: did.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(newKeyPair.Public), }, @@ -327,7 +327,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bob.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -378,7 +378,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: newKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -443,13 +443,13 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, { Id: newKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(newKey.Public), }, @@ -508,13 +508,13 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, { Id: secondKeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(secondKey.Public), }, @@ -531,7 +531,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, @@ -577,7 +577,7 @@ var _ = Describe("DIDDoc update", func() { VerificationMethod: []*types.VerificationMethod{ { Id: alice.DidDocInfo.KeyID, - VerificationMethodType: types.Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.DidDocInfo.Did, VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.DidDocInfo.KeyPair.Public), }, diff --git a/x/did/types/constant_test.go b/x/did/types/constant_test.go index 2c26635ae..234f243d5 100644 --- a/x/did/types/constant_test.go +++ b/x/did/types/constant_test.go @@ -5,11 +5,9 @@ import ( ) var ( - ValidTestDID = "did:cheqd:testnet:zABCDEFG123456789abcd" - ValidTestDID2 = "did:cheqd:testnet:zABCDEFG987654321abcd" - InvalidTestDID = "badDid" - ValidEd25519PubKey = "zF1hVGXXK9rmx5HhMTpGnGQJiab9qrFJbQXBRhSmYjQWX" - InvalidEd25519PubKey = "zF1hVGXXK9rmx5HhMTpGnGQJi" + ValidTestDID = "did:cheqd:testnet:zABCDEFG123456789abcd" + ValidTestDID2 = "did:cheqd:testnet:zABCDEFG987654321abcd" + InvalidTestDID = "badDid" ) type TestJWKKey struct { @@ -45,9 +43,13 @@ var ( ) var ( - ValidEd25519VerificationMaterial = "{\"publicKeyMultibase\":\"" + ValidEd25519PubKey + "\"}" - InvalidEd25519VerificationMaterial = "{\"publicKeyMultibase\":\"" + InvalidEd25519PubKey + "\"}" - - ValidJWKKeyVerificationMaterial = "{\"publicKeyJwk\":" + string(ValidPublicKeyJWK) + "}" - InvalidJWKKeyVerificationMaterial = "{\"publicKeyJwk\":" + string(InvalidPublicKeyJWK) + "}" + // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9202d564c12 + ValidEd25519VerificationMaterial = "z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3" + // bytes: 020076a50fe5e0c3616c1b4d85a308c104a1c99d8d3d92c18c1f4e0179202d564c12 + InvalidEd25519VerificationMaterialBadMulticodec = "z3dEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9 + InvalidEd25519VerificationMaterialBadlength = "zBm3emgJHyjidq7HsZFTx3PCjYHayy7SxisBeVCa4" + + ValidJWKKeyVerificationMaterial = string(ValidPublicKeyJWK) + InvalidJWKKeyVerificationMaterial = string(InvalidPublicKeyJWK) ) diff --git a/x/did/types/diddoc_verification_material.go b/x/did/types/diddoc_verification_material.go deleted file mode 100644 index f9f159b51..000000000 --- a/x/did/types/diddoc_verification_material.go +++ /dev/null @@ -1,82 +0,0 @@ -package types - -import ( - "encoding/json" - - validation "github.com/go-ozzo/ozzo-validation/v4" -) - -type VerificationMaterial interface { - Type() string - Validate() error -} - -// Ed25519VerificationKey2020 - -type Ed25519VerificationKey2020 struct { - PublicKeyMultibase string `json:"publicKeyMultibase"` -} - -var _ VerificationMaterial = (*Ed25519VerificationKey2020)(nil) - -func (vm Ed25519VerificationKey2020) Type() string { - return "Ed25519VerificationKey2020" -} - -func (vm Ed25519VerificationKey2020) Validate() error { - return validation.ValidateStruct(&vm, - validation.Field(&vm.PublicKeyMultibase, validation.Required, IsMultibase(), IsMultibaseEncodedEd25519PubKey()), - ) -} - -// JsonWebKey2020 - -type JSONWebKey2020 struct { - PublicKeyJwk json.RawMessage `json:"publicKeyJwk"` -} - -var _ VerificationMaterial = (*JSONWebKey2020)(nil) - -func (vm JSONWebKey2020) Type() string { - return "JsonWebKey2020" -} - -func (vm JSONWebKey2020) Validate() error { - return validation.Validate(string(vm.PublicKeyJwk), validation.Required, IsJWK()) -} - -// Validation - -func ValidEd25519VerificationKey2020Rule() *CustomErrorRule { - return NewCustomErrorRule(func(value interface{}) error { - casted, ok := value.(string) - if !ok { - panic("ValidVerificationMethodRule must be only applied on verification methods") - } - - var vm Ed25519VerificationKey2020 - err := json.Unmarshal([]byte(casted), &vm) - if err != nil { - return err - } - - return vm.Validate() - }) -} - -func ValidJSONWebKey2020Rule() *CustomErrorRule { - return NewCustomErrorRule(func(value interface{}) error { - casted, ok := value.(string) - if !ok { - panic("ValidVerificationMethodRule must be only applied on verification methods") - } - - var vm JSONWebKey2020 - err := json.Unmarshal([]byte(casted), &vm) - if err != nil { - return err - } - - return vm.Validate() - }) -} diff --git a/x/did/types/diddoc_verification_material_test.go b/x/did/types/diddoc_verification_material_test.go deleted file mode 100644 index de18db279..000000000 --- a/x/did/types/diddoc_verification_material_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package types_test - -import ( - . "github.com/cheqd/cheqd-node/x/did/types" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -type VerificationMaterialTestCase struct { - vm VerificationMaterial - isValid bool - errorMsg string -} - -var _ = DescribeTable("Verification Method material validation tests", func(testCase VerificationMaterialTestCase) { - err := testCase.vm.Validate() - - if testCase.isValid { - Expect(err).To(BeNil()) - } else { - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring(testCase.errorMsg)) - } -}, - - Entry( - "Valid Ed25519VerificationKey2020 verification material", - VerificationMaterialTestCase{ - vm: Ed25519VerificationKey2020{ - PublicKeyMultibase: ValidEd25519PubKey, - }, - isValid: true, - errorMsg: "", - }), - - Entry( - "Valid JsonWebKey2020 verification material", - VerificationMaterialTestCase{ - vm: JSONWebKey2020{ - PublicKeyJwk: ValidPublicKeyJWK, - }, - isValid: true, - errorMsg: "", - }), - - Entry( - "Invalid Ed25519VerificationKey2020 verification material", - VerificationMaterialTestCase{ - vm: Ed25519VerificationKey2020{ - PublicKeyMultibase: InvalidEd25519PubKey, - }, - isValid: false, - errorMsg: "publicKeyMultibase: ed25519: bad public key length: 18", - }), - - Entry( - "Invalid JsonWebKey2020 verification material", - VerificationMaterialTestCase{ - vm: JSONWebKey2020{ - PublicKeyJwk: InvalidPublicKeyJWK, - }, - isValid: false, - errorMsg: "can't parse jwk: failed to parse key", - }), -) diff --git a/x/did/types/diddoc_verification_method.go b/x/did/types/diddoc_verification_method.go index 20a870e33..ce73f2ca7 100644 --- a/x/did/types/diddoc_verification_method.go +++ b/x/did/types/diddoc_verification_method.go @@ -4,20 +4,23 @@ import ( "crypto/ecdsa" "crypto/ed25519" "crypto/rsa" - "encoding/json" "errors" "fmt" "github.com/cheqd/cheqd-node/x/did/utils" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/lestrrat-go/jwx/jwk" "github.com/multiformats/go-multibase" ) +const ( + JSONWebKey2020Type = "JsonWebKey2020" + Ed25519VerificationKey2020Type = "Ed25519VerificationKey2020" +) + var SupportedMethodTypes = []string{ - JSONWebKey2020{}.Type(), - Ed25519VerificationKey2020{}.Type(), + JSONWebKey2020Type, + Ed25519VerificationKey2020Type, } func NewVerificationMethod(id string, vmType string, controller string, verificationMaterial string) *VerificationMethod { @@ -55,29 +58,19 @@ func VerifySignature(vm VerificationMethod, message []byte, signature []byte) er var verificationError error switch vm.VerificationMethodType { - case Ed25519VerificationKey2020{}.Type(): - var ed25519VerificationKey2020 Ed25519VerificationKey2020 - err := json.Unmarshal([]byte(vm.VerificationMaterial), &ed25519VerificationKey2020) - if err != nil { - return sdkerrors.Wrapf(err, "failed to unmarshal verification material for %s", vm.Id) - } + case Ed25519VerificationKey2020Type: - _, keyBytes, err := multibase.Decode(ed25519VerificationKey2020.PublicKeyMultibase) + _, multibaseBytes, err := multibase.Decode(vm.VerificationMaterial) if err != nil { return err } + keyBytes := utils.GetEd25519VerificationKey2020(multibaseBytes) verificationError = utils.VerifyED25519Signature(keyBytes, message, signature) - case JSONWebKey2020{}.Type(): - var jsonWebKey2020 JSONWebKey2020 - err := json.Unmarshal([]byte(vm.VerificationMaterial), &jsonWebKey2020) - if err != nil { - return sdkerrors.Wrapf(err, "failed to unmarshal verification material for %s", vm.Id) - } - + case JSONWebKey2020Type: var raw interface{} - err = jwk.ParseRawKey([]byte(jsonWebKey2020.PublicKeyJwk), &raw) + err := jwk.ParseRawKey([]byte(vm.VerificationMaterial), &raw) if err != nil { return fmt.Errorf("can't parse jwk: %s", err.Error()) } @@ -134,10 +127,10 @@ func (vm VerificationMethod) Validate(baseDid string, allowedNamespaces []string validation.Field(&vm.Controller, validation.Required, IsDID(allowedNamespaces)), validation.Field(&vm.VerificationMethodType, validation.Required, validation.In(utils.ToInterfaces(SupportedMethodTypes)...)), validation.Field(&vm.VerificationMaterial, - validation.When(vm.VerificationMethodType == Ed25519VerificationKey2020{}.Type(), validation.Required, ValidEd25519VerificationKey2020Rule()), + validation.When(vm.VerificationMethodType == Ed25519VerificationKey2020Type, validation.Required, IsMultibaseEd25519VerificationKey2020()), ), validation.Field(&vm.VerificationMaterial, - validation.When(vm.VerificationMethodType == JSONWebKey2020{}.Type(), validation.Required, ValidJSONWebKey2020Rule()), + validation.When(vm.VerificationMethodType == JSONWebKey2020Type, validation.Required, IsJWK()), ), ) } diff --git a/x/did/types/diddoc_verification_method_test.go b/x/did/types/diddoc_verification_method_test.go index b17563ec7..ae544dab2 100644 --- a/x/did/types/diddoc_verification_method_test.go +++ b/x/did/types/diddoc_verification_method_test.go @@ -10,8 +10,8 @@ import ( "encoding/json" . "github.com/cheqd/cheqd-node/x/did/types" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/lestrrat-go/jwx/jwk" - "github.com/multiformats/go-multibase" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -145,10 +145,10 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidEd25519VerificationMaterial, + VerificationMaterial: InvalidEd25519VerificationMaterialBadlength, }, isValid: false, - errorMsg: "verification_material: (publicKeyMultibase: ed25519: bad public key length: 18.)", + errorMsg: "verification_material: ed25519: bad public key length: 27", }), ) @@ -168,14 +168,13 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { Context("when ed25519 key is placed", func() { It("is valid", func() { - pubKeyStr, err := multibase.Encode(multibase.Base58BTC, pubKey) - Expect(err).To(BeNil()) + pubKeyStr := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) vm := VerificationMethod{ Id: "", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "", - VerificationMaterial: "{\"publicKeyMultibase\": \"" + pubKeyStr + "\"}", + VerificationMaterial: pubKeyStr, } err = VerifySignature(vm, msgBytes, signature) @@ -195,7 +194,7 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", - VerificationMaterial: "{\"publicKeyJwk\": " + string(jsonPayload) + "}", + VerificationMaterial: string(jsonPayload), } err = VerifySignature(vm2, msgBytes, signature) @@ -234,7 +233,7 @@ var _ = Describe("Validation ECDSA Signature in verification method", func() { Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", - VerificationMaterial: "{\"publicKeyJwk\": " + string(jsonPayload) + "}", + VerificationMaterial: string(jsonPayload), } err = VerifySignature(vm, msgBytes, signature) @@ -272,7 +271,7 @@ var _ = Describe("Validation RSA Signature in verification method", func() { Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", - VerificationMaterial: "{\"publicKeyJwk\": " + string(jsonPayload) + "}", + VerificationMaterial: string(jsonPayload), } err = VerifySignature(vm2, msgBytes, signature) @@ -280,3 +279,81 @@ var _ = Describe("Validation RSA Signature in verification method", func() { }) }) }) + +var _ = DescribeTable("Verification Method material validation tests", func(testCase VerificationMethodTestCase) { + + err := testCase.vm.Validate(testCase.baseDid, testCase.allowedNamespaces) + + if testCase.isValid { + Expect(err).To(BeNil()) + } else { + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring(testCase.errorMsg)) + } +}, + + Entry( + "Valid Ed25519VerificationKey2020 verification material", + VerificationMethodTestCase{ + vm: VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2020", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: ValidEd25519VerificationMaterial, + }, + isValid: true, + errorMsg: "", + }), + + Entry( + "Valid JsonWebKey2020 verification material", + VerificationMethodTestCase{ + vm: VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "JsonWebKey2020", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: ValidJWKKeyVerificationMaterial, + }, + isValid: true, + errorMsg: "", + }), + + Entry( + "Invalid Ed25519VerificationKey2020 verification material", + VerificationMethodTestCase{ + vm: VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2020", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: InvalidEd25519VerificationMaterialBadlength, + }, + isValid: false, + errorMsg: "", + }), + + Entry( + "Invalid Ed25519VerificationKey2020 verification material", + VerificationMethodTestCase{ + vm: VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2020", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: InvalidEd25519VerificationMaterialBadMulticodec, + }, + isValid: false, + errorMsg: "verification_material: invalid multicodec for ED25519VerificationKey2020. expected: 0xed01 actual: 0x0200", + }), + + Entry( + "Invalid JsonWebKey2020 verification material", + VerificationMethodTestCase{ + vm: VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "JsonWebKey2020", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: InvalidJWKKeyVerificationMaterial, + }, + isValid: false, + errorMsg: "can't parse jwk: failed to parse key", + }), +) diff --git a/x/did/types/tx_msg_create_diddoc_payload_test.go b/x/did/types/tx_msg_create_diddoc_payload_test.go index 0a2134968..63321e513 100644 --- a/x/did/types/tx_msg_create_diddoc_payload_test.go +++ b/x/did/types/tx_msg_create_diddoc_payload_test.go @@ -19,7 +19,7 @@ var _ = Describe("Create DID Payload Validation tests", func() { VerificationMethod: []*VerificationMethod{ { Id: testCase.inputID + "#key1", - VerificationMethodType: Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: Ed25519VerificationKey2020Type, Controller: testCase.inputID, }, }, @@ -30,7 +30,7 @@ var _ = Describe("Create DID Payload Validation tests", func() { VerificationMethod: []*VerificationMethod{ { Id: testCase.expectedID + "#key1", - VerificationMethodType: Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: Ed25519VerificationKey2020Type, Controller: testCase.expectedID, }, }, diff --git a/x/did/types/tx_msg_update_did_doc_payload_test.go b/x/did/types/tx_msg_update_did_doc_payload_test.go index 7878a1471..72ed70901 100644 --- a/x/did/types/tx_msg_update_did_doc_payload_test.go +++ b/x/did/types/tx_msg_update_did_doc_payload_test.go @@ -19,7 +19,7 @@ var _ = Describe("Update DID Payload Validation tests", func() { VerificationMethod: []*VerificationMethod{ { Id: testCase.inputID + "#key1", - VerificationMethodType: Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: Ed25519VerificationKey2020Type, Controller: testCase.inputID, }, }, @@ -31,7 +31,7 @@ var _ = Describe("Update DID Payload Validation tests", func() { VerificationMethod: []*VerificationMethod{ { Id: testCase.expectedID + "#key1", - VerificationMethodType: Ed25519VerificationKey2020{}.Type(), + VerificationMethodType: Ed25519VerificationKey2020Type, Controller: testCase.expectedID, }, }, diff --git a/x/did/types/validate.go b/x/did/types/validate.go index 013987401..c11b5cd64 100644 --- a/x/did/types/validate.go +++ b/x/did/types/validate.go @@ -127,6 +127,17 @@ func IsMultibase() *CustomErrorRule { }) } +func IsMultibaseEd25519VerificationKey2020() *CustomErrorRule { + return NewCustomErrorRule(func(value interface{}) error { + casted, ok := value.(string) + if !ok { + panic("IsMultibaseEd25519VerificationKey2020 must be only applied on string properties") + } + + return utils.ValidateMultibaseEd25519VerificationKey2020(casted) + }) +} + func IsMultibaseEncodedEd25519PubKey() *CustomErrorRule { return NewCustomErrorRule(func(value interface{}) error { casted, ok := value.(string) diff --git a/x/did/utils/crypto.go b/x/did/utils/crypto.go index 0ada565f8..33687882e 100644 --- a/x/did/utils/crypto.go +++ b/x/did/utils/crypto.go @@ -84,3 +84,7 @@ func VerifyECDSASignature(pubKey ecdsa.PublicKey, message []byte, signature []by } return nil } + +func GetEd25519VerificationKey2020(keyBytes []byte) []byte { + return keyBytes[2:] +} diff --git a/x/did/utils/encoding.go b/x/did/utils/encoding.go index 340c8f7e5..e287fe5ea 100644 --- a/x/did/utils/encoding.go +++ b/x/did/utils/encoding.go @@ -51,3 +51,32 @@ func MustEncodeJSON(data interface{}) string { return string(encoded) } + +func ValidateMulticodecEd25519VerificationKey2020(keyBytes []byte) error { + if keyBytes[0] != 0xed && keyBytes[1] != 0x01 { + return fmt.Errorf("invalid multicodec for ED25519VerificationKey2020. expected: %s actual: %s", + "0xed01", fmt.Sprintf("0x%02x%02x", keyBytes[0], keyBytes[1])) + } + return nil +} + +func ValidateMultibaseEd25519VerificationKey2020(data string) error { + encoding, keyBytes, err := multibase.Decode(data) + if err != nil { + return err + } + + if encoding != multibase.Base58BTC { + return fmt.Errorf("invalid encoding for ED25519VerificationKey2020. expected: %s actual: %s", + multibase.EncodingToStr[multibase.Base58BTC], multibase.EncodingToStr[encoding]) + } + + err = ValidateMulticodecEd25519VerificationKey2020(keyBytes) + if err != nil { + return err + } + + pubKey := GetEd25519VerificationKey2020(keyBytes) + err = ValidateEd25519PubKey(pubKey) + return err +} From 2f59e96382c100ea83c2f636e00e33658145929a Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 30 Dec 2022 20:30:12 +0300 Subject: [PATCH 02/42] Change generated jsons for unit upgrade tests --- .../generated/payload/checksum/existing/v2/diddoc.json | 2 +- .../generated/payload/checksum/expected/v2/diddoc.json | 4 ++-- .../generated/payload/indy_style/existing/v2/diddoc.json | 8 ++++---- .../payload/indy_style/existing/v2/diddoc_2.json | 8 ++++---- .../generated/payload/indy_style/expected/v2/diddoc.json | 8 ++++---- .../payload/indy_style/expected/v2/diddoc_2.json | 8 ++++---- .../payload/uuid/existing/v2/diddoc_lowcase.json | 8 ++++---- .../generated/payload/uuid/existing/v2/diddoc_mixed.json | 8 ++++---- .../generated/payload/uuid/existing/v2/diddoc_upper.json | 8 ++++---- .../payload/uuid/expected/v2/diddoc_lowcase.json | 8 ++++---- .../generated/payload/uuid/expected/v2/diddoc_mixed.json | 8 ++++---- .../generated/payload/uuid/expected/v2/diddoc_upper.json | 8 ++++---- .../payload/version_id/existing/v2/diddoc_hash.json | 8 ++++---- .../payload/version_id/expected/v2/diddoc_hash.json | 8 ++++---- 14 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json b/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json index b1623b591..ab9b1c224 100644 --- a/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/checksum/existing/v2/diddoc.json @@ -18,7 +18,7 @@ "id": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb", - "verification_material": "z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS" + "verification_material": "z6MkjndtVVvRivBfWddHt5QC2WHoguixzrVBxTTnCJW2ArYp" } ], "service": [] diff --git a/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json b/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json index 539ab1e72..ab9b1c224 100644 --- a/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/checksum/expected/v2/diddoc.json @@ -12,13 +12,13 @@ "capability_invocation": [], "capability_delegation": [], "key_agreement": [], - "allso_known_as": [], + "also_known_as": [], "verification_method": [ { "id": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:97096fb1-63ea-4f81-b296-8eb5da6ab6eb", - "verification_material": "z6LNquFfzPNhCQ8nbCWSMBQjosLT7ayEqGSYrN2Y1FdmS" + "verification_material": "z6MkjndtVVvRivBfWddHt5QC2WHoguixzrVBxTTnCJW2ArYp" } ], "service": [] diff --git a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json index 5e317dfac..48a9d544b 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd" + "verification_material": "z6MkeXDkMqPMfDgq8ZQkRzwRZAo8TviYAo5nr957E56nTXE1" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5" + "verification_material": "z6MkjnP7TsFXr32rX3EoD6uUEzE2Fp2pPcGZYtBCEKL1fUAT" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj" + "verification_material": "z6MkofRWLT37dkx57TYhETh2ytBzifDMvV6dpVrLC5ugXm17" }, { "id": "did:cheqd:testnet:xcWigjiDhDTaBGRX#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:xcWigjiDhDTaBGRX", - "verification_material": "z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei" + "verification_material": "z6MkirAS5q6B4EQD1Vhe5vXFmorUpex6rLjuSH9eVYCHWK26" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json index 89e5cd61e..81f879fce 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json +++ b/tests/upgrade/unit/generated/payload/indy_style/existing/v2/diddoc_2.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X" + "verification_material": "z6MknYedstxzbpY2ieWByJ39zoBCxAUhEnqgzAjWttPq8xou" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w" + "verification_material": "z6Mkeu8apRGvw3LHEkxp7XGzWoHedYJEgpzQ5Xv7k7j8cqsK" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy" + "verification_material": "z6MkoD8YhYJseVZyBsXNN9iPemNRQUCgHwqkcCEgJT7pBv2M" }, { "id": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:SWFYv4aPjJtxZ1q2", - "verification_material": "z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL" + "verification_material": "z6MkkwHQ4yEBr4EvNXcrKLBJTX1tVYdyVwTm3w4ZKtGXFjKi" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json index 524199030..31f865bfb 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json +++ b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "z4xhmb8vKgCN24a3kRyai5F8eMSgkuqSA8ABPo8mYJSd" + "verification_material": "z6MkeXDkMqPMfDgq8ZQkRzwRZAo8TviYAo5nr957E56nTXE1" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "z6L84sd16WVYPQYQ6XXwdPtg2SEkxyj2CrsGGQ3MzkFP5" + "verification_material": "z6MkjnP7TsFXr32rX3EoD6uUEzE2Fp2pPcGZYtBCEKL1fUAT" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "zADATkCngJDTbzxhzYtjC8ndzu5wWWbrH8UwQMowfcYDj" + "verification_material": "z6MkofRWLT37dkx57TYhETh2ytBzifDMvV6dpVrLC5ugXm17" }, { "id": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:7Hty8uGafcEsU7EpJEAPUC", - "verification_material": "z5PuPVaqjigujtzrwQMZQviJV15gFSTVYkGEifGEGb6Ei" + "verification_material": "z6MkirAS5q6B4EQD1Vhe5vXFmorUpex6rLjuSH9eVYCHWK26" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json index 181b2d2b8..5391aa302 100644 --- a/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json +++ b/tests/upgrade/unit/generated/payload/indy_style/expected/v2/diddoc_2.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "z96PbHeiZGH3Zc9fVHj5K9hdD8bCqpubLJ9pb4cRpDk2X" + "verification_material": "z6MknYedstxzbpY2ieWByJ39zoBCxAUhEnqgzAjWttPq8xou" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "zSsYEB2VbVqp8G87RxK9fhjeoy2PGwk3PX1Buqm7hd5w" + "verification_material": "z6Mkeu8apRGvw3LHEkxp7XGzWoHedYJEgpzQ5Xv7k7j8cqsK" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "z9ksW7J4SJx5W5NgfgakYofpRatvpt4bPvBKkUB9oGhEy" + "verification_material": "z6MkoD8YhYJseVZyBsXNN9iPemNRQUCgHwqkcCEgJT7pBv2M" }, { "id": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5aayeuitt5VD2VWbL2zopg", - "verification_material": "z7V2MUiykWWkTG2n9dmDTcRTtfyN864DQMv9dVcJWLWYL" + "verification_material": "z6MkkwHQ4yEBr4EvNXcrKLBJTX1tVYdyVwTm3w4ZKtGXFjKi" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json index 022b03cf0..cc38c72ef 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_lowcase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" + "verification_material": "z6Mkw16FU8WVLAqScmkaj1AHHfGVSzAjsbccjuxYGiP2ZSiN" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" + "verification_material": "z6Mks54F5e3v1uDtdGTmFRd71ed19h56SyABVL7SwPoSk4Fq" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" + "verification_material": "z6MkfsqJdjYSsuBSL3osT7a9VRAMhKPztqvA2otbr6cKWvRJ" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" + "verification_material": "z6MknyD9Tm3NN6khHabqkt5jEwfSaRCXM4stL6UhJjwrgYZG" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json index 8382f2bad..8e0dcb6f9 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_mixed.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq" + "verification_material": "z6Mkhu3KZFd39BSD8kDNbiWyXsXXZ9uy8qMNrqbrkkV9z4YD" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ" + "verification_material": "z6MkwUMt89ooTRMGDrPXX1Uei93ouEhuNpgcXtRaazE33Dcw" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP" + "verification_material": "z6MksenQTTP7bs4HxfAisuJbh6qxW9ffucX5p5tpPkeQ4kmm" }, { "id": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:C1594E93-dEd6-4244-9CC4-74af38dab09d", - "verification_material": "zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh" + "verification_material": "z6MkvLgz1avSwuTpMn9KwHR9edSrkJWypozqJgcLkRc3Ahn5" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json index 3fae1f88b..1bf03c3f9 100644 --- a/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json +++ b/tests/upgrade/unit/generated/payload/uuid/existing/v2/diddoc_upper.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF" + "verification_material": "z6Mkk9TamLok1PQjyBWTMqbJQHSXJKFv1HNCGhfoJehKLQSd" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn" + "verification_material": "z6MkrsTjbK78f9j51EDUsHtPpc76A23h7i5V3x1cTUbtRy5A" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk" + "verification_material": "z6MkssCp5pzQWtJnHQSSjfkzp5hz2haR2vnfPaAAv7uAjBL8" }, { "id": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:FDFECBD2-A84A-4FB2-B634-E3FDB00F2ABC", - "verification_material": "zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr" + "verification_material": "z6MkvHQLprMMxhavc1DTsbWgDFDdF5FaCVuZyPHuahpMMDUE" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json index 022b03cf0..cc38c72ef 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_lowcase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" + "verification_material": "z6Mkw16FU8WVLAqScmkaj1AHHfGVSzAjsbccjuxYGiP2ZSiN" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" + "verification_material": "z6Mks54F5e3v1uDtdGTmFRd71ed19h56SyABVL7SwPoSk4Fq" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" + "verification_material": "z6MkfsqJdjYSsuBSL3osT7a9VRAMhKPztqvA2otbr6cKWvRJ" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" + "verification_material": "z6MknyD9Tm3NN6khHabqkt5jEwfSaRCXM4stL6UhJjwrgYZG" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json index 1a2811e77..3b1c42bd6 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_mixed.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "z4SnGy1Nbodwk2FNfv9Z8gmyXjae7ix72ApgvvUX94qkq" + "verification_material": "z6Mkhu3KZFd39BSD8kDNbiWyXsXXZ9uy8qMNrqbrkkV9z4YD" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "zJ26qXuZN7sro7MYpqSWos3Vp5fS3xwSFqsWekiG27zqZ" + "verification_material": "z6MkwUMt89ooTRMGDrPXX1Uei93ouEhuNpgcXtRaazE33Dcw" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "zECXMsD8gGKZprAL2CLLkr1HxgaPpVjGj84ytZUgP9XzP" + "verification_material": "z6MksenQTTP7bs4HxfAisuJbh6qxW9ffucX5p5tpPkeQ4kmm" }, { "id": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:a35d7486-1749-55bf-96d4-683958a9a884", - "verification_material": "zGtRwRLg1cMyMFHJdFiTJoXtrvjF8QvkUcfhQv9e2FUzh" + "verification_material": "z6MkvLgz1avSwuTpMn9KwHR9edSrkJWypozqJgcLkRc3Ahn5" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json index 8fd2f48f5..c299227cd 100644 --- a/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json +++ b/tests/upgrade/unit/generated/payload/uuid/expected/v2/diddoc_upper.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "z6hCYB6ZJfqvGrgfkgGdTZBtXUjz4bQ7qagksUNjJRBfF" + "verification_material": "z6Mkk9TamLok1PQjyBWTMqbJQHSXJKFv1HNCGhfoJehKLQSd" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "zDRCh14rhKcEbtjNnBivYyWZ6LSmqhpq8Mw6gdCdsWkHn" + "verification_material": "z6MkrsTjbK78f9j51EDUsHtPpc76A23h7i5V3x1cTUbtRy5A" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "zEQwmVajyBLpKAubk46o9xz9zD8JZd3YJhZFF5qw9oxYk" + "verification_material": "z6MkssCp5pzQWtJnHQSSjfkzp5hz2haR2vnfPaAAv7uAjBL8" }, { "id": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:d87f512c-cbfc-58d1-b995-f526589ad808", - "verification_material": "zGq9JEc6vdA6TVWNmC2YqN9fdRVyincfDHNNykRrLRzgr" + "verification_material": "z6MkvHQLprMMxhavc1DTsbWgDFDdF5FaCVuZyPHuahpMMDUE" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json b/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json index 1eb22ea1a..c68a908e0 100644 --- a/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json +++ b/tests/upgrade/unit/generated/payload/version_id/existing/v2/diddoc_hash.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" + "verification_material": "z6Mkw16FU8WVLAqScmkaj1AHHfGVSzAjsbccjuxYGiP2ZSiN" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" + "verification_material": "z6Mks54F5e3v1uDtdGTmFRd71ed19h56SyABVL7SwPoSk4Fq" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" + "verification_material": "z6MkfsqJdjYSsuBSL3osT7a9VRAMhKPztqvA2otbr6cKWvRJ" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" + "verification_material": "z6MknyD9Tm3NN6khHabqkt5jEwfSaRCXM4stL6UhJjwrgYZG" } ], "authentication": [ diff --git a/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json b/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json index 0ceebd1fc..656708ea9 100644 --- a/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json +++ b/tests/upgrade/unit/generated/payload/version_id/expected/v2/diddoc_hash.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zHYqCstG3zdLyWGut3SCSSZiVdQttTiNG3u3cSSR1eDvz" + "verification_material": "z6Mkw16FU8WVLAqScmkaj1AHHfGVSzAjsbccjuxYGiP2ZSiN" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "zDcoCVPoUgMjRWmd4ZrfGAZ51L7oF35upoKCX77qRpqUT" + "verification_material": "z6Mks54F5e3v1uDtdGTmFRd71ed19h56SyABVL7SwPoSk4Fq" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z2RaG3VJ1YMgyDYyAmYcJeKcMsk89UxfoLnyg1peJbhdv" + "verification_material": "z6MkfsqJdjYSsuBSL3osT7a9VRAMhKPztqvA2otbr6cKWvRJ" }, { "id": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:e77cc679-ada0-4a71-8738-918f388fcbb5", - "verification_material": "z9Wx6sWnw2ZGEB5m95K7tPr7SkqvfwBdXe5ZmUTyqmKmt" + "verification_material": "z6MknyD9Tm3NN6khHabqkt5jEwfSaRCXM4stL6UhJjwrgYZG" } ], "authentication": [ From bb4e178ebad60cd92f4ecc5138e7156eb33107cf Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 30 Dec 2022 20:37:56 +0300 Subject: [PATCH 03/42] Makes linter happy --- app/migrations/helpers/protobuf.go | 4 ++-- app/migrations/helpers/protobuf_test.go | 2 +- x/did/tests/setup/utils.go | 4 ++-- x/did/types/constant_test.go | 4 ++-- x/did/types/diddoc_verification_method_test.go | 2 -- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/migrations/helpers/protobuf.go b/app/migrations/helpers/protobuf.go index 09e595232..22409b4d7 100644 --- a/app/migrations/helpers/protobuf.go +++ b/app/migrations/helpers/protobuf.go @@ -12,8 +12,8 @@ func BuildEd25519VerificationKey2020VerificationMaterial(publicKey string) (stri if err != nil { return "", err } - multicodec := []byte{0xed, 0x01} - multicodecAndKey := append(multicodec, publicKeyBytes...) + multicodecAndKey := []byte{0xed, 0x01} + multicodecAndKey = append(multicodecAndKey, publicKeyBytes...) keyStr, err := multibase.Encode(multibase.Base58BTC, multicodecAndKey) return keyStr, err } diff --git a/app/migrations/helpers/protobuf_test.go b/app/migrations/helpers/protobuf_test.go index 9a6ca3a76..6d558cffe 100644 --- a/app/migrations/helpers/protobuf_test.go +++ b/app/migrations/helpers/protobuf_test.go @@ -12,7 +12,7 @@ var _ = DescribeTable( Expect(key).To(Equal(v2PubKey)) }, - Entry("Valid: General convertion", "zDw21irq4wBfyTvxAG9L8PQj6b79iyTyzyV6XVj9SfyRR", "z6MksPH4K75WGjASaRnrwiHyEWH6QgRaPMEMfW1TL17TbCCo"), + Entry("Valid: General conversion", "zDw21irq4wBfyTvxAG9L8PQj6b79iyTyzyV6XVj9SfyRR", "z6MksPH4K75WGjASaRnrwiHyEWH6QgRaPMEMfW1TL17TbCCo"), // Mainnet case Entry("Valid: Real case", "zF7rhDBfUt9d1gJPjx7s1JXfUY7oVWkYsWCo7fztHtepn", "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA"), ) diff --git a/x/did/tests/setup/utils.go b/x/did/tests/setup/utils.go index 53870266f..f2b6f142e 100644 --- a/x/did/tests/setup/utils.go +++ b/x/did/tests/setup/utils.go @@ -64,8 +64,8 @@ func GenerateKeyPair() KeyPair { } func BuildEd25519VerificationKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { - multicodec := []byte{0xed, 0x01} - multicodecAndKey := append(multicodec, publicKey...) + multicodecAndKey := []byte{0xed, 0x01} + multicodecAndKey = append(multicodecAndKey, publicKey...) keyStr, _ := multibase.Encode(multibase.Base58BTC, multicodecAndKey) return keyStr } diff --git a/x/did/types/constant_test.go b/x/did/types/constant_test.go index 234f243d5..87e8683ed 100644 --- a/x/did/types/constant_test.go +++ b/x/did/types/constant_test.go @@ -44,11 +44,11 @@ var ( var ( // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9202d564c12 - ValidEd25519VerificationMaterial = "z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3" + ValidEd25519VerificationMaterial = "z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3" // bytes: 020076a50fe5e0c3616c1b4d85a308c104a1c99d8d3d92c18c1f4e0179202d564c12 InvalidEd25519VerificationMaterialBadMulticodec = "z3dEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9 - InvalidEd25519VerificationMaterialBadlength = "zBm3emgJHyjidq7HsZFTx3PCjYHayy7SxisBeVCa4" + InvalidEd25519VerificationMaterialBadlength = "zBm3emgJHyjidq7HsZFTx3PCjYHayy7SxisBeVCa4" ValidJWKKeyVerificationMaterial = string(ValidPublicKeyJWK) InvalidJWKKeyVerificationMaterial = string(InvalidPublicKeyJWK) diff --git a/x/did/types/diddoc_verification_method_test.go b/x/did/types/diddoc_verification_method_test.go index ae544dab2..0937078dc 100644 --- a/x/did/types/diddoc_verification_method_test.go +++ b/x/did/types/diddoc_verification_method_test.go @@ -9,7 +9,6 @@ import ( "crypto/rsa" "encoding/json" - . "github.com/cheqd/cheqd-node/x/did/types" testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/lestrrat-go/jwx/jwk" . "github.com/onsi/ginkgo/v2" @@ -281,7 +280,6 @@ var _ = Describe("Validation RSA Signature in verification method", func() { }) var _ = DescribeTable("Verification Method material validation tests", func(testCase VerificationMethodTestCase) { - err := testCase.vm.Validate(testCase.baseDid, testCase.allowedNamespaces) if testCase.isValid { From 826e00fbe6d9dfb4b2b7a4537362cceceef3be6d Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 30 Dec 2022 20:38:30 +0300 Subject: [PATCH 04/42] Makes linter happy --- x/did/types/diddoc_verification_method_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/did/types/diddoc_verification_method_test.go b/x/did/types/diddoc_verification_method_test.go index 0937078dc..cc12d65c3 100644 --- a/x/did/types/diddoc_verification_method_test.go +++ b/x/did/types/diddoc_verification_method_test.go @@ -9,6 +9,7 @@ import ( "crypto/rsa" "encoding/json" + . "github.com/cheqd/cheqd-node/x/did/types" testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/lestrrat-go/jwx/jwk" . "github.com/onsi/ginkgo/v2" From 9d35ffe1d43e0e745b846aa58fe0fed25ab2b89f Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Fri, 30 Dec 2022 20:44:35 +0300 Subject: [PATCH 05/42] Makes linter happy --- .../types/diddoc_verification_method_test.go | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/x/did/types/diddoc_verification_method_test.go b/x/did/types/diddoc_verification_method_test.go index cc12d65c3..8fb180e3d 100644 --- a/x/did/types/diddoc_verification_method_test.go +++ b/x/did/types/diddoc_verification_method_test.go @@ -9,15 +9,15 @@ import ( "crypto/rsa" "encoding/json" - . "github.com/cheqd/cheqd-node/x/did/types" testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" + didtypes "github.com/cheqd/cheqd-node/x/did/types" "github.com/lestrrat-go/jwx/jwk" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) type VerificationMethodTestCase struct { - vm VerificationMethod + vm didtypes.VerificationMethod baseDid string allowedNamespaces []string isValid bool @@ -38,7 +38,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Verification method with expected multibase key", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -51,7 +51,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Verification method with expected jwk key", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -64,7 +64,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Id has expected DID as a base", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -78,7 +78,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Id does not have expected DID as a base", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -92,7 +92,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Namespace is allowed", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:mainnet:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -105,7 +105,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Namespace is not allowed", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:mainnet:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -118,7 +118,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "JWK key has expected format", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -129,7 +129,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "JWK key has unexpected format", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -141,7 +141,7 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Entry( "Ed25519 key has unexpected format", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -170,14 +170,14 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { It("is valid", func() { pubKeyStr := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) - vm := VerificationMethod{ + vm := didtypes.VerificationMethod{ Id: "", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "", VerificationMaterial: pubKeyStr, } - err = VerifySignature(vm, msgBytes, signature) + err = didtypes.VerifySignature(vm, msgBytes, signature) Expect(err).To(BeNil()) }) }) @@ -190,14 +190,14 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { jsonPayload, err := json.MarshalIndent(jwkKey, "", " ") Expect(err).To(BeNil()) - vm2 := VerificationMethod{ + vm2 := didtypes.VerificationMethod{ Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", VerificationMaterial: string(jsonPayload), } - err = VerifySignature(vm2, msgBytes, signature) + err = didtypes.VerifySignature(vm2, msgBytes, signature) Expect(err).To(BeNil()) }) }) @@ -229,14 +229,14 @@ var _ = Describe("Validation ECDSA Signature in verification method", func() { jsonPayload, err := json.MarshalIndent(jwkKey, "", " ") Expect(err).To(BeNil()) - vm := VerificationMethod{ + vm := didtypes.VerificationMethod{ Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", VerificationMaterial: string(jsonPayload), } - err = VerifySignature(vm, msgBytes, signature) + err = didtypes.VerifySignature(vm, msgBytes, signature) Expect(err).To(BeNil()) }) }) @@ -267,14 +267,14 @@ var _ = Describe("Validation RSA Signature in verification method", func() { jsonPayload, err := json.Marshal(jwkKey) Expect(err).To(BeNil()) - vm2 := VerificationMethod{ + vm2 := didtypes.VerificationMethod{ Id: "", VerificationMethodType: "JsonWebKey2020", Controller: "", VerificationMaterial: string(jsonPayload), } - err = VerifySignature(vm2, msgBytes, signature) + err = didtypes.VerifySignature(vm2, msgBytes, signature) Expect(err).To(BeNil()) }) }) @@ -294,7 +294,7 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Entry( "Valid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -307,7 +307,7 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Entry( "Valid JsonWebKey2020 verification material", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -320,7 +320,7 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Entry( "Invalid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -333,7 +333,7 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Entry( "Invalid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", @@ -346,7 +346,7 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Entry( "Invalid JsonWebKey2020 verification material", VerificationMethodTestCase{ - vm: VerificationMethod{ + vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", From 1fc2abfa80aea6afa26aa320d02a524e1de7144a Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Sat, 31 Dec 2022 10:30:58 +0300 Subject: [PATCH 06/42] Fix integration tests --- tests/integration/cli_diddoc_test.go | 5 ++--- tests/integration/cli_resource_test.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index 3703f74e9..f6001bede 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -67,8 +67,7 @@ var _ = Describe("cheqd cli - positive did", func() { newPubKey, newPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - newPubKeyMultibase58, err := multibase.Encode(multibase.Base58BTC, newPubKey) - Expect(err).To(BeNil()) + newPubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(newPubKey) payload2 := types.MsgUpdateDidDocPayload{ Id: did, @@ -77,7 +76,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + newPubKeyMultibase58 + "\"}", + VerificationMaterial: newPubKeyMultibase58, }, }, Authentication: []string{keyID}, diff --git a/tests/integration/cli_resource_test.go b/tests/integration/cli_resource_test.go index 96c2cfebf..ae7864faa 100644 --- a/tests/integration/cli_resource_test.go +++ b/tests/integration/cli_resource_test.go @@ -44,7 +44,7 @@ var _ = Describe("cheqd cli - positive resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: "{\"publicKeyMultibase\": \"" + string(pubKeyMultibase58) + "\"}", + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, From b417a8dd1de44e3d97cd084db7a6f8f34115812b Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Sat, 31 Dec 2022 11:14:53 +0300 Subject: [PATCH 07/42] Remove unused imports --- tests/integration/cli_diddoc_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index f6001bede..a7378c847 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -12,7 +12,6 @@ import ( cli_types "github.com/cheqd/cheqd-node/x/did/client/cli" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - "github.com/multiformats/go-multibase" testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" . "github.com/onsi/ginkgo/v2" From 875bbf45cc9b886c2dce7b7f71a0082202dbd15a Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Sat, 31 Dec 2022 11:34:57 +0300 Subject: [PATCH 08/42] Change comparision check --- tests/integration/cli_diddoc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index a7378c847..edcc8fd61 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -110,7 +110,7 @@ var _ = Describe("cheqd cli - positive did", func() { Expect(didDoc.VerificationMethod[0].Id).To(BeEquivalentTo(keyID)) Expect(didDoc.VerificationMethod[0].VerificationMethodType).To(BeEquivalentTo("Ed25519VerificationKey2020")) Expect(didDoc.VerificationMethod[0].Controller).To(BeEquivalentTo(did)) - Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo("{\"publicKeyMultibase\": \"" + newPubKeyMultibase58 + "\"}")) + Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo(newPubKeyMultibase58)) // Check that DIDDoc is not deactivated Expect(resp.Value.Metadata.Deactivated).To(BeFalse()) From 924cea9f5a8814c6e23cfc19db791596c733665d Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Sat, 31 Dec 2022 12:15:16 +0300 Subject: [PATCH 09/42] Add changes for generated files --- .../generated/post/query - diddoc/diddoc_indy_16.json | 8 ++++---- .../generated/post/query - diddoc/diddoc_indy_32.json | 8 ++++---- .../post/query - diddoc/diddoc_uuid_lowcase.json | 8 ++++---- .../generated/post/query - diddoc/diddoc_uuid_mixed.json | 8 ++++---- .../post/query - diddoc/diddoc_uuid_uppercase.json | 8 ++++---- .../generated/post/update - diddoc/diddoc_indy_16.json | 6 +++--- .../post/update - diddoc/diddoc_uuid_lowcase.json | 8 ++++---- .../post/update - diddoc/diddoc_uuid_uppercase.json | 8 ++++---- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_16.json b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_16.json index 9b4639d59..d9e220b8b 100644 --- a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_16.json +++ b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_16.json @@ -13,19 +13,19 @@ "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zBNy7xYrzNb25mbVFP5hVZXwJZ7RD16yJSoya82qe3Jra\"}" + "verification_material": "z6MkpqEAYo7Ri8WYt6Kx4efLQdVJNgh4QzDf8ptVxJoexXdx" }, { "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zC4mnpocVYbywi32srkHzRdy7LEXQG4TM8YtCTPXWnza1\"}" + "verification_material": "z6MkqX2qR3rvt9UQpXsaYKFqGjX79ooFfwhhpZo8HfVXiDMP" }, { "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zC1CAqqp2tQooisYtTh1oULGzKyRNQbsUtyqoh2neWPta\"}" + "verification_material": "z6MkqTTDS64UDxJGqNPb9FyeKRpz9YhDpV7qazkjXJkfRcfx" } ], "authentication": [ @@ -61,5 +61,5 @@ "also_known_as": [ "alias-3" ] - } + } } \ No newline at end of file diff --git a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_32.json b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_32.json index 592ecb10d..58f05c605 100644 --- a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_32.json +++ b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_indy_32.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b", - "verification_material": "{\"publicKeyMultibase\":\"zEZ673G4y1tzG7ceqH9frgj2hJj14EiDjho3BwC9hcuz8\"}" + "verification_material": "z6Mkt1M9dWKQMSUjE7VXxidhXpah8JGuebU6Pox7mU7iY8mW" }, { "id": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b", - "verification_material": "{\"publicKeyMultibase\":\"z9uXTvgTyWZjr79CVgkgdzRSzApn7x4asDDMqDDro8D3k\"}" + "verification_material": "z6MkoMnWWviQr7EKDe3CNKeUqWzyzQ3yMwqDuEGm3Vpp3Rq8" }, { "id": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b", - "verification_material": "{\"publicKeyMultibase\":\"zCnaC3GEjg3dmGPGo3svUw8Lytu3HWJGpTVsVXnBUQJca\"}" + "verification_material": "z6MkrEqEdWVB1b8ENt7VjStKnDtyiUK8vBXB9WnRN49VKXPx" }, { "id": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:Nqoxg85PKyr9nPstjTpg5b", - "verification_material": "{\"publicKeyMultibase\":\"z6yL88rhPLU4nFAUGLv1VLiTTXnV4At64PPJwCrEHjTw\"}" + "verification_material": "z6MkeZENiP78isxXtk1AwusrLSGTH74LU48SkQJEmUpFCxFK" } ], "authentication": [ diff --git a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_lowcase.json b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_lowcase.json index 46eba3f86..9cf3b8454 100644 --- a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_lowcase.json +++ b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_lowcase.json @@ -14,25 +14,25 @@ "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z6nExc7qoYEoDd2DRrMpBv5ShXHYZQL3LTi2twgTm79bL\"}" + "verification_material": "z6MkkEW1CN6EsnHgjX48Xvn2mAzhLrpQpDHh9iwpmxRn2NNi" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z8GnprPBEuoBvYqJD4RbUhoFSrZMzH6rffRvCmNzEBxDT\"}" + "verification_material": "z6Mkmj3sSdRgFLgPfL8ujzZKYtoSg8dqgz72MSq8bexF7Azq" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z8iREaP6YKkK77MxojoyAgcnuJAC9reQq6mMJuxxCK523\"}" + "verification_material": "z6MknAgHAdLyfHoaDroWRNw1XiLu7jU1GXfBnnGEkEvDEHoR" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z4GCBhVhbx2ZgF1hMT2Zt3f9x17LqeR4jb83QXehsMCvt\"}" + "verification_material": "z6MkhiTEHjx3Ha49MWY48bXitkhwpgch4JK6H8xLMvftGRiG" } ], "authentication": [ diff --git a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_mixed.json b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_mixed.json index 8634fdb3f..fb45f05b4 100644 --- a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_mixed.json +++ b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_mixed.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04", - "verification_material": "{\"publicKeyMultibase\":\"z2Ebg35RKmCM4SKYBkNNiHqbK5ypdAUcjsKyLum1zpCr4\"}" + "verification_material": "z6MkfgridKfm6jqXYpNtRwLZ8w9JuZ6UaMs6ZLtGk2z1jRdS" }, { "id": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04", - "verification_material": "{\"publicKeyMultibase\":\"z2j417oT5Pyha2XKK4xYsgBv8u5pFk7HFDzbCbRUgZfc6\"}" + "verification_material": "z6MkgBK3i3hWjXC392A1kXWiXHU8if679zXbv1W8RhShUtPU" }, { "id": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04", - "verification_material": "{\"publicKeyMultibase\":\"z7THeYhdHGDHnVrffBsuXyoRKKyBZgwNjX4PYL25cEk1L\"}" + "verification_material": "z6MkkuYh8wsibknFcMWMsSsNptyK9YTR6pd6D5JUAJ3d9xni" }, { "id": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:85d9e742-be4d-59e8-9b10-5449db2e2d04", - "verification_material": "{\"publicKeyMultibase\":\"zYnoDoX5wcCKEq6ZRRkS42jigYTSEn8DNvDnWmQadtsJ\"}" + "verification_material": "z6Mkf13qp3mXH9gnMKwG6ziGu8HiW7jHefNa4w8iM3NbZ7eg" } ], "assertion_method": [ diff --git a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_uppercase.json b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_uppercase.json index 2117772c8..b911b59d3 100644 --- a/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_uppercase.json +++ b/tests/upgrade/integration/generated/post/query - diddoc/diddoc_uuid_uppercase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z3RFgcpLEM8oRi2DoK3B1FCSTAfCBKjZvBkzuxcBV4TNM\"}" + "verification_material": "z6MkgsWjD4afggHtpX4Vzc8r6HzSzEU2jcpGsmuqnt9Vyg9j" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z7JQKofgkaFFpjqJAKNWtFSKVv8kkLHhvErcNx7A6VL8p\"}" + "verification_material": "z6MkkkfNPuwBunkHrL8rzwUj6XsVji2bkAxGvsXJnP87QYvC" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z9X6yXQoNcdZD1zvpuWpicviFnqMvwaziuGbcRnBAVY3y\"}" + "verification_material": "z6MknyN27f3oxB3g8VmXb5nZU2GFcQdnMUF5bHWYG49BQkqM" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"zHkQBWRFoUUizMNscNNGQhMhtt2zMK6UV4YFJ9aeBfZbj\"}" + "verification_material": "z6MkwCfE6fWEp2DTTsiK3wEFYTFthcGCiyiqkZADyrcCanP7" } ], "authentication": [ diff --git a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_indy_16.json b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_indy_16.json index 29d182ee0..1c9c7dbc8 100644 --- a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_indy_16.json +++ b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_indy_16.json @@ -13,19 +13,19 @@ "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zBNy7xYrzNb25mbVFP5hVZXwJZ7RD16yJSoya82qe3Jra\"}" + "verification_material": "z6MkpqEAYo7Ri8WYt6Kx4efLQdVJNgh4QzDf8ptVxJoexXdx" }, { "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zC4mnpocVYbywi32srkHzRdy7LEXQG4TM8YtCTPXWnza1\"}" + "verification_material": "z6MkqX2qR3rvt9UQpXsaYKFqGjX79ooFfwhhpZo8HfVXiDMP" }, { "id": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:5rjaLzcffhGUH4nt4fyfAg", - "verification_material": "{\"publicKeyMultibase\":\"zC1CAqqp2tQooisYtTh1oULGzKyRNQbsUtyqoh2neWPta\"}" + "verification_material": "z6MkqTTDS64UDxJGqNPb9FyeKRpz9YhDpV7qazkjXJkfRcfx" } ], "authentication": [ diff --git a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_lowcase.json b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_lowcase.json index b587b2895..5c3d835b3 100644 --- a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_lowcase.json +++ b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_lowcase.json @@ -14,25 +14,25 @@ "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z6nExc7qoYEoDd2DRrMpBv5ShXHYZQL3LTi2twgTm79bL\"}" + "verification_material": "z6MkkEW1CN6EsnHgjX48Xvn2mAzhLrpQpDHh9iwpmxRn2NNi" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z8GnprPBEuoBvYqJD4RbUhoFSrZMzH6rffRvCmNzEBxDT\"}" + "verification_material": "z6Mkmj3sSdRgFLgPfL8ujzZKYtoSg8dqgz72MSq8bexF7Azq" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z8iREaP6YKkK77MxojoyAgcnuJAC9reQq6mMJuxxCK523\"}" + "verification_material": "z6MknAgHAdLyfHoaDroWRNw1XiLu7jU1GXfBnnGEkEvDEHoR" }, { "id": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:2e5ca092-8264-47c7-9216-8b36e01e5554", - "verification_material": "{\"publicKeyMultibase\":\"z4GCBhVhbx2ZgF1hMT2Zt3f9x17LqeR4jb83QXehsMCvt\"}" + "verification_material": "z6MkhiTEHjx3Ha49MWY48bXitkhwpgch4JK6H8xLMvftGRiG" } ], "authentication": [ diff --git a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_uppercase.json b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_uppercase.json index 859397bf6..9da847232 100644 --- a/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_uppercase.json +++ b/tests/upgrade/integration/generated/post/update - diddoc/diddoc_uuid_uppercase.json @@ -13,25 +13,25 @@ "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-1", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z3RFgcpLEM8oRi2DoK3B1FCSTAfCBKjZvBkzuxcBV4TNM\"}" + "verification_material": "z6MkgsWjD4afggHtpX4Vzc8r6HzSzEU2jcpGsmuqnt9Vyg9j" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-2", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z7JQKofgkaFFpjqJAKNWtFSKVv8kkLHhvErcNx7A6VL8p\"}" + "verification_material": "z6MkkkfNPuwBunkHrL8rzwUj6XsVji2bkAxGvsXJnP87QYvC" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-3", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"z9X6yXQoNcdZD1zvpuWpicviFnqMvwaziuGbcRnBAVY3y\"}" + "verification_material": "z6MknyN27f3oxB3g8VmXb5nZU2GFcQdnMUF5bHWYG49BQkqM" }, { "id": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4#key-4", "verificationMethodType": "Ed25519VerificationKey2020", "controller": "did:cheqd:testnet:91e5f0cf-5f1e-5c19-97d3-d313e84033b4", - "verification_material": "{\"publicKeyMultibase\":\"zHkQBWRFoUUizMNscNNGQhMhtt2zMK6UV4YFJ9aeBfZbj\"}" + "verification_material": "z6MkwCfE6fWEp2DTTsiK3wEFYTFthcGCiyiqkZADyrcCanP7" } ], "authentication": [ From ae98ced2e2320712d2fa3c83af97191a8fabe75e Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 18:47:57 +0200 Subject: [PATCH 10/42] Added Ed25519VerificationKey2018 support & enhanced tests --- app/migrations/helpers/protobuf.go | 10 +- app/migrations/helpers/protobuf_test.go | 5 +- app/migrations/migration_did_protobuf.go | 4 +- tests/integration/cli/tx.go | 2 +- tests/integration/cli_diddoc_negative_test.go | 72 ++--- .../cli_diddoc_pricing_negative_test.go | 18 +- tests/integration/cli_diddoc_pricing_test.go | 40 +-- tests/integration/cli_diddoc_test.go | 272 +++++++++++++++++- .../integration/cli_resource_negative_test.go | 40 +-- .../cli_resource_pricing_negative_test.go | 12 +- .../integration/cli_resource_pricing_test.go | 38 +-- tests/integration/cli_resource_test.go | 16 +- x/did/tests/create_diddoc_test.go | 75 +++-- x/did/tests/setup/setup_create_diddoc.go | 2 +- x/did/tests/setup/utils.go | 14 +- x/did/tests/tests_suite_test.go | 2 +- x/did/tests/update_diddoc_test.go | 26 +- x/did/types/constant_test.go | 26 +- x/did/types/diddoc_diddoc_test.go | 24 +- x/did/types/diddoc_verification_method.go | 23 +- .../types/diddoc_verification_method_test.go | 160 ++++++++--- x/did/types/tx_msg_create_diddoc_test.go | 12 +- x/did/types/tx_msg_update_did_doc_test.go | 6 +- x/did/types/types_test.go | 2 +- x/did/types/validate.go | 11 + x/did/utils/encoding.go | 16 +- x/did/utils/utils_suite_test.go | 2 +- 27 files changed, 665 insertions(+), 265 deletions(-) diff --git a/app/migrations/helpers/protobuf.go b/app/migrations/helpers/protobuf.go index 22409b4d7..a81210c29 100644 --- a/app/migrations/helpers/protobuf.go +++ b/app/migrations/helpers/protobuf.go @@ -4,7 +4,7 @@ import ( "github.com/multiformats/go-multibase" ) -func BuildEd25519VerificationKey2020VerificationMaterial(publicKey string) (string, error) { +func GenerateEd25519VerificationKey2020VerificationMaterial(publicKey string) (string, error) { encoding, publicKeyBytes, err := multibase.Decode(publicKey) if encoding != multibase.Base58BTC { panic("Only Base58BTC encoding is supported") @@ -12,8 +12,8 @@ func BuildEd25519VerificationKey2020VerificationMaterial(publicKey string) (stri if err != nil { return "", err } - multicodecAndKey := []byte{0xed, 0x01} - multicodecAndKey = append(multicodecAndKey, publicKeyBytes...) - keyStr, err := multibase.Encode(multibase.Base58BTC, multicodecAndKey) - return keyStr, err + publicKeyMultibaseBytes := []byte{0xed, 0x01} + publicKeyMultibaseBytes = append(publicKeyMultibaseBytes, publicKeyBytes...) + + return multibase.Encode(multibase.Base58BTC, publicKeyMultibaseBytes) } diff --git a/app/migrations/helpers/protobuf_test.go b/app/migrations/helpers/protobuf_test.go index 6d558cffe..9309f7c01 100644 --- a/app/migrations/helpers/protobuf_test.go +++ b/app/migrations/helpers/protobuf_test.go @@ -6,9 +6,10 @@ import ( ) var _ = DescribeTable( - "Test BuildEd25519VerificationKey2020VerificationMaterial", + "Test GenerateEd25519VerificationKey2020VerificationMaterial", func(v1PubKey string, v2PubKey string) { - key, _ := BuildEd25519VerificationKey2020VerificationMaterial(v1PubKey) + key, err := GenerateEd25519VerificationKey2020VerificationMaterial(v1PubKey) + Expect(err).To(BeNil()) Expect(key).To(Equal(v2PubKey)) }, diff --git a/app/migrations/migration_did_protobuf.go b/app/migrations/migration_did_protobuf.go index 3d9bfbaf8..4dbe200d1 100644 --- a/app/migrations/migration_did_protobuf.go +++ b/app/migrations/migration_did_protobuf.go @@ -142,7 +142,7 @@ func MigrateType(t string) string { case didtypesv1.Ed25519VerificationKey2020: return didtypes.Ed25519VerificationKey2020Type case didtypesv1.JSONWebKey2020: - return didtypes.JSONWebKey2020Type + return didtypes.JsonWebKey2020Type default: panic("Unknown type") } @@ -162,7 +162,7 @@ func MigrateVerificationMaterial(vm *didtypesv1.VerificationMethod) string { return string(res) case didtypesv1.Ed25519VerificationKey2020: - pkMulti, err := helpers.BuildEd25519VerificationKey2020VerificationMaterial(vm.PublicKeyMultibase) + pkMulti, err := helpers.GenerateEd25519VerificationKey2020VerificationMaterial(vm.PublicKeyMultibase) if err != nil { panic(err) } diff --git a/tests/integration/cli/tx.go b/tests/integration/cli/tx.go index 3cb164d44..fa0990195 100644 --- a/tests/integration/cli/tx.go +++ b/tests/integration/cli/tx.go @@ -18,7 +18,7 @@ var CLITxParams = []string{ "--yes", } -var CLIGasParams = []string{ +var CliGasParams = []string{ "--gas", Gas, "--gas-adjustment", GasAdjustment, "--gas-prices", GasPrices, diff --git a/tests/integration/cli_diddoc_negative_test.go b/tests/integration/cli_diddoc_negative_test.go index 2327276f4..8d05547bf 100644 --- a/tests/integration/cli_diddoc_negative_test.go +++ b/tests/integration/cli_diddoc_negative_test.go @@ -33,7 +33,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -56,7 +56,7 @@ var _ = Describe("cheqd cli - negative did", func() { }, } - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -67,7 +67,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey2) + pubKeyMultibase582 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -93,35 +93,35 @@ var _ = Describe("cheqd cli - negative did", func() { AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create diddoc with missing cli arguments")) // Fail to create a new DID Doc with missing cli arguments // a. missing payload, sign inputs and account - _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, []cli_types.SignInput{}, "", cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, []cli_types.SignInput{}, "", cli.CliGasParams) Expect(err).ToNot(BeNil()) // b. missing payload, sign inputs - _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) // c. missing payload, account - _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, signInputs2, "", cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, signInputs2, "", cli.CliGasParams) // d. missing sign inputs, account - _, err = cli.CreateDidDoc(tmpDir, payload2, []cli_types.SignInput{}, "", cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload2, []cli_types.SignInput{}, "", cli.CliGasParams) // e. missing payload - _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, signInputs2, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, types.MsgCreateDidDocPayload{}, signInputs2, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) // f. missing sign inputs - _, err = cli.CreateDidDoc(tmpDir, payload2, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload2, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) // g. missing account - _, err = cli.CreateDidDoc(tmpDir, payload2, signInputs2, "", cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload2, signInputs2, "", cli.CliGasParams) Expect(err).ToNot(BeNil()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create diddoc with sign inputs mismatch")) // Fail to create a new DID Doc with sign inputs mismatch // a. sign inputs mismatch - _, err = cli.CreateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) // b. non-existing key id @@ -130,7 +130,7 @@ var _ = Describe("cheqd cli - negative did", func() { VerificationMethodID: "non-existing-key-id", PrivKey: privKey2, }, - }, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) // c. non-matching private key @@ -139,18 +139,18 @@ var _ = Describe("cheqd cli - negative did", func() { VerificationMethodID: keyId2, PrivKey: privKey, }, - }, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_2, cli.CliGasParams) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create diddoc with non-supported VM type")) // Fail to create a new DID Doc with non-supported VM type payload3 := payload2 payload3.VerificationMethod[0].VerificationMethodType = "NonSupportedVMType" - _, err = cli.CreateDidDoc(tmpDir, payload3, signInputs2, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload3, signInputs2, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).ToNot(BeNil()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create diddoc with already existing DID")) // Fail to create a new DID Doc with already existing DID - _, err = cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) }) @@ -164,7 +164,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -188,7 +188,7 @@ var _ = Describe("cheqd cli - negative did", func() { }, } - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -208,7 +208,7 @@ var _ = Describe("cheqd cli - negative did", func() { VersionId: uuid.NewString(), } - res, err = cli.UpdateDidDoc(tmpDir, updatedPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err = cli.UpdateDidDoc(tmpDir, updatedPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -220,7 +220,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey2) + pubKeyMultibase582 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -244,7 +244,7 @@ var _ = Describe("cheqd cli - negative did", func() { }, } - res_, err := cli.CreateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + res_, err := cli.CreateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res_.Code).To(BeEquivalentTo(0)) @@ -299,41 +299,41 @@ var _ = Describe("cheqd cli - negative did", func() { AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot update diddoc with missing cli arguments")) // Fail to update the DID Doc with missing cli arguments // a. missing payload, sign inputs and account - _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, []cli_types.SignInput{}, "", cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, []cli_types.SignInput{}, "", cli.CliGasParams) Expect(err).ToNot(BeNil()) // b. missing payload, sign inputs - _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // c. missing payload, account - _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // d. missing sign inputs, account - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // e. missing payload - _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, types.MsgUpdateDidDocPayload{}, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // f. missing sign inputs - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, []cli_types.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // g. missing account - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputs, "", cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputs, "", cli.CliGasParams) Expect(err).ToNot(BeNil()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot update diddoc with sign inputs mismatch")) // Fail to update the DID Doc with sign inputs mismatch // a. sign inputs total mismatch - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsFuzzed, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsFuzzed, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // b. sign inputs invalid length - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // c. non-existing key id @@ -346,7 +346,7 @@ var _ = Describe("cheqd cli - negative did", func() { VerificationMethodID: "non-existing-key-id", PrivKey: privKey2, }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // d. non-matching private key @@ -359,7 +359,7 @@ var _ = Describe("cheqd cli - negative did", func() { VerificationMethodID: keyId, PrivKey: privKey2, }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // e. invalid private key @@ -372,7 +372,7 @@ var _ = Describe("cheqd cli - negative did", func() { VerificationMethodID: keyId2AsExtraController, PrivKey: privKey2, }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot update diddoc with a non-supported VM type")) @@ -388,7 +388,7 @@ var _ = Describe("cheqd cli - negative did", func() { }, } invalidVmTypePayload.VersionId = uuid.NewString() - _, err = cli.UpdateDidDoc(tmpDir, invalidVmTypePayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, invalidVmTypePayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot update diddoc with a non-existing DID")) @@ -396,18 +396,18 @@ var _ = Describe("cheqd cli - negative did", func() { nonExistingDid := "did:cheqd:" + network.DidNamespace + ":" + uuid.NewString() nonExistingDidPayload := deepCopierUpdateDid.DeepCopy(followingUpdatedPayload) nonExistingDidPayload.Id = nonExistingDid - _, err = cli.UpdateDidDoc(tmpDir, nonExistingDidPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, nonExistingDidPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).ToNot(BeNil()) // Finally, update the DID Doc - res, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot update diddoc with an unchanged payload")) // Fail to update the DID Doc with an unchanged payload followingUpdatedPayload.VersionId = uuid.NewString() - _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + _, err = cli.UpdateDidDoc(tmpDir, followingUpdatedPayload, signInputsAugmented, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) // TODO: Decide if this should be an error, if the DID Doc is unchanged }) diff --git a/tests/integration/cli_diddoc_pricing_negative_test.go b/tests/integration/cli_diddoc_pricing_negative_test.go index 2f0249a16..93d3dc4a4 100644 --- a/tests/integration/cli_diddoc_pricing_negative_test.go +++ b/tests/integration/cli_diddoc_pricing_negative_test.go @@ -10,9 +10,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" sdk "github.com/cosmos/cosmos-sdk/types" @@ -59,7 +59,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -197,14 +197,14 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { It("should not succeed in create diddoc message - case: gas auto, insufficient funds", func() { By("submitting create diddoc message with insufficient funds") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_6, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_6, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) It("should not succeed in update diddoc message - case: gas auto, insufficient funds", func() { By("submitting the create diddoc message") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -225,14 +225,14 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { } By("submitting update diddoc message with insufficient funds") - res, err = cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_6, cli.CLIGasParams) + res, err = cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_6, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) It("should not succeed in deactivate diddoc message - case: gas auto, insufficient funds", func() { By("submitting the create diddoc message") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -243,7 +243,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { } By("submitting deactivate diddoc message with insufficient funds") - res, err = cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_6, cli.CLIGasParams) + res, err = cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_6, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) @@ -271,7 +271,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { It("should not charge more than tax for update diddoc message - case: fixed fee", func() { By("submitting the create diddoc message") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -313,7 +313,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { It("should not charge more than tax for deactivate diddoc message - case: fixed fee", func() { By("submitting the create diddoc message") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) diff --git a/tests/integration/cli_diddoc_pricing_test.go b/tests/integration/cli_diddoc_pricing_test.go index d406cd2a5..ffff23966 100644 --- a/tests/integration/cli_diddoc_pricing_test.go +++ b/tests/integration/cli_diddoc_pricing_test.go @@ -10,9 +10,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -40,7 +40,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -132,7 +132,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(balanceBefore.Denom).To(BeEquivalentTo(types.BaseMinimalDenom)) By("submitting a create diddoc message") - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -188,7 +188,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { It("should tax update diddoc message - case: fixed fee", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -270,7 +270,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { It("should tax update diddoc message - case: gas auto", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -297,7 +297,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { By("submitting an update diddoc message") tax := feeParams.UpdateDid - res, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -352,7 +352,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { It("should tax deactivate diddoc message - case: fixed fee", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -424,7 +424,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { It("should tax deactivate diddoc message - case: gas auto", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -440,7 +440,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(balanceBefore.Denom).To(BeEquivalentTo(types.BaseMinimalDenom)) By("submitting an deactivate diddoc message") - res, err := cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + res, err := cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -496,7 +496,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { It("should tax create diddoc message with feegrant - case: fixed fee", func() { By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -509,7 +509,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(err).To(BeNil()) By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -531,13 +531,13 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) It("should tax update diddoc message with feegrant - case: fixed fee", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -558,7 +558,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { } By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -571,7 +571,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(err).To(BeNil()) By("submitting an update diddoc message") - resp, err = cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + resp, err = cli.UpdateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -593,13 +593,13 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) It("should tax deactivate diddoc message with feegrant - case: fixed fee", func() { By("submitting a create diddoc message") - resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -610,7 +610,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { } By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -623,7 +623,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(err).To(BeNil()) By("submitting a deactivate diddoc message") - resp, err = cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + resp, err = cli.DeactivateDidDoc(tmpDir, payload2, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -645,7 +645,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) }) diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index edcc8fd61..d8684697e 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -10,9 +10,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" cli_types "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" "github.com/google/uuid" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -25,8 +25,8 @@ var _ = Describe("cheqd cli - positive did", func() { tmpDir = GinkgoT().TempDir() }) - It("can create diddoc, update it and query the result", func() { - AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can create diddoc")) + It("can create diddoc, update it and query the result (Ed25519VerificationKey2020)", func() { + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can create diddoc (Ed25519VerificationKey2020)")) // Create a new DID Doc did := "did:cheqd:" + network.DidNamespace + ":" + uuid.NewString() keyID := did + "#key1" @@ -34,7 +34,7 @@ var _ = Describe("cheqd cli - positive did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -43,7 +43,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyID}, @@ -57,16 +57,16 @@ var _ = Describe("cheqd cli - positive did", func() { }, } - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) - AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can update diddoc")) + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can update diddoc (Ed25519VerificationKey2020)")) // Update the DID Doc newPubKey, newPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - newPubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(newPubKey) + newPubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(newPubKey) payload2 := types.MsgUpdateDidDocPayload{ Id: did, @@ -75,7 +75,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: newPubKeyMultibase58, + VerificationMaterial: newPubKeyMultibase, }, }, Authentication: []string{keyID}, @@ -93,11 +93,11 @@ var _ = Describe("cheqd cli - positive did", func() { }, } - res2, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res2, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res2.Code).To(BeEquivalentTo(0)) - AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query diddoc")) + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query diddoc (Ed25519VerificationKey2020)")) // Query the DID Doc resp, err := cli.QueryDidDoc(did) Expect(err).To(BeNil()) @@ -110,12 +110,254 @@ var _ = Describe("cheqd cli - positive did", func() { Expect(didDoc.VerificationMethod[0].Id).To(BeEquivalentTo(keyID)) Expect(didDoc.VerificationMethod[0].VerificationMethodType).To(BeEquivalentTo("Ed25519VerificationKey2020")) Expect(didDoc.VerificationMethod[0].Controller).To(BeEquivalentTo(did)) - Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo(newPubKeyMultibase58)) + Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo(newPubKeyMultibase)) + + // Check that DIDDoc is not deactivated + Expect(resp.Value.Metadata.Deactivated).To(BeFalse()) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can deactivate diddoc (Ed25519VerificationKey2020)")) + // Deactivate the DID Doc + payload3 := types.MsgDeactivateDidDocPayload{ + Id: did, + VersionId: uuid.NewString(), + } + + signInputs3 := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: newPrivKey, + }, + } + + res3, err := cli.DeactivateDidDoc(tmpDir, payload3, signInputs3, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res3.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query deactivated diddoc (Ed25519VerificationKey2020)")) + // Query the DID Doc + + resp2, err := cli.QueryDidDoc(did) + Expect(err).To(BeNil()) + + didDoc2 := resp2.Value.DidDoc + Expect(didDoc2).To(BeEquivalentTo(didDoc)) + + // Check that the DID Doc is deactivated + Expect(resp2.Value.Metadata.Deactivated).To(BeTrue()) + }) + + It("can create diddoc, update it and query the result (JsonWebKey2020)", func() { + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can create diddoc (JsonWebKey2020)")) + // Create a new DID Doc + did := "did:cheqd:" + network.DidNamespace + ":" + uuid.NewString() + keyID := did + "#key1" + + pubKey, privKey, err := ed25519.GenerateKey(nil) + Expect(err).To(BeNil()) + + pubKeyMultibase := testsetup.GenerateJsonWebKey2020VerificationMaterial(pubKey) + + payload := types.MsgCreateDidDocPayload{ + Id: did, + VerificationMethod: []*types.VerificationMethod{ + { + Id: keyID, + VerificationMethodType: "JsonWebKey2020", + Controller: did, + VerificationMaterial: pubKeyMultibase, + }, + }, + Authentication: []string{keyID}, + VersionId: uuid.NewString(), + } + + signInputs := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: privKey, + }, + } + + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can update diddoc (JsonWebKey2020)")) + // Update the DID Doc + newPubKey, newPrivKey, err := ed25519.GenerateKey(nil) + Expect(err).To(BeNil()) + + newPubKeyMultibase := testsetup.GenerateJsonWebKey2020VerificationMaterial(newPubKey) + + payload2 := types.MsgUpdateDidDocPayload{ + Id: did, + VerificationMethod: []*types.VerificationMethod{ + { + Id: keyID, + VerificationMethodType: "JsonWebKey2020", + Controller: did, + VerificationMaterial: newPubKeyMultibase, + }, + }, + Authentication: []string{keyID}, + VersionId: uuid.NewString(), + } + + signInputs2 := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: privKey, + }, + { + VerificationMethodID: keyID, + PrivKey: newPrivKey, + }, + } + + res2, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res2.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query diddoc (JsonWebKey2020)")) + // Query the DID Doc + resp, err := cli.QueryDidDoc(did) + Expect(err).To(BeNil()) + + didDoc := resp.Value.DidDoc + Expect(didDoc.Id).To(BeEquivalentTo(did)) + Expect(didDoc.Authentication).To(HaveLen(1)) + Expect(didDoc.Authentication[0]).To(BeEquivalentTo(keyID)) + Expect(didDoc.VerificationMethod).To(HaveLen(1)) + Expect(didDoc.VerificationMethod[0].Id).To(BeEquivalentTo(keyID)) + Expect(didDoc.VerificationMethod[0].VerificationMethodType).To(BeEquivalentTo("JsonWebKey2020")) + Expect(didDoc.VerificationMethod[0].Controller).To(BeEquivalentTo(did)) + Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo(newPubKeyMultibase)) + + // Check that DIDDoc is not deactivated + Expect(resp.Value.Metadata.Deactivated).To(BeFalse()) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can deactivate diddoc (JsonWebKey2020)")) + // Deactivate the DID Doc + payload3 := types.MsgDeactivateDidDocPayload{ + Id: did, + VersionId: uuid.NewString(), + } + + signInputs3 := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: newPrivKey, + }, + } + + res3, err := cli.DeactivateDidDoc(tmpDir, payload3, signInputs3, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res3.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query deactivated diddoc (JsonWebKey2020)")) + // Query the DID Doc + + resp2, err := cli.QueryDidDoc(did) + Expect(err).To(BeNil()) + + didDoc2 := resp2.Value.DidDoc + Expect(didDoc2).To(BeEquivalentTo(didDoc)) + + // Check that the DID Doc is deactivated + Expect(resp2.Value.Metadata.Deactivated).To(BeTrue()) + }) + + It("can create diddoc, update it and query the result (Ed25519VerificationKey2018)", func() { + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can create diddoc (Ed25519VerificationKey2018)")) + // Create a new DID Doc + did := "did:cheqd:" + network.DidNamespace + ":" + uuid.NewString() + keyID := did + "#key1" + + pubKey, privKey, err := ed25519.GenerateKey(nil) + Expect(err).To(BeNil()) + + pubKeyBase58 := testsetup.GenerateEd25519VerificationKey2018VerificationMaterial(pubKey) + + payload := types.MsgCreateDidDocPayload{ + Id: did, + VerificationMethod: []*types.VerificationMethod{ + { + Id: keyID, + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: did, + VerificationMaterial: pubKeyBase58, + }, + }, + Authentication: []string{keyID}, + VersionId: uuid.NewString(), + } + + signInputs := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: privKey, + }, + } + + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can update diddoc (Ed25519VerificationKey2018)")) + // Update the DID Doc + newPubKey, newPrivKey, err := ed25519.GenerateKey(nil) + Expect(err).To(BeNil()) + + newpubKeyBase58 := testsetup.GenerateEd25519VerificationKey2018VerificationMaterial(newPubKey) + + payload2 := types.MsgUpdateDidDocPayload{ + Id: did, + VerificationMethod: []*types.VerificationMethod{ + { + Id: keyID, + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: did, + VerificationMaterial: newpubKeyBase58, + }, + }, + Authentication: []string{keyID}, + VersionId: uuid.NewString(), + } + + signInputs2 := []cli_types.SignInput{ + { + VerificationMethodID: keyID, + PrivKey: privKey, + }, + { + VerificationMethodID: keyID, + PrivKey: newPrivKey, + }, + } + + res2, err := cli.UpdateDidDoc(tmpDir, payload2, signInputs2, testdata.BASE_ACCOUNT_1, cli.CliGasParams) + Expect(err).To(BeNil()) + Expect(res2.Code).To(BeEquivalentTo(0)) + + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query diddoc (Ed25519VerificationKey2018)")) + // Query the DID Doc + resp, err := cli.QueryDidDoc(did) + Expect(err).To(BeNil()) + + didDoc := resp.Value.DidDoc + Expect(didDoc.Id).To(BeEquivalentTo(did)) + Expect(didDoc.Authentication).To(HaveLen(1)) + Expect(didDoc.Authentication[0]).To(BeEquivalentTo(keyID)) + Expect(didDoc.VerificationMethod).To(HaveLen(1)) + Expect(didDoc.VerificationMethod[0].Id).To(BeEquivalentTo(keyID)) + Expect(didDoc.VerificationMethod[0].VerificationMethodType).To(BeEquivalentTo("Ed25519VerificationKey2018")) + Expect(didDoc.VerificationMethod[0].Controller).To(BeEquivalentTo(did)) + Expect(didDoc.VerificationMethod[0].VerificationMaterial).To(BeEquivalentTo(newpubKeyBase58)) // Check that DIDDoc is not deactivated Expect(resp.Value.Metadata.Deactivated).To(BeFalse()) - AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can deactivate diddoc")) + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can deactivate diddoc (Ed25519VerificationKey2018)")) // Deactivate the DID Doc payload3 := types.MsgDeactivateDidDocPayload{ Id: did, @@ -129,11 +371,11 @@ var _ = Describe("cheqd cli - positive did", func() { }, } - res3, err := cli.DeactivateDidDoc(tmpDir, payload3, signInputs3, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res3, err := cli.DeactivateDidDoc(tmpDir, payload3, signInputs3, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res3.Code).To(BeEquivalentTo(0)) - AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query deactivated diddoc")) + AddReportEntry("Integration", fmt.Sprintf("%sPositive: %s", cli.Green, "can query deactivated diddoc (Ed25519VerificationKey2018)")) // Query the DID Doc resp2, err := cli.QueryDidDoc(did) diff --git a/tests/integration/cli_resource_negative_test.go b/tests/integration/cli_resource_negative_test.go index 6d8836735..2b4043bdd 100644 --- a/tests/integration/cli_resource_negative_test.go +++ b/tests/integration/cli_resource_negative_test.go @@ -10,9 +10,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -39,16 +39,16 @@ var _ = Describe("cheqd cli - negative resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, VerificationMethod: []*types.VerificationMethod{ { - Id: keyId, - VerificationMethodType: "Ed25519VerificationKey2020", - Controller: did, - VerificationMaterial: pubKeyMultibase58, + Id: keyId, + VerificationMethodType: "Ed25519VerificationKey2020", + Controller: did, + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, @@ -62,7 +62,7 @@ var _ = Describe("cheqd cli - negative resource", func() { }, } - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -100,7 +100,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create resource with missing cli arguments")) @@ -112,7 +112,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) // b. missing resource id - works because it is generated by the cli _, err = cli.CreateResource(tmpDir, resourcecli.CreateResourceOptions{ @@ -121,7 +121,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) // c. missing resource name @@ -131,7 +131,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // c. missing resource version - ok @@ -143,7 +143,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceName: resourceName, ResourceVersion: resourceVersion, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // e. missing resource file @@ -153,7 +153,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceName: resourceName, ResourceVersion: resourceVersion, ResourceType: resourceType, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // f. missing sign inputs @@ -164,7 +164,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, []clitypes.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, []clitypes.SignInput{}, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // g. missing account @@ -175,7 +175,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, "", cli.CLIGasParams) + }, signInputs, "", cli.CliGasParams) Expect(err).To(HaveOccurred()) AddReportEntry("Integration", fmt.Sprintf("%sNegative: %s", cli.Purple, "cannot create resource with sign inputs mismatch")) @@ -188,7 +188,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs2, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs2, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // b. non-existing key id @@ -204,7 +204,7 @@ var _ = Describe("cheqd cli - negative resource", func() { VerificationMethodID: "non-existing-key-id", PrivKey: signInputs[0].PrivKey, }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // c. non-matching private key @@ -220,7 +220,7 @@ var _ = Describe("cheqd cli - negative resource", func() { VerificationMethodID: signInputs[0].VerificationMethodID, PrivKey: privKey2, }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // d. invalid private key @@ -236,7 +236,7 @@ var _ = Describe("cheqd cli - negative resource", func() { VerificationMethodID: signInputs[0].VerificationMethodID, PrivKey: testdata.GenerateByteEntropy(), }, - }, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(HaveOccurred()) // Finally, create the resource @@ -247,7 +247,7 @@ var _ = Describe("cheqd cli - negative resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) }) diff --git a/tests/integration/cli_resource_pricing_negative_test.go b/tests/integration/cli_resource_pricing_negative_test.go index 62f13c74a..7c183d054 100644 --- a/tests/integration/cli_resource_pricing_negative_test.go +++ b/tests/integration/cli_resource_pricing_negative_test.go @@ -10,10 +10,10 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" didtypes "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" @@ -60,7 +60,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -84,7 +84,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { } // Submit the DID Doc - resp, err := cli.CreateDidDoc(tmpDir, didPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, didPayload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) }) @@ -313,7 +313,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_3, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_3, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) @@ -335,7 +335,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_3, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_3, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) @@ -357,7 +357,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_3, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_3, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(5)) }) diff --git a/tests/integration/cli_resource_pricing_test.go b/tests/integration/cli_resource_pricing_test.go index a4db895d8..b1d786caa 100644 --- a/tests/integration/cli_resource_pricing_test.go +++ b/tests/integration/cli_resource_pricing_test.go @@ -10,10 +10,10 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" didtypes "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -42,16 +42,16 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, VerificationMethod: []*didtypes.VerificationMethod{ { - Id: keyId, - VerificationMethodType: "Ed25519VerificationKey2020", - Controller: did, - VerificationMaterial: pubKeyMultibase58, + Id: keyId, + VerificationMethodType: "Ed25519VerificationKey2020", + Controller: did, + VerificationMaterial: pubKeyMultibase58, }, }, Authentication: []string{keyId}, @@ -66,7 +66,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { } // Submit the DID Doc - resp, err := cli.CreateDidDoc(tmpDir, didPayload, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + resp, err := cli.CreateDidDoc(tmpDir, didPayload, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) }) @@ -169,7 +169,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -321,7 +321,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -473,7 +473,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_4, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_4, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -537,7 +537,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(err).To(BeNil()) By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -557,7 +557,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -579,7 +579,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) @@ -593,7 +593,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(err).To(BeNil()) By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -613,7 +613,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -635,7 +635,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) @@ -649,7 +649,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(err).To(BeNil()) By("creating a feegrant") - res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err := cli.GrantFees(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -669,7 +669,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CLIGasParams)) + }, signInputs, testdata.BASE_ACCOUNT_1, helpers.GenerateFeeGranter(testdata.BASE_ACCOUNT_4_ADDR, cli.CliGasParams)) Expect(err).To(BeNil()) Expect(resp.Code).To(BeEquivalentTo(0)) @@ -691,7 +691,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Expect(diff.IsZero()).To(BeTrue()) By("revoking the feegrant") - res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CLIGasParams) + res, err = cli.RevokeFeeGrant(testdata.BASE_ACCOUNT_4_ADDR, testdata.BASE_ACCOUNT_1_ADDR, cli.CliGasParams) Expect(err).To(BeNil()) }) }) diff --git a/tests/integration/cli_resource_test.go b/tests/integration/cli_resource_test.go index ae7864faa..3d9a2b244 100644 --- a/tests/integration/cli_resource_test.go +++ b/tests/integration/cli_resource_test.go @@ -10,9 +10,9 @@ import ( "github.com/cheqd/cheqd-node/tests/integration/network" "github.com/cheqd/cheqd-node/tests/integration/testdata" clitypes "github.com/cheqd/cheqd-node/x/did/client/cli" + testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/cheqd/cheqd-node/x/did/types" resourcecli "github.com/cheqd/cheqd-node/x/resource/client/cli" - testsetup "github.com/cheqd/cheqd-node/x/did/tests/setup" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -35,7 +35,7 @@ var _ = Describe("cheqd cli - positive resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -58,7 +58,7 @@ var _ = Describe("cheqd cli - positive resource", func() { }, } - res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + res, err := cli.CreateDidDoc(tmpDir, payload, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -79,7 +79,7 @@ var _ = Describe("cheqd cli - positive resource", func() { ResourceVersion: resourceVersion, ResourceType: resourceType, ResourceFile: resourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -121,7 +121,7 @@ var _ = Describe("cheqd cli - positive resource", func() { ResourceVersion: nextResourceVersion, ResourceType: nextResourceType, ResourceFile: nextResourceFile, - }, signInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, signInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -133,7 +133,7 @@ var _ = Describe("cheqd cli - positive resource", func() { secondPubKey, secondPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - secondPubKeyMultibase58 := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(secondPubKey) + secondPubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(secondPubKey) secondPayload := types.MsgCreateDidDocPayload{ Id: secondDid, @@ -156,7 +156,7 @@ var _ = Describe("cheqd cli - positive resource", func() { }, } - res, err = cli.CreateDidDoc(tmpDir, secondPayload, secondSignInputs, testdata.BASE_ACCOUNT_2, cli.CLIGasParams) + res, err = cli.CreateDidDoc(tmpDir, secondPayload, secondSignInputs, testdata.BASE_ACCOUNT_2, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) @@ -175,7 +175,7 @@ var _ = Describe("cheqd cli - positive resource", func() { ResourceVersion: secondResourceVersion, ResourceType: secondResourceType, ResourceFile: secondResourceFile, - }, secondSignInputs, testdata.BASE_ACCOUNT_1, cli.CLIGasParams) + }, secondSignInputs, testdata.BASE_ACCOUNT_1, cli.CliGasParams) Expect(err).To(BeNil()) Expect(res.Code).To(BeEquivalentTo(0)) diff --git a/x/did/tests/create_diddoc_test.go b/x/did/tests/create_diddoc_test.go index 207a26d7d..84fc09f51 100644 --- a/x/did/tests/create_diddoc_test.go +++ b/x/did/tests/create_diddoc_test.go @@ -32,7 +32,7 @@ var _ = Describe("Create DID tests", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), @@ -65,9 +65,44 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.JSONWebKey2020Type, + VerificationMethodType: types.JsonWebKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildJSONWebKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateJsonWebKey2020VerificationMaterial(keypair.Public), + }, + }, + VersionId: uuid.NewString(), + } + + signatures := []testsetup.SignInput{ + { + VerificationMethodID: keyID, + Key: keypair.Private, + }, + } + + _, err := setup.CreateDid(msg, signatures) + Expect(err).To(BeNil()) + + // check + created, err := setup.QueryDidDoc(did) + Expect(err).To(BeNil()) + Expect(msg.ToDidDoc()).To(Equal(*created.Value.DidDoc)) + }) + + It("Valid: Works for simple DIDDoc (Ed25519VerificationKey2018)", func() { + did := testsetup.GenerateDID(testsetup.Base58_16bytes) + keypair := testsetup.GenerateKeyPair() + keyID := did + "#key-1" + + msg := &types.MsgCreateDidDocPayload{ + Id: did, + Authentication: []string{keyID}, + VerificationMethod: []*types.VerificationMethod{ + { + Id: keyID, + VerificationMethodType: types.Ed25519VerificationKey2018Type, + Controller: did, + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2018VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), @@ -108,7 +143,7 @@ var _ = Describe("Create DID tests", func() { Id: bobKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: anna.Did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, }, VersionId: uuid.NewString(), @@ -149,25 +184,25 @@ var _ = Describe("Create DID tests", func() { Id: keyID1, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair1.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair1.Public), }, { Id: keyID2, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair2.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair2.Public), }, { Id: keyID3, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair3.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair3.Public), }, { Id: keyID4, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair4.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair4.Public), }, }, Authentication: []string{keyID1, keyID2}, @@ -224,7 +259,7 @@ var _ = Describe("Create DID tests", func() { Id: bobKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bobDid, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, }, VersionId: uuid.NewString(), @@ -255,7 +290,7 @@ var _ = Describe("Create DID tests", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), @@ -283,15 +318,21 @@ var _ = Describe("Create DID tests", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), } - signatures := []testsetup.SignInput{} + signatures := []testsetup.SignInput{ + { + VerificationMethodID: keyID, + Key: keypair.Private, + }, + } _, err := setup.CreateDid(msg, signatures) + Expect(err).ToNot(BeNil()) Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("%s: DID Doc not found", nonExistingDid))) }) @@ -309,7 +350,7 @@ var _ = Describe("Create DID tests", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), @@ -346,7 +387,7 @@ var _ = Describe("Create DID tests", func() { Id: bobKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bobDid, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(bobKeypair.Public), }, }, VersionId: uuid.NewString(), @@ -372,7 +413,7 @@ var _ = Describe("Create DID tests", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), @@ -403,7 +444,7 @@ var _ = Describe("Create DID tests", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, } @@ -438,7 +479,7 @@ var _ = Describe("Check upper/lower case for DID creation", func() { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: testsetup.BuildEd25519VerificationKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), diff --git a/x/did/tests/setup/setup_create_diddoc.go b/x/did/tests/setup/setup_create_diddoc.go index 484427d4f..6235098dd 100644 --- a/x/did/tests/setup/setup_create_diddoc.go +++ b/x/did/tests/setup/setup_create_diddoc.go @@ -42,7 +42,7 @@ func (s *TestSetup) BuildDidDocWithCustomDID(did string) DidDocInfo { Id: keyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(keyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(keyPair.Public), }, }, Authentication: []string{keyID}, diff --git a/x/did/tests/setup/utils.go b/x/did/tests/setup/utils.go index f2b6f142e..27e48013e 100644 --- a/x/did/tests/setup/utils.go +++ b/x/did/tests/setup/utils.go @@ -63,14 +63,14 @@ func GenerateKeyPair() KeyPair { return KeyPair{PrivateKey, PublicKey} } -func BuildEd25519VerificationKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { - multicodecAndKey := []byte{0xed, 0x01} - multicodecAndKey = append(multicodecAndKey, publicKey...) - keyStr, _ := multibase.Encode(multibase.Base58BTC, multicodecAndKey) +func GenerateEd25519VerificationKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { + publicKeyMultibaseBytes := []byte{0xed, 0x01} + publicKeyMultibaseBytes = append(publicKeyMultibaseBytes, publicKey...) + keyStr, _ := multibase.Encode(multibase.Base58BTC, publicKeyMultibaseBytes) return keyStr } -func BuildJSONWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { +func GenerateJsonWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { pubKeyJwk, err := jwk.New(publicKey) if err != nil { panic(err) @@ -83,3 +83,7 @@ func BuildJSONWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string return string(pubKeyJwkJSON) } + +func GenerateEd25519VerificationKey2018VerificationMaterial(publicKey ed25519.PublicKey) string { + return base58.Encode(publicKey) +} diff --git a/x/did/tests/tests_suite_test.go b/x/did/tests/tests_suite_test.go index fb621a35f..abdc6ba58 100644 --- a/x/did/tests/tests_suite_test.go +++ b/x/did/tests/tests_suite_test.go @@ -9,5 +9,5 @@ import ( func TestTestsGeneral(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Cheqd DID Module") + RunSpecs(t, "Did Module") } diff --git a/x/did/tests/update_diddoc_test.go b/x/did/tests/update_diddoc_test.go index 07322ac94..ebf96647f 100644 --- a/x/did/tests/update_diddoc_test.go +++ b/x/did/tests/update_diddoc_test.go @@ -36,7 +36,7 @@ var _ = Describe("DIDDoc update", func() { Id: bob.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bob.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(bob.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(bob.KeyPair.Public), }, }, Authentication: []string{bob.KeyID}, @@ -115,7 +115,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, VersionId: uuid.NewString(), @@ -173,7 +173,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, VersionId: uuid.NewString(), @@ -231,7 +231,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, Authentication: []string{alice.KeyID}, @@ -270,7 +270,7 @@ var _ = Describe("DIDDoc update", func() { Id: did.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: did.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(newKeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(newKeyPair.Public), }, }, VersionId: uuid.NewString(), @@ -329,7 +329,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: bob.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, Authentication: []string{alice.KeyID}, @@ -380,7 +380,7 @@ var _ = Describe("DIDDoc update", func() { Id: newKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, Authentication: []string{alice.KeyID}, @@ -445,13 +445,13 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, { Id: newKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(newKey.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(newKey.Public), }, }, Authentication: []string{alice.KeyID}, @@ -510,13 +510,13 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, { Id: secondKeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(secondKey.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(secondKey.Public), }, }, Authentication: []string{alice.KeyID}, @@ -533,7 +533,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.KeyPair.Public), }, }, Authentication: []string{alice.KeyID}, @@ -579,7 +579,7 @@ var _ = Describe("DIDDoc update", func() { Id: alice.DidDocInfo.KeyID, VerificationMethodType: types.Ed25519VerificationKey2020Type, Controller: alice.DidDocInfo.Did, - VerificationMaterial: BuildEd25519VerificationKey2020VerificationMaterial(alice.DidDocInfo.KeyPair.Public), + VerificationMaterial: GenerateEd25519VerificationKey2020VerificationMaterial(alice.DidDocInfo.KeyPair.Public), }, }, Authentication: []string{alice.KeyID}, diff --git a/x/did/types/constant_test.go b/x/did/types/constant_test.go index 87e8683ed..99deb2bd4 100644 --- a/x/did/types/constant_test.go +++ b/x/did/types/constant_test.go @@ -43,13 +43,21 @@ var ( ) var ( - // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9202d564c12 - ValidEd25519VerificationMaterial = "z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3" - // bytes: 020076a50fe5e0c3616c1b4d85a308c104a1c99d8d3d92c18c1f4e0179202d564c12 - InvalidEd25519VerificationMaterialBadMulticodec = "z3dEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" - // bytes: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9 - InvalidEd25519VerificationMaterialBadlength = "zBm3emgJHyjidq7HsZFTx3PCjYHayy7SxisBeVCa4" - - ValidJWKKeyVerificationMaterial = string(ValidPublicKeyJWK) - InvalidJWKKeyVerificationMaterial = string(InvalidPublicKeyJWK) + // bytes in hex: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9202d564c12 + ValidEd25519VerificationKey2020VerificationMaterial = "z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3" + + // bytes in hex: 020076a50fe5e0c3616c1b4d85a308c104a1c99d8d3d92c18c1f4e0179202d564c12 + InvalidEd25519VerificationKey2020VerificationMaterialBadPrefix = "z3dEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf" + + // bytes in hex: ed01c92d1e8f9cfa03f63be3489accb0c2704bb7da3f2e4e94509d8ff9 + InvalidEd25519VerificationKey2020VerificationMaterialBadlength = "zBm3emgJHyjidq7HsZFTx3PCjYHayy7SxisBeVCa4" + + // bytes in hex: 0a04f18e1a12b6af626bde47be47a1800d211712af9e2c0fd43990c7073121ce + ValidEd25519VerificationKey2018VerificationMaterial = "g7T3moSG5mwFvazr5gi8AyUETXTkZ9E6PZxAZVhWN93" + + // bytes in hex: 2c392158b9b3b3935a22ba9dc371211ab58939b39461dcf66aec6d5cd04b9e + InvalidEd25519VerificationKey2018VerificationMaterialBadLength = "g7T3moSG5mwFvazr5gi8AyUETXTkZ9E6PZxAZVhWN9" + + ValidJWK2020VerificationMaterial = string(ValidPublicKeyJWK) + InvalidJWK2020VerificationMaterial = string(InvalidPublicKeyJWK) ) diff --git a/x/did/types/diddoc_diddoc_test.go b/x/did/types/diddoc_diddoc_test.go index f5c0af756..e8f9ac777 100644 --- a/x/did/types/diddoc_diddoc_test.go +++ b/x/did/types/diddoc_diddoc_test.go @@ -37,7 +37,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -55,7 +55,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -73,7 +73,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -91,7 +91,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "JsonWebKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, }, }, @@ -108,7 +108,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: InvalidTestDID, VerificationMethodType: "JsonWebKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, }, }, @@ -125,7 +125,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "JsonWebKey2020", Controller: InvalidTestDID, - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, }, }, @@ -143,7 +143,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -162,7 +162,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -180,7 +180,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -199,7 +199,7 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, @@ -216,13 +216,13 @@ var _ = DescribeTable("DIDDoc Validation tests", func(testCase DIDDocTestCase) { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, { Id: fmt.Sprintf("%s#fragment", ValidTestDID), VerificationMethodType: "Ed25519VerificationKey2020", Controller: ValidTestDID, - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, }, diff --git a/x/did/types/diddoc_verification_method.go b/x/did/types/diddoc_verification_method.go index ce73f2ca7..ebe04d0a9 100644 --- a/x/did/types/diddoc_verification_method.go +++ b/x/did/types/diddoc_verification_method.go @@ -10,17 +10,20 @@ import ( "github.com/cheqd/cheqd-node/x/did/utils" validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/lestrrat-go/jwx/jwk" + "github.com/mr-tron/base58" "github.com/multiformats/go-multibase" ) const ( - JSONWebKey2020Type = "JsonWebKey2020" + JsonWebKey2020Type = "JsonWebKey2020" Ed25519VerificationKey2020Type = "Ed25519VerificationKey2020" + Ed25519VerificationKey2018Type = "Ed25519VerificationKey2018" ) var SupportedMethodTypes = []string{ - JSONWebKey2020Type, + JsonWebKey2020Type, Ed25519VerificationKey2020Type, + Ed25519VerificationKey2018Type, } func NewVerificationMethod(id string, vmType string, controller string, verificationMaterial string) *VerificationMethod { @@ -68,7 +71,7 @@ func VerifySignature(vm VerificationMethod, message []byte, signature []byte) er keyBytes := utils.GetEd25519VerificationKey2020(multibaseBytes) verificationError = utils.VerifyED25519Signature(keyBytes, message, signature) - case JSONWebKey2020Type: + case JsonWebKey2020Type: var raw interface{} err := jwk.ParseRawKey([]byte(vm.VerificationMaterial), &raw) if err != nil { @@ -86,6 +89,14 @@ func VerifySignature(vm VerificationMethod, message []byte, signature []byte) er panic("unsupported jwk key") // This should have been checked during basic validation } + case Ed25519VerificationKey2018Type: + publicKeyBytes, err := base58.Decode(vm.VerificationMaterial) + if err != nil { + return err + } + + verificationError = utils.VerifyED25519Signature(publicKeyBytes, message, signature) + default: panic("unsupported verification method type") // This should have also been checked during basic validation } @@ -120,7 +131,6 @@ func (vm *VerificationMethod) ReplaceDids(old, new string) { } // Validation - func (vm VerificationMethod) Validate(baseDid string, allowedNamespaces []string) error { return validation.ValidateStruct(&vm, validation.Field(&vm.Id, validation.Required, IsDIDUrl(allowedNamespaces, Empty, Empty, Required), HasPrefix(baseDid)), @@ -130,7 +140,10 @@ func (vm VerificationMethod) Validate(baseDid string, allowedNamespaces []string validation.When(vm.VerificationMethodType == Ed25519VerificationKey2020Type, validation.Required, IsMultibaseEd25519VerificationKey2020()), ), validation.Field(&vm.VerificationMaterial, - validation.When(vm.VerificationMethodType == JSONWebKey2020Type, validation.Required, IsJWK()), + validation.When(vm.VerificationMethodType == Ed25519VerificationKey2018Type, validation.Required, IsBase58Ed25519VerificationKey2018()), + ), + validation.Field(&vm.VerificationMaterial, + validation.When(vm.VerificationMethodType == JsonWebKey2020Type, validation.Required, IsJWK()), ), ) } diff --git a/x/did/types/diddoc_verification_method_test.go b/x/did/types/diddoc_verification_method_test.go index 8fb180e3d..f142123f5 100644 --- a/x/did/types/diddoc_verification_method_test.go +++ b/x/did/types/diddoc_verification_method_test.go @@ -34,7 +34,6 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Expect(err.Error()).To(ContainSubstring(testCase.errorMsg)) } }, - Entry( "Verification method with expected multibase key", VerificationMethodTestCase{ @@ -42,12 +41,12 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, isValid: true, errorMsg: "", - }), - + }, + ), Entry( "Verification method with expected jwk key", VerificationMethodTestCase{ @@ -55,12 +54,25 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, isValid: true, errorMsg: "", - }), - + }, + ), + Entry( + "Verification method with expected base58 key", + VerificationMethodTestCase{ + vm: didtypes.VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#uio", + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: ValidEd25519VerificationKey2018VerificationMaterial, + }, + isValid: true, + errorMsg: "", + }, + ), Entry( "Id has expected DID as a base", VerificationMethodTestCase{ @@ -68,13 +80,13 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, baseDid: "did:cheqd:zABCDEFG123456789abcd", isValid: true, errorMsg: "", - }), - + }, + ), Entry( "Id does not have expected DID as a base", VerificationMethodTestCase{ @@ -82,13 +94,13 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, baseDid: "did:cheqd:zABCDEFG987654321abcd", isValid: false, errorMsg: "id: must have prefix: did:cheqd:zABCDEFG987654321abcd.", - }), - + }, + ), Entry( "Namespace is allowed", VerificationMethodTestCase{ @@ -96,11 +108,12 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:mainnet:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, allowedNamespaces: []string{"mainnet", ""}, isValid: true, - }), + }, + ), Entry( "Namespace is not allowed", @@ -109,12 +122,13 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:mainnet:zABCDEFG123456789abcd#rty", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, allowedNamespaces: []string{"testnet"}, isValid: false, errorMsg: "controller: did namespace must be one of: testnet; id: did namespace must be one of: testnet.", - }), + }, + ), Entry( "JWK key has expected format", VerificationMethodTestCase{ @@ -122,10 +136,11 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, isValid: true, - }), + }, + ), Entry( "JWK key has unexpected format", VerificationMethodTestCase{ @@ -133,42 +148,57 @@ var _ = DescribeTable("Verification Method validation tests", func(testCase Veri Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidJWKKeyVerificationMaterial, + VerificationMaterial: InvalidJWK2020VerificationMaterial, }, isValid: false, errorMsg: "verification_material: can't parse jwk: failed to parse key", - }), + }, + ), Entry( - "Ed25519 key has unexpected format", + "Ed25519 key 2020 has unexpected format", VerificationMethodTestCase{ vm: didtypes.VerificationMethod{ Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidEd25519VerificationMaterialBadlength, + VerificationMaterial: InvalidEd25519VerificationKey2020VerificationMaterialBadlength, }, isValid: false, errorMsg: "verification_material: ed25519: bad public key length: 27", - }), + }, + ), + Entry( + "Ed25519 key 2018 has unexpected format", + VerificationMethodTestCase{ + vm: didtypes.VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: InvalidEd25519VerificationKey2018VerificationMaterialBadLength, + }, + isValid: false, + errorMsg: "verification_material: ed25519: bad public key length: 31", + }, + ), ) var _ = Describe("Validation ed25519 Signature in verification method", func() { var pubKey ed25519.PublicKey var privKey ed25519.PrivateKey + var signature []byte var err error message := "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod " + "tempor incididunt ut labore et dolore magna aliqua." msgBytes := []byte(message) - var signature []byte pubKey, privKey, err = ed25519.GenerateKey(rand.Reader) Expect(err).To(BeNil()) signature = ed25519.Sign(privKey, msgBytes) - Context("when ed25519 key is placed", func() { + Context("when ed25519 key 2020 representation is placed", func() { It("is valid", func() { - pubKeyStr := testsetup.BuildEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyStr := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) vm := didtypes.VerificationMethod{ Id: "", @@ -182,7 +212,7 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { }) }) - Context("when with the same env but JWK is placed", func() { + Context("when JWK 2020 representation is placed", func() { It("is valid", func() { jwkKey, err := jwk.New(pubKey) Expect(err).To(BeNil()) @@ -201,6 +231,22 @@ var _ = Describe("Validation ed25519 Signature in verification method", func() { Expect(err).To(BeNil()) }) }) + + Context("when ed25519 key 2018 representation is placed", func() { + It("is valid", func() { + pubKeyStr := testsetup.GenerateEd25519VerificationKey2018VerificationMaterial(pubKey) + + vm := didtypes.VerificationMethod{ + Id: "", + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: "", + VerificationMaterial: pubKeyStr, + } + + err = didtypes.VerifySignature(vm, msgBytes, signature) + Expect(err).To(BeNil()) + }) + }) }) var _ = Describe("Validation ECDSA Signature in verification method", func() { @@ -290,7 +336,6 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Expect(err.Error()).To(ContainSubstring(testCase.errorMsg)) } }, - Entry( "Valid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ @@ -298,12 +343,12 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, isValid: true, errorMsg: "", - }), - + }, + ), Entry( "Valid JsonWebKey2020 verification material", VerificationMethodTestCase{ @@ -311,12 +356,25 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: ValidJWKKeyVerificationMaterial, + VerificationMaterial: ValidJWK2020VerificationMaterial, }, isValid: true, errorMsg: "", - }), - + }, + ), + Entry( + "Valid Ed25519VerificationKey2018 verification material", + VerificationMethodTestCase{ + vm: didtypes.VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: ValidEd25519VerificationKey2018VerificationMaterial, + }, + isValid: true, + errorMsg: "", + }, + ), Entry( "Invalid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ @@ -324,12 +382,12 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidEd25519VerificationMaterialBadlength, + VerificationMaterial: InvalidEd25519VerificationKey2020VerificationMaterialBadlength, }, isValid: false, errorMsg: "", - }), - + }, + ), Entry( "Invalid Ed25519VerificationKey2020 verification material", VerificationMethodTestCase{ @@ -337,12 +395,12 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidEd25519VerificationMaterialBadMulticodec, + VerificationMaterial: InvalidEd25519VerificationKey2020VerificationMaterialBadPrefix, }, isValid: false, - errorMsg: "verification_material: invalid multicodec for ED25519VerificationKey2020. expected: 0xed01 actual: 0x0200", - }), - + errorMsg: "verification_material: invalid two-byte prefix for Ed25519VerificationKey2020. expected: 0xed01 actual: 0x0200", + }, + ), Entry( "Invalid JsonWebKey2020 verification material", VerificationMethodTestCase{ @@ -350,9 +408,23 @@ var _ = DescribeTable("Verification Method material validation tests", func(test Id: "did:cheqd:zABCDEFG123456789abcd#qwe", VerificationMethodType: "JsonWebKey2020", Controller: "did:cheqd:zABCDEFG987654321abcd", - VerificationMaterial: InvalidJWKKeyVerificationMaterial, + VerificationMaterial: InvalidJWK2020VerificationMaterial, }, isValid: false, errorMsg: "can't parse jwk: failed to parse key", - }), + }, + ), + Entry( + "Invalid Ed25519VerificationKey2018 verification material", + VerificationMethodTestCase{ + vm: didtypes.VerificationMethod{ + Id: "did:cheqd:zABCDEFG123456789abcd#qwe", + VerificationMethodType: "Ed25519VerificationKey2018", + Controller: "did:cheqd:zABCDEFG987654321abcd", + VerificationMaterial: InvalidEd25519VerificationKey2018VerificationMaterialBadLength, + }, + isValid: false, + errorMsg: "ed25519: bad public key length: 31", + }, + ), ) diff --git a/x/did/types/tx_msg_create_diddoc_test.go b/x/did/types/tx_msg_create_diddoc_test.go index 9530e1a35..ed4ab25de 100644 --- a/x/did/types/tx_msg_create_diddoc_test.go +++ b/x/did/types/tx_msg_create_diddoc_test.go @@ -25,7 +25,6 @@ var _ = Describe("Message for DID creation", func() { Expect(err.Error()).To(ContainSubstring(testCase.errorMsg)) } }, - Entry( "All fields are set properly", TestCaseMsgCreateDID{ @@ -37,7 +36,7 @@ var _ = Describe("Message for DID creation", func() { Id: "did:cheqd:testnet:zABCDEFG123456789abcd#key1", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:testnet:zABCDEFG123456789abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, Authentication: []string{"did:cheqd:testnet:zABCDEFG123456789abcd#key1", "did:cheqd:testnet:zABCDEFG123456789abcd#aaa"}, @@ -46,8 +45,8 @@ var _ = Describe("Message for DID creation", func() { Signatures: nil, }, isValid: true, - }), - + }, + ), Entry( "IDs are duplicated", TestCaseMsgCreateDID{ @@ -59,7 +58,7 @@ var _ = Describe("Message for DID creation", func() { Id: "did:cheqd:testnet:zABCDEFG123456789abcd#key1", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:testnet:zABCDEFG123456789abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, Authentication: []string{"did:cheqd:testnet:zABCDEFG123456789abcd#key1", "did:cheqd:testnet:zABCDEFG123456789abcd#key1"}, @@ -68,6 +67,7 @@ var _ = Describe("Message for DID creation", func() { }, isValid: false, errorMsg: "payload: (authentication: there should be no duplicates.).: basic validation failed", - }), + }, + ), ) }) diff --git a/x/did/types/tx_msg_update_did_doc_test.go b/x/did/types/tx_msg_update_did_doc_test.go index c5b6cc633..8e08cffb1 100644 --- a/x/did/types/tx_msg_update_did_doc_test.go +++ b/x/did/types/tx_msg_update_did_doc_test.go @@ -36,7 +36,7 @@ var _ = Describe("Message for DID updating", func() { Id: "did:cheqd:testnet:zABCDEFG123456789abcd#key1", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:testnet:zABCDEFG123456789abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, Authentication: []string{"did:cheqd:testnet:zABCDEFG123456789abcd#key1", "did:cheqd:testnet:zABCDEFG123456789abcd#aaa"}, @@ -58,7 +58,7 @@ var _ = Describe("Message for DID updating", func() { Id: "did:cheqd:testnet:zABCDEFG123456789abcd#key1", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:testnet:zABCDEFG123456789abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, Authentication: []string{"did:cheqd:testnet:zABCDEFG123456789abcd#key1", "did:cheqd:testnet:zABCDEFG123456789abcd#key1"}, @@ -80,7 +80,7 @@ var _ = Describe("Message for DID updating", func() { Id: "did:cheqd:testnet:zABCDEFG123456789abcd#key1", VerificationMethodType: "Ed25519VerificationKey2020", Controller: "did:cheqd:testnet:zABCDEFG123456789abcd", - VerificationMaterial: ValidEd25519VerificationMaterial, + VerificationMaterial: ValidEd25519VerificationKey2020VerificationMaterial, }, }, Authentication: []string{"did:cheqd:testnet:zABCDEFG123456789abcd#key1", "did:cheqd:testnet:zABCDEFG123456789abcd#aaa"}, diff --git a/x/did/types/types_test.go b/x/did/types/types_test.go index 0421edfd7..3ee24ed3e 100644 --- a/x/did/types/types_test.go +++ b/x/did/types/types_test.go @@ -9,5 +9,5 @@ import ( func TestUtils(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Cheqd Module Types") + RunSpecs(t, "Did Module Types") } diff --git a/x/did/types/validate.go b/x/did/types/validate.go index c11b5cd64..75643885b 100644 --- a/x/did/types/validate.go +++ b/x/did/types/validate.go @@ -138,6 +138,17 @@ func IsMultibaseEd25519VerificationKey2020() *CustomErrorRule { }) } +func IsBase58Ed25519VerificationKey2018() *CustomErrorRule { + return NewCustomErrorRule(func(value interface{}) error { + casted, ok := value.(string) + if !ok { + panic("IsBase58Ed25519VerificationKey2018 must be only applied on string properties") + } + + return utils.ValidateBase58Ed25519VerificationKey2018(casted) + }) +} + func IsMultibaseEncodedEd25519PubKey() *CustomErrorRule { return NewCustomErrorRule(func(value interface{}) error { casted, ok := value.(string) diff --git a/x/did/utils/encoding.go b/x/did/utils/encoding.go index e287fe5ea..b6212a5a9 100644 --- a/x/did/utils/encoding.go +++ b/x/did/utils/encoding.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + "github.com/mr-tron/base58" "github.com/multiformats/go-multibase" ) @@ -54,7 +55,7 @@ func MustEncodeJSON(data interface{}) string { func ValidateMulticodecEd25519VerificationKey2020(keyBytes []byte) error { if keyBytes[0] != 0xed && keyBytes[1] != 0x01 { - return fmt.Errorf("invalid multicodec for ED25519VerificationKey2020. expected: %s actual: %s", + return fmt.Errorf("invalid two-byte prefix for Ed25519VerificationKey2020. expected: %s actual: %s", "0xed01", fmt.Sprintf("0x%02x%02x", keyBytes[0], keyBytes[1])) } return nil @@ -67,7 +68,7 @@ func ValidateMultibaseEd25519VerificationKey2020(data string) error { } if encoding != multibase.Base58BTC { - return fmt.Errorf("invalid encoding for ED25519VerificationKey2020. expected: %s actual: %s", + return fmt.Errorf("invalid encoding for Ed25519VerificationKey2020. expected: %s actual: %s", multibase.EncodingToStr[multibase.Base58BTC], multibase.EncodingToStr[encoding]) } @@ -77,6 +78,13 @@ func ValidateMultibaseEd25519VerificationKey2020(data string) error { } pubKey := GetEd25519VerificationKey2020(keyBytes) - err = ValidateEd25519PubKey(pubKey) - return err + return ValidateEd25519PubKey(pubKey) +} + +func ValidateBase58Ed25519VerificationKey2018(data string) error { + pubKey, err := base58.Decode(data) + if err != nil { + return err + } + return ValidateEd25519PubKey(pubKey) } diff --git a/x/did/utils/utils_suite_test.go b/x/did/utils/utils_suite_test.go index 6bd2b0c8e..adaab32fc 100644 --- a/x/did/utils/utils_suite_test.go +++ b/x/did/utils/utils_suite_test.go @@ -9,5 +9,5 @@ import ( func TestUtils(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Cheqd Module Utils") + RunSpecs(t, "Did Module Utils") } From 4c6f4d2947dbb1d0a6c45d58e3dcfe5abdfbdc37 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 18:53:05 +0200 Subject: [PATCH 11/42] Fixed namings --- app/migrations/migration_did_protobuf.go | 2 +- tests/integration/cli_diddoc_test.go | 4 ++-- x/did/tests/create_diddoc_test.go | 4 ++-- x/did/tests/setup/utils.go | 2 +- x/did/types/diddoc_verification_method.go | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/migrations/migration_did_protobuf.go b/app/migrations/migration_did_protobuf.go index 4dbe200d1..a6862a164 100644 --- a/app/migrations/migration_did_protobuf.go +++ b/app/migrations/migration_did_protobuf.go @@ -142,7 +142,7 @@ func MigrateType(t string) string { case didtypesv1.Ed25519VerificationKey2020: return didtypes.Ed25519VerificationKey2020Type case didtypesv1.JSONWebKey2020: - return didtypes.JsonWebKey2020Type + return didtypes.JSONWebKey2020Type default: panic("Unknown type") } diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index d8684697e..d28bfe1f6 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -155,7 +155,7 @@ var _ = Describe("cheqd cli - positive did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateJsonWebKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateJSONWebKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -187,7 +187,7 @@ var _ = Describe("cheqd cli - positive did", func() { newPubKey, newPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - newPubKeyMultibase := testsetup.GenerateJsonWebKey2020VerificationMaterial(newPubKey) + newPubKeyMultibase := testsetup.GenerateJSONWebKey2020VerificationMaterial(newPubKey) payload2 := types.MsgUpdateDidDocPayload{ Id: did, diff --git a/x/did/tests/create_diddoc_test.go b/x/did/tests/create_diddoc_test.go index 84fc09f51..565c1dd81 100644 --- a/x/did/tests/create_diddoc_test.go +++ b/x/did/tests/create_diddoc_test.go @@ -65,9 +65,9 @@ var _ = Describe("Create DID tests", func() { VerificationMethod: []*types.VerificationMethod{ { Id: keyID, - VerificationMethodType: types.JsonWebKey2020Type, + VerificationMethodType: types.JSONWebKey2020Type, Controller: did, - VerificationMaterial: testsetup.GenerateJsonWebKey2020VerificationMaterial(keypair.Public), + VerificationMaterial: testsetup.GenerateJSONWebKey2020VerificationMaterial(keypair.Public), }, }, VersionId: uuid.NewString(), diff --git a/x/did/tests/setup/utils.go b/x/did/tests/setup/utils.go index 27e48013e..b8d2914ad 100644 --- a/x/did/tests/setup/utils.go +++ b/x/did/tests/setup/utils.go @@ -70,7 +70,7 @@ func GenerateEd25519VerificationKey2020VerificationMaterial(publicKey ed25519.Pu return keyStr } -func GenerateJsonWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { +func GenerateJSONWebKey2020VerificationMaterial(publicKey ed25519.PublicKey) string { pubKeyJwk, err := jwk.New(publicKey) if err != nil { panic(err) diff --git a/x/did/types/diddoc_verification_method.go b/x/did/types/diddoc_verification_method.go index ebe04d0a9..f6100d771 100644 --- a/x/did/types/diddoc_verification_method.go +++ b/x/did/types/diddoc_verification_method.go @@ -15,13 +15,13 @@ import ( ) const ( - JsonWebKey2020Type = "JsonWebKey2020" + JSONWebKey2020Type = "JsonWebKey2020" Ed25519VerificationKey2020Type = "Ed25519VerificationKey2020" Ed25519VerificationKey2018Type = "Ed25519VerificationKey2018" ) var SupportedMethodTypes = []string{ - JsonWebKey2020Type, + JSONWebKey2020Type, Ed25519VerificationKey2020Type, Ed25519VerificationKey2018Type, } @@ -71,7 +71,7 @@ func VerifySignature(vm VerificationMethod, message []byte, signature []byte) er keyBytes := utils.GetEd25519VerificationKey2020(multibaseBytes) verificationError = utils.VerifyED25519Signature(keyBytes, message, signature) - case JsonWebKey2020Type: + case JSONWebKey2020Type: var raw interface{} err := jwk.ParseRawKey([]byte(vm.VerificationMaterial), &raw) if err != nil { @@ -143,7 +143,7 @@ func (vm VerificationMethod) Validate(baseDid string, allowedNamespaces []string validation.When(vm.VerificationMethodType == Ed25519VerificationKey2018Type, validation.Required, IsBase58Ed25519VerificationKey2018()), ), validation.Field(&vm.VerificationMaterial, - validation.When(vm.VerificationMethodType == JsonWebKey2020Type, validation.Required, IsJWK()), + validation.When(vm.VerificationMethodType == JSONWebKey2020Type, validation.Required, IsJWK()), ), ) } From 811dd307e33c82d201a5235392922c68baa5b1b3 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 20:00:57 +0200 Subject: [PATCH 12/42] Temp disabled --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5d7d28c8d..c1baeda27 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -92,7 +92,7 @@ jobs: VALIDATE_ALL_CODEBASE: true MULTI_STATUS: true - VALIDATE_BASH: true + VALIDATE_BASH: false # This is temporarily disabled. Will be taken care of at a later stage of this PR. VALIDATE_DOCKERFILE_HADOLINT: true VALIDATE_ENV: true VALIDATE_GITHUB_ACTIONS: true From f691d0920ba589973f55072fb74ce2822a1af1d8 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 20:03:13 +0200 Subject: [PATCH 13/42] Temp disabled --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c1baeda27..e8eb11a82 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -92,7 +92,7 @@ jobs: VALIDATE_ALL_CODEBASE: true MULTI_STATUS: true - VALIDATE_BASH: false # This is temporarily disabled. Will be taken care of at a later stage of this PR. + # VALIDATE_BASH: true This is temporarily disabled. Will be taken care of at a later stage of this PR. VALIDATE_DOCKERFILE_HADOLINT: true VALIDATE_ENV: true VALIDATE_GITHUB_ACTIONS: true From 44f295537e197d057b7661ddd4f663be9b0282f5 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 20:15:25 +0200 Subject: [PATCH 14/42] Fixed deprecated print --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da695c934..0277d014c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: id: set-version run: | RELEASE_VERSION=$( git describe --tags ${{ github.sha }}) - echo ::set-output name=RELEASE_VERSION::"$RELEASE_VERSION" + echo "name=RELEASE_VERSION::"$RELEASE_VERSION"" >> "$GITHUB_OUTPUT" # Push Protobufs to Buf.build registry - uses: bufbuild/buf-push-action@v1 From 1984f5f7106e5efa0842a82057ee637f90ae3e48 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Wed, 4 Jan 2023 20:31:26 +0200 Subject: [PATCH 15/42] Removed bloat --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0277d014c..6a151d8a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: id: set-version run: | RELEASE_VERSION=$( git describe --tags ${{ github.sha }}) - echo "name=RELEASE_VERSION::"$RELEASE_VERSION"" >> "$GITHUB_OUTPUT" + echo "name=RELEASE_VERSION::$RELEASE_VERSION" >> $GITHUB_OUTPUT # Push Protobufs to Buf.build registry - uses: bufbuild/buf-push-action@v1 From cd5fb79a79187c995d629bd2231d5ffd74716648 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Thu, 5 Jan 2023 11:37:51 +0200 Subject: [PATCH 16/42] Fixed shellcheck --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a151d8a2..a83777437 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -68,8 +68,8 @@ jobs: - name: Set release version number id: set-version run: | - RELEASE_VERSION=$( git describe --tags ${{ github.sha }}) - echo "name=RELEASE_VERSION::$RELEASE_VERSION" >> $GITHUB_OUTPUT + RELEASE_VERSION=$( git describe --tags "${{ github.sha }}") + echo "name=RELEASE_VERSION::$RELEASE_VERSION" >> "$GITHUB_OUTPUT" # Push Protobufs to Buf.build registry - uses: bufbuild/buf-push-action@v1 From f8a2b6c83624565fb330bf8567c9dab8c088ef73 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:12:28 +0200 Subject: [PATCH 17/42] Fixed bash shellcheck & restored bash linters --- .github/workflows/lint.yml | 2 +- docker/localnet/gen-network-config.sh | 20 +++++++++---------- tests/legacy/ibc-defi/cheqd/cheqd-init.sh | 6 +++--- tests/legacy/ibc-defi/osmosis/osmosis_init.sh | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e8eb11a82..5d7d28c8d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -92,7 +92,7 @@ jobs: VALIDATE_ALL_CODEBASE: true MULTI_STATUS: true - # VALIDATE_BASH: true This is temporarily disabled. Will be taken care of at a later stage of this PR. + VALIDATE_BASH: true VALIDATE_DOCKERFILE_HADOLINT: true VALIDATE_ENV: true VALIDATE_GITHUB_ACTIONS: true diff --git a/docker/localnet/gen-network-config.sh b/docker/localnet/gen-network-config.sh index f291d56ea..0bb87805e 100644 --- a/docker/localnet/gen-network-config.sh +++ b/docker/localnet/gen-network-config.sh @@ -38,16 +38,16 @@ function configure_node() { APP_TOML="${NODE_HOME}/config/app.toml" CONFIG_TOML="${NODE_HOME}/config/config.toml" - sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" - sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}" + sed -i "$SED_EXT" 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" + sed -i "$SED_EXT" 's/enable = false/enable = true/g' "${APP_TOML}" - sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" - sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" - sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" - sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" - sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" - sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" } function configure_genesis() { @@ -60,10 +60,10 @@ function configure_genesis() { GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json" # Default denom - sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}" + sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "${GENESIS}" # Short voting period - sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" + sed -i "$SED_EXT" 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" # Test accounts BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" diff --git a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh index 68cce5ec8..5e3da4d9f 100755 --- a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh +++ b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh @@ -20,12 +20,12 @@ NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) cheqd-noded keys add cheqd-user --keyring-backend test # Config -sed -i $sed_extension 's|minimum-gas-prices = ""|minimum-gas-prices = "25ncheq"|g' "$HOME/.cheqdnode/config/app.toml" -sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" +sed -i "$sed_extension" 's|minimum-gas-prices = ""|minimum-gas-prices = "25ncheq"|g' "$HOME/.cheqdnode/config/app.toml" +sed -i "$sed_extension" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" # Genesis GENESIS="$HOME/.cheqdnode/config/genesis.json" -sed -i $sed_extension 's/"stake"/"ncheq"/' "$GENESIS" +sed -i "$sed_extension" 's/"stake"/"ncheq"/' "$GENESIS" cheqd-noded add-genesis-account cheqd-user 1000000000000000000ncheq --keyring-backend test cheqd-noded gentx cheqd-user 10000000000000000ncheq --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh index b23843ac5..3a9328b8b 100644 --- a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh @@ -27,4 +27,4 @@ jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/ mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json" # Config -sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" +sed -i "$sed_extension" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" From be9a3568bb0beca14656c30927c96ef7583e8ee7 Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Thu, 5 Jan 2023 14:25:13 +0200 Subject: [PATCH 18/42] Ignored `sed` extension --- docker/localnet/gen-network-config.sh | 35 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/docker/localnet/gen-network-config.sh b/docker/localnet/gen-network-config.sh index 0bb87805e..b85aed7f7 100644 --- a/docker/localnet/gen-network-config.sh +++ b/docker/localnet/gen-network-config.sh @@ -38,16 +38,29 @@ function configure_node() { APP_TOML="${NODE_HOME}/config/app.toml" CONFIG_TOML="${NODE_HOME}/config/config.toml" - sed -i "$SED_EXT" 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" - sed -i "$SED_EXT" 's/enable = false/enable = true/g' "${APP_TOML}" + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" - sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}" - sed -i "$SED_EXT" 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" + # shellcheck disable=SC2086 + sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" + + # shellcheck disable=SC2086 + sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" + + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" + + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" + + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" } function configure_genesis() { @@ -60,10 +73,12 @@ function configure_genesis() { GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json" # Default denom - sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "${GENESIS}" + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}" # Short voting period - sed -i "$SED_EXT" 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" + # shellcheck disable=SC2086 + sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" # Test accounts BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" From dc2a3434af0736ac91dae4a71a58231bd57c26be Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:00:47 +0200 Subject: [PATCH 19/42] Fixed widespread namings --- tests/integration/cli_diddoc_negative_test.go | 20 +++++++++---------- .../cli_diddoc_pricing_negative_test.go | 4 ++-- tests/integration/cli_diddoc_pricing_test.go | 4 ++-- .../integration/cli_resource_negative_test.go | 4 ++-- .../cli_resource_pricing_negative_test.go | 4 ++-- .../integration/cli_resource_pricing_test.go | 4 ++-- tests/integration/cli_resource_test.go | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/integration/cli_diddoc_negative_test.go b/tests/integration/cli_diddoc_negative_test.go index 8d05547bf..d0ff2c00f 100644 --- a/tests/integration/cli_diddoc_negative_test.go +++ b/tests/integration/cli_diddoc_negative_test.go @@ -33,7 +33,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -42,7 +42,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, @@ -67,7 +67,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) + pubKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -76,7 +76,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase582, + VerificationMaterial: pubKeyMultibase2, }, }, Authentication: []string{keyId2}, @@ -164,7 +164,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -174,7 +174,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, @@ -200,7 +200,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, @@ -220,7 +220,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase582 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) + pubKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -230,7 +230,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase582, + VerificationMaterial: pubKeyMultibase2, }, }, Authentication: []string{keyId2}, @@ -287,7 +287,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2AsExtraController, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase582, + VerificationMaterial: pubKeyMultibase2, }) followingUpdatedPayload.Authentication = append(followingUpdatedPayload.Authentication, keyId2AsExtraController) followingUpdatedPayload.CapabilityDelegation = []string{keyId} diff --git a/tests/integration/cli_diddoc_pricing_negative_test.go b/tests/integration/cli_diddoc_pricing_negative_test.go index 93d3dc4a4..9704aa424 100644 --- a/tests/integration/cli_diddoc_pricing_negative_test.go +++ b/tests/integration/cli_diddoc_pricing_negative_test.go @@ -59,7 +59,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -68,7 +68,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_diddoc_pricing_test.go b/tests/integration/cli_diddoc_pricing_test.go index ffff23966..dfa2bdf8c 100644 --- a/tests/integration/cli_diddoc_pricing_test.go +++ b/tests/integration/cli_diddoc_pricing_test.go @@ -40,7 +40,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -49,7 +49,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_negative_test.go b/tests/integration/cli_resource_negative_test.go index 2b4043bdd..b8c937e78 100644 --- a/tests/integration/cli_resource_negative_test.go +++ b/tests/integration/cli_resource_negative_test.go @@ -39,7 +39,7 @@ var _ = Describe("cheqd cli - negative resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -48,7 +48,7 @@ var _ = Describe("cheqd cli - negative resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_negative_test.go b/tests/integration/cli_resource_pricing_negative_test.go index 7c183d054..4d5c03e18 100644 --- a/tests/integration/cli_resource_pricing_negative_test.go +++ b/tests/integration/cli_resource_pricing_negative_test.go @@ -60,7 +60,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -69,7 +69,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_test.go b/tests/integration/cli_resource_pricing_test.go index b1d786caa..dd29b7c74 100644 --- a/tests/integration/cli_resource_pricing_test.go +++ b/tests/integration/cli_resource_pricing_test.go @@ -42,7 +42,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -51,7 +51,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_test.go b/tests/integration/cli_resource_test.go index 3d9a2b244..7d2f0ec9f 100644 --- a/tests/integration/cli_resource_test.go +++ b/tests/integration/cli_resource_test.go @@ -35,7 +35,7 @@ var _ = Describe("cheqd cli - positive resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -44,7 +44,7 @@ var _ = Describe("cheqd cli - positive resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase58, + VerificationMaterial: pubKeyMultibase, }, }, Authentication: []string{keyId}, @@ -133,7 +133,7 @@ var _ = Describe("cheqd cli - positive resource", func() { secondPubKey, secondPrivKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - secondPubKeyMultibase58 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(secondPubKey) + secondpubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(secondPubKey) secondPayload := types.MsgCreateDidDocPayload{ Id: secondDid, @@ -142,7 +142,7 @@ var _ = Describe("cheqd cli - positive resource", func() { Id: secondKeyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: secondDid, - VerificationMaterial: secondPubKeyMultibase58, + VerificationMaterial: secondpubKeyMultibase, }, }, Authentication: []string{secondKeyId}, From ba5d5acff90f30edab8c4b69cb26b2dd99519f2e Mon Sep 17 00:00:00 2001 From: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:08:46 +0200 Subject: [PATCH 20/42] Ignored on legacy --- tests/legacy/ibc-defi/cheqd/cheqd-init.sh | 9 ++++++--- tests/legacy/ibc-defi/osmosis/osmosis_init.sh | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh index 5e3da4d9f..3eb73ab99 100755 --- a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh +++ b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh @@ -20,12 +20,15 @@ NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) cheqd-noded keys add cheqd-user --keyring-backend test # Config -sed -i "$sed_extension" 's|minimum-gas-prices = ""|minimum-gas-prices = "25ncheq"|g' "$HOME/.cheqdnode/config/app.toml" -sed -i "$sed_extension" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" +# shellcheck disable=SC2086 +sed -i $sed_extension 's|minimum-gas-prices = ""|minimum-gas-prices = "25ncheq"|g' "$HOME/.cheqdnode/config/app.toml" +# shellcheck disable=SC2086 +sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" # Genesis GENESIS="$HOME/.cheqdnode/config/genesis.json" -sed -i "$sed_extension" 's/"stake"/"ncheq"/' "$GENESIS" +# shellcheck disable=SC2086 +sed -i $sed_extension 's/"stake"/"ncheq"/' "$GENESIS" cheqd-noded add-genesis-account cheqd-user 1000000000000000000ncheq --keyring-backend test cheqd-noded gentx cheqd-user 10000000000000000ncheq --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh index 3a9328b8b..bc2a8374e 100644 --- a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh @@ -27,4 +27,5 @@ jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/ mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json" # Config -sed -i "$sed_extension" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" +# shellcheck disable=SC2086 +sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" From 3cb2e9e26c11a23784b14a07ba547704925f9bdb Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:04:57 +0000 Subject: [PATCH 21/42] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a83777437..de4bacba9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,7 +69,7 @@ jobs: id: set-version run: | RELEASE_VERSION=$( git describe --tags "${{ github.sha }}") - echo "name=RELEASE_VERSION::$RELEASE_VERSION" >> "$GITHUB_OUTPUT" + echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT" # Push Protobufs to Buf.build registry - uses: bufbuild/buf-push-action@v1 From 26dd560ff33f0995e99ed8b69cd1c59af370e337 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:21:18 +0000 Subject: [PATCH 22/42] Update gen-network-config.sh Fixes shellcheck SC2086 --- docker/localnet/gen-network-config.sh | 37 ++++++++------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/docker/localnet/gen-network-config.sh b/docker/localnet/gen-network-config.sh index b85aed7f7..6661d3412 100644 --- a/docker/localnet/gen-network-config.sh +++ b/docker/localnet/gen-network-config.sh @@ -38,29 +38,14 @@ function configure_node() { APP_TOML="${NODE_HOME}/config/app.toml" CONFIG_TOML="${NODE_HOME}/config/config.toml" - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" - - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/minimum-gas-prices = ""/minimum-gas-prices = "50ncheq"/g' "${APP_TOML}" + sed -i "$SED_EXT" 's/enable = false/enable = true/g' "${APP_TOML}" + sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" + sed -i "$SED_EXT" 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" } function configure_genesis() { @@ -73,12 +58,10 @@ function configure_genesis() { GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json" # Default denom - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}" + sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "${GENESIS}" # Short voting period - # shellcheck disable=SC2086 - sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" + sed -i "$SED_EXT" 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" # Test accounts BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" From 68b3301b241f3d78674941cf20a8d845c7c9adbf Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:28:07 +0000 Subject: [PATCH 23/42] Rename pubKeyMultibase to publicKeyMultibase This makes it consistent with the actual standard, although this is mostly cosmetic --- tests/integration/cli_diddoc_negative_test.go | 20 +++++++++---------- .../cli_diddoc_pricing_negative_test.go | 4 ++-- tests/integration/cli_diddoc_pricing_test.go | 4 ++-- tests/integration/cli_diddoc_test.go | 8 ++++---- .../integration/cli_resource_negative_test.go | 4 ++-- .../cli_resource_pricing_negative_test.go | 4 ++-- .../integration/cli_resource_pricing_test.go | 4 ++-- tests/integration/cli_resource_test.go | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/integration/cli_diddoc_negative_test.go b/tests/integration/cli_diddoc_negative_test.go index d0ff2c00f..a9e15f51d 100644 --- a/tests/integration/cli_diddoc_negative_test.go +++ b/tests/integration/cli_diddoc_negative_test.go @@ -33,7 +33,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -42,7 +42,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, @@ -67,7 +67,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) + publicKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -76,7 +76,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase2, + VerificationMaterial: publicKeyMultibase2, }, }, Authentication: []string{keyId2}, @@ -164,7 +164,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -174,7 +174,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, @@ -200,7 +200,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, @@ -220,7 +220,7 @@ var _ = Describe("cheqd cli - negative did", func() { pubKey2, privKey2, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) + publicKeyMultibase2 := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey2) payload2 := types.MsgCreateDidDocPayload{ Id: did2, @@ -230,7 +230,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase2, + VerificationMaterial: publicKeyMultibase2, }, }, Authentication: []string{keyId2}, @@ -287,7 +287,7 @@ var _ = Describe("cheqd cli - negative did", func() { Id: keyId2AsExtraController, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did2, - VerificationMaterial: pubKeyMultibase2, + VerificationMaterial: publicKeyMultibase2, }) followingUpdatedPayload.Authentication = append(followingUpdatedPayload.Authentication, keyId2AsExtraController) followingUpdatedPayload.CapabilityDelegation = []string{keyId} diff --git a/tests/integration/cli_diddoc_pricing_negative_test.go b/tests/integration/cli_diddoc_pricing_negative_test.go index 9704aa424..264b470c1 100644 --- a/tests/integration/cli_diddoc_pricing_negative_test.go +++ b/tests/integration/cli_diddoc_pricing_negative_test.go @@ -59,7 +59,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -68,7 +68,7 @@ var _ = Describe("cheqd cli - negative diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_diddoc_pricing_test.go b/tests/integration/cli_diddoc_pricing_test.go index dfa2bdf8c..cf312a346 100644 --- a/tests/integration/cli_diddoc_pricing_test.go +++ b/tests/integration/cli_diddoc_pricing_test.go @@ -40,7 +40,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload = types.MsgCreateDidDocPayload{ Id: did, @@ -49,7 +49,7 @@ var _ = Describe("cheqd cli - positive diddoc pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_diddoc_test.go b/tests/integration/cli_diddoc_test.go index d28bfe1f6..b9f9e4fe2 100644 --- a/tests/integration/cli_diddoc_test.go +++ b/tests/integration/cli_diddoc_test.go @@ -34,7 +34,7 @@ var _ = Describe("cheqd cli - positive did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -43,7 +43,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyID}, @@ -155,7 +155,7 @@ var _ = Describe("cheqd cli - positive did", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateJSONWebKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateJSONWebKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -164,7 +164,7 @@ var _ = Describe("cheqd cli - positive did", func() { Id: keyID, VerificationMethodType: "JsonWebKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyID}, diff --git a/tests/integration/cli_resource_negative_test.go b/tests/integration/cli_resource_negative_test.go index b8c937e78..f1f505806 100644 --- a/tests/integration/cli_resource_negative_test.go +++ b/tests/integration/cli_resource_negative_test.go @@ -39,7 +39,7 @@ var _ = Describe("cheqd cli - negative resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -48,7 +48,7 @@ var _ = Describe("cheqd cli - negative resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_negative_test.go b/tests/integration/cli_resource_pricing_negative_test.go index 4d5c03e18..eda790f57 100644 --- a/tests/integration/cli_resource_pricing_negative_test.go +++ b/tests/integration/cli_resource_pricing_negative_test.go @@ -60,7 +60,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -69,7 +69,7 @@ var _ = Describe("cheqd cli - negative resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_pricing_test.go b/tests/integration/cli_resource_pricing_test.go index dd29b7c74..c5628ea5a 100644 --- a/tests/integration/cli_resource_pricing_test.go +++ b/tests/integration/cli_resource_pricing_test.go @@ -42,7 +42,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) didPayload := didtypes.MsgCreateDidDocPayload{ Id: did, @@ -51,7 +51,7 @@ var _ = Describe("cheqd cli - positive resource pricing", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, diff --git a/tests/integration/cli_resource_test.go b/tests/integration/cli_resource_test.go index 7d2f0ec9f..cd6abf80f 100644 --- a/tests/integration/cli_resource_test.go +++ b/tests/integration/cli_resource_test.go @@ -35,7 +35,7 @@ var _ = Describe("cheqd cli - positive resource", func() { pubKey, privKey, err := ed25519.GenerateKey(nil) Expect(err).To(BeNil()) - pubKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) + publicKeyMultibase := testsetup.GenerateEd25519VerificationKey2020VerificationMaterial(pubKey) payload := types.MsgCreateDidDocPayload{ Id: did, @@ -44,7 +44,7 @@ var _ = Describe("cheqd cli - positive resource", func() { Id: keyId, VerificationMethodType: "Ed25519VerificationKey2020", Controller: did, - VerificationMaterial: pubKeyMultibase, + VerificationMaterial: publicKeyMultibase, }, }, Authentication: []string{keyId}, From fd901a1bec36892c8b9ea31f3988c4445ed3a8c5 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:36:28 +0000 Subject: [PATCH 24/42] Fix SED_EXT shellcheck in legacy tests --- tests/legacy/ibc-defi/cheqd/cheqd-init.sh | 13 +++++-------- tests/legacy/ibc-defi/osmosis/osmosis_init.sh | 7 +++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh index 3eb73ab99..fb7d78bbe 100755 --- a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh +++ b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh @@ -5,9 +5,9 @@ set -euox pipefail # sed in macos requires extra argument if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' + SED_EXT='' elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' + SED_EXT='.orig' fi CHAIN_ID="cheqd" @@ -20,15 +20,12 @@ NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) cheqd-noded keys add cheqd-user --keyring-backend test # Config -# shellcheck disable=SC2086 -sed -i $sed_extension 's|minimum-gas-prices = ""|minimum-gas-prices = "25ncheq"|g' "$HOME/.cheqdnode/config/app.toml" -# shellcheck disable=SC2086 -sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" +sed -i "$SED_EXT" 's|minimum-gas-prices = ""|minimum-gas-prices = "50ncheq"|g' "$HOME/.cheqdnode/config/app.toml" +sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" # Genesis GENESIS="$HOME/.cheqdnode/config/genesis.json" -# shellcheck disable=SC2086 -sed -i $sed_extension 's/"stake"/"ncheq"/' "$GENESIS" +sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "$GENESIS" cheqd-noded add-genesis-account cheqd-user 1000000000000000000ncheq --keyring-backend test cheqd-noded gentx cheqd-user 10000000000000000ncheq --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh index bc2a8374e..8c114533b 100644 --- a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh @@ -5,9 +5,9 @@ set -euox pipefail # sed in macos requires extra argument if [[ "$OSTYPE" == "linux-gnu"* ]]; then - sed_extension='' + SED_EXT='' elif [[ "$OSTYPE" == "darwin"* ]]; then - sed_extension='.orig' + SED_EXT='.orig' fi CHAIN_ID="osmosis" @@ -27,5 +27,4 @@ jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/ mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json" # Config -# shellcheck disable=SC2086 -sed -i $sed_extension 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" +sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" From 4ef1f1a66492d92f21e9eafa8603930b1c9dc3e5 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:41:15 +0000 Subject: [PATCH 25/42] Fix SED_EXT setting --- docker/localnet/gen-network-config.sh | 10 +++++----- tests/legacy/ibc-defi/cheqd/cheqd-init.sh | 11 +++++------ tests/legacy/ibc-defi/osmosis/osmosis_init.sh | 9 +++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docker/localnet/gen-network-config.sh b/docker/localnet/gen-network-config.sh index 6661d3412..1c064bea6 100644 --- a/docker/localnet/gen-network-config.sh +++ b/docker/localnet/gen-network-config.sh @@ -4,11 +4,11 @@ set -euo pipefail -# sed in macos requires extra argument -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - SED_EXT='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - SED_EXT='.orig' +# sed in MacOS requires extra argument +if [[ "$OSTYPE" == "darwin"* ]]; then + SED_EXT='.orig' +else + SED_EXT='' fi # Params diff --git a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh index fb7d78bbe..86f6498e0 100755 --- a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh +++ b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh @@ -2,12 +2,11 @@ set -euox pipefail -# sed in macos requires extra argument - -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - SED_EXT='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - SED_EXT='.orig' +# sed in MacOS requires extra argument +if [[ "$OSTYPE" == "darwin"* ]]; then + SED_EXT='.orig' +else + SED_EXT='' fi CHAIN_ID="cheqd" diff --git a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh index 8c114533b..444666368 100644 --- a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh @@ -4,10 +4,11 @@ set -euox pipefail # sed in macos requires extra argument -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - SED_EXT='' -elif [[ "$OSTYPE" == "darwin"* ]]; then - SED_EXT='.orig' +# sed in MacOS requires extra argument +if [[ "$OSTYPE" == "darwin"* ]]; then + SED_EXT='.orig' +else + SED_EXT='' fi CHAIN_ID="osmosis" From d1a9fe19f65127dae3f9fc012908566296ec67ee Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 12:55:14 +0000 Subject: [PATCH 26/42] Typo fixes --- x/did/tests/tests_suite_test.go | 2 +- x/did/types/types_test.go | 2 +- x/did/utils/utils_suite_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/did/tests/tests_suite_test.go b/x/did/tests/tests_suite_test.go index abdc6ba58..d3e28bd9c 100644 --- a/x/did/tests/tests_suite_test.go +++ b/x/did/tests/tests_suite_test.go @@ -9,5 +9,5 @@ import ( func TestTestsGeneral(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Did Module") + RunSpecs(t, "DID Module") } diff --git a/x/did/types/types_test.go b/x/did/types/types_test.go index 3ee24ed3e..37de453fa 100644 --- a/x/did/types/types_test.go +++ b/x/did/types/types_test.go @@ -9,5 +9,5 @@ import ( func TestUtils(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Did Module Types") + RunSpecs(t, "DID Module Types") } diff --git a/x/did/utils/utils_suite_test.go b/x/did/utils/utils_suite_test.go index adaab32fc..3321a74c2 100644 --- a/x/did/utils/utils_suite_test.go +++ b/x/did/utils/utils_suite_test.go @@ -9,5 +9,5 @@ import ( func TestUtils(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Did Module Utils") + RunSpecs(t, "DID Module Utils") } From d37bbd8abc0283ef8289cfc0ade1cdf16fbd0913 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 13:08:01 +0000 Subject: [PATCH 27/42] Ignore files a bit differently --- .github/workflows/lint.yml | 1 - docker/localnet/gen-network-config.sh | 22 +++++++++---------- tests/legacy/ibc-defi/cheqd/cheqd-init.sh | 9 +++++--- tests/legacy/ibc-defi/osmosis/osmosis_init.sh | 3 ++- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5d7d28c8d..f66c7cb9d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -85,7 +85,6 @@ jobs: uses: github/super-linter/slim@v4 env: IGNORE_GITIGNORED_FILES: true - FILTER_REGEX_EXCLUDE: .*docs/config.json DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LOG_LEVEL: WARN diff --git a/docker/localnet/gen-network-config.sh b/docker/localnet/gen-network-config.sh index 1c064bea6..914855638 100644 --- a/docker/localnet/gen-network-config.sh +++ b/docker/localnet/gen-network-config.sh @@ -1,7 +1,7 @@ #!/bin/bash +# shellcheck disable=SC2086 # Generates network configuration for an arbitrary amount of validators, observers, and seeds. - set -euo pipefail # sed in MacOS requires extra argument @@ -38,14 +38,14 @@ function configure_node() { APP_TOML="${NODE_HOME}/config/app.toml" CONFIG_TOML="${NODE_HOME}/config/config.toml" - sed -i "$SED_EXT" 's/minimum-gas-prices = ""/minimum-gas-prices = "50ncheq"/g' "${APP_TOML}" - sed -i "$SED_EXT" 's/enable = false/enable = true/g' "${APP_TOML}" - sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" - sed -i "$SED_EXT" 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "50ncheq"/g' "${APP_TOML}" + sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}" + sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}" + sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}" + sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}" } function configure_genesis() { @@ -58,10 +58,10 @@ function configure_genesis() { GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json" # Default denom - sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "${GENESIS}" + sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}" # Short voting period - sed -i "$SED_EXT" 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" + sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}" # Test accounts BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96" diff --git a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh index 86f6498e0..4801b800f 100755 --- a/tests/legacy/ibc-defi/cheqd/cheqd-init.sh +++ b/tests/legacy/ibc-defi/cheqd/cheqd-init.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 set -euox pipefail @@ -19,12 +20,14 @@ NODE_0_VAL_PUBKEY=$(cheqd-noded tendermint show-validator) cheqd-noded keys add cheqd-user --keyring-backend test # Config -sed -i "$SED_EXT" 's|minimum-gas-prices = ""|minimum-gas-prices = "50ncheq"|g' "$HOME/.cheqdnode/config/app.toml" -sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" +sed -i $SED_EXT 's|minimum-gas-prices = ""|minimum-gas-prices = "50ncheq"|g' "$HOME/.cheqdnode/config/app.toml" + +# shellcheck disable=SC2086 +sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.cheqdnode/config/config.toml" # Genesis GENESIS="$HOME/.cheqdnode/config/genesis.json" -sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "$GENESIS" +sed -i $SED_EXT 's/"stake"/"ncheq"/' "$GENESIS" cheqd-noded add-genesis-account cheqd-user 1000000000000000000ncheq --keyring-backend test cheqd-noded gentx cheqd-user 10000000000000000ncheq --chain-id $CHAIN_ID --pubkey "$NODE_0_VAL_PUBKEY" --keyring-backend test diff --git a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh index 444666368..aa109b562 100644 --- a/tests/legacy/ibc-defi/osmosis/osmosis_init.sh +++ b/tests/legacy/ibc-defi/osmosis/osmosis_init.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2086 set -euox pipefail @@ -28,4 +29,4 @@ jq '.app_state["gov"]["voting_params"]["voting_period"]="10s"' "$HOME/.osmosisd/ mv "$HOME/.osmosisd/config/tmp_genesis.json" "$HOME/.osmosisd/config/genesis.json" # Config -sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" +sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "$HOME/.osmosisd/config/config.toml" From 3624ffe8827a1c485e9087bb4883d8075ee30d52 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 13:19:04 +0000 Subject: [PATCH 28/42] Fix lint checks --- tests/upgrade/unit/setup/dataset.go | 2 +- x/did/keeper/msg_server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/upgrade/unit/setup/dataset.go b/tests/upgrade/unit/setup/dataset.go index 37eac904c..87d547098 100644 --- a/tests/upgrade/unit/setup/dataset.go +++ b/tests/upgrade/unit/setup/dataset.go @@ -6,7 +6,7 @@ import ( resourcetypes "github.com/cheqd/cheqd-node/x/resource/types" resourcetypesv1 "github.com/cheqd/cheqd-node/x/resource/types/v1" - . "github.com/onsi/gomega" //nolint: revive,stylecheck + . "github.com/onsi/gomega" ) // Existing diff --git a/x/did/keeper/msg_server.go b/x/did/keeper/msg_server.go index 4d2703e1c..89672bcbb 100644 --- a/x/did/keeper/msg_server.go +++ b/x/did/keeper/msg_server.go @@ -51,7 +51,7 @@ func MustFindDidDoc(k *Keeper, ctx *sdk.Context, inMemoryDIDDocs map[string]type } func FindVerificationMethod(k *Keeper, ctx *sdk.Context, inMemoryDIDs map[string]types.DidDocWithMetadata, didURL string) (res types.VerificationMethod, found bool, err error) { - did, _, _, _ := utils.MustSplitDIDUrl(didURL) //nolint:dogsled + did, _, _, _ := utils.MustSplitDIDUrl(didURL) didDoc, found, err := FindDidDoc(k, ctx, inMemoryDIDs, did) if err != nil || !found { From 23ebbd9fdfdd010a995a8e4b3a50f55b228185d0 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 14:48:33 +0000 Subject: [PATCH 29/42] Update .goreleaser.yml --- .goreleaser.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 9d427a359..15b983183 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -8,9 +8,11 @@ env: before: hooks: - make clean - - go mod tidy - - go mod download + - make tidy + - make install - make proto-gen + # Uncomment this bit when our Swagger generation is ready + # - make swagger builds: - id: ubuntu-latest-amd64 @@ -22,7 +24,7 @@ builds: - CGO_ENABLED=1 flags: - -mod=readonly - - -tags="netgo ledger" + - -tags="netgo ledger goleveldb" - -trimpath ldflags: - -s -w @@ -42,7 +44,7 @@ builds: - sudo apt update && sudo apt install clang gcc-multilib g++-multilib -y flags: - -mod=readonly - - -tags="netgo ledger" + - -tags="netgo ledger goleveldb" - -trimpath ldflags: - -s -w From 73f8ba6cb4db09ccb94417cfc7b669e932d5ef75 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 15:12:14 +0000 Subject: [PATCH 30/42] Update Dockerfile --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0826fbf05..0e6c3f96c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,13 +15,13 @@ WORKDIR /go/src/github.com/cheqd/cheqd-node COPY . . # Make node binary -RUN make build +RUN make install && make build ############################################################### ### STAGE 2: Build cheqd-node image ### ############################################################### -FROM alpine:3.17 AS runner +FROM alpine:3.18 AS runner # Install pre-requisites RUN apk update && apk add --no-cache bash ca-certificates From bfe2af16e8f0c9bfec34439f886fa975939d93f6 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 15:12:18 +0000 Subject: [PATCH 31/42] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f399cbeb5..97074905d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,6 +36,7 @@ jobs: build-docker: name: "Docker image" runs-on: ubuntu-20.04 + needs: build-binary env: IMAGE_NAME: ${{ github.repository }} From 88405b0986acde94c795b4042a0177fa4fe76c36 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 15:44:47 +0000 Subject: [PATCH 32/42] Update Golang linter settings --- .github/linters/.golangci.yaml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/linters/.golangci.yaml b/.github/linters/.golangci.yaml index 700dd783e..6c062da12 100644 --- a/.github/linters/.golangci.yaml +++ b/.github/linters/.golangci.yaml @@ -18,7 +18,6 @@ linters: - gocritic - gofumpt - goimports - - gosec - gosimple - govet - ineffassign @@ -26,17 +25,27 @@ linters: - nakedret - nestif - nolintlint - - prealloc - - revive - staticcheck - stylecheck - typecheck - unconvert - - unparam - unused linters-settings: + dogsled: + # Checks assignments with too many blank identifiers. + # Default: 2 + max-blank-identifiers: 3 + + gocritic: + # Which checks should be disabled; can't be combined with 'enabled-checks'. + # See https://go-critic.github.io/overview#checks-overview. + # Default: [] + disabled-checks: + - regexpMust + - badCall # Remove this after CI workflow PR + gofumpt: lang-version: "1.18" @@ -45,3 +54,16 @@ linters-settings: - cheqd - cheq - ncheq + + stylecheck: + # Select the Go version to target. + go: "1.18" + # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks + # Default: ["*"] + checks: ["all"] + # https://staticcheck.io/docs/configuration/options/#dot_import_whitelist + dot-import-whitelist: + - "github.com/cheqd/cheqd-node/x/did/utils" + - "github.com/onsi/gomega" + # https://staticcheck.io/docs/configuration/options/#initialisms + initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] From 7aacd770014d58c434b253ecfa89225a85f618ac Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 15:45:02 +0000 Subject: [PATCH 33/42] Remove gosec nolint --- simapp/test_helpers.go | 4 ++-- tests/upgrade/integration/cli/exec.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 9ece4df24..31488d556 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -362,7 +362,7 @@ func SignCheckDeliver( chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { tx, err := helpers.GenSignedMockTx( - rand.New(rand.NewSource(time.Now().UnixNano())), //nolint:gosec + rand.New(rand.NewSource(time.Now().UnixNano())), txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -533,7 +533,7 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i var err error for i := 0; i < numToGenerate; i++ { txs[i], err = helpers.GenSignedMockTx( - rand.New(rand.NewSource(time.Now().UnixNano())), //nolint:gosec + rand.New(rand.NewSource(time.Now().UnixNano())), txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, diff --git a/tests/upgrade/integration/cli/exec.go b/tests/upgrade/integration/cli/exec.go index cab7719e7..6a97f0398 100644 --- a/tests/upgrade/integration/cli/exec.go +++ b/tests/upgrade/integration/cli/exec.go @@ -13,7 +13,7 @@ func Exec(args ...string) (string, error) { } func ExecDirect(args ...string) (string, error) { - cmd := exec.Command(args[0], args[1:]...) //nolint:gosec + cmd := exec.Command(args[0], args[1:]...) out, err := cmd.CombinedOutput() if err != nil { return "", errors.Wrap(err, string(out)) @@ -23,7 +23,7 @@ func ExecDirect(args ...string) (string, error) { } func ExecWithEnv(env []string, args ...string) (string, error) { - cmd := exec.Command(args[0], args[1:]...) //nolint:gosec + cmd := exec.Command(args[0], args[1:]...) cmd.Env = append(os.Environ(), env...) out, err := cmd.CombinedOutput() if err != nil { From ab6437c2f9b0dcef9251586501a65015810aa370 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 15:58:12 +0000 Subject: [PATCH 34/42] Remove unused comments --- .github/linters/.golangci.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/linters/.golangci.yaml b/.github/linters/.golangci.yaml index 6c062da12..7c95f5769 100644 --- a/.github/linters/.golangci.yaml +++ b/.github/linters/.golangci.yaml @@ -1,10 +1,5 @@ run: timeout: 10m - # skip-dirs: - # - x/did/keeper/v1 - # - x/did/types/v1 - # - x/resource/keeper/v1 - # - x/resource/types/v1 linters: From e4f13b5a7e32574469838463bd75b03be4cb5327 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:01:37 +0000 Subject: [PATCH 35/42] Add TODO for nolint comments that need to be removed --- app/app.go | 1 + tests/upgrade/integration/cli/helpers.go | 1 + 2 files changed, 2 insertions(+) diff --git a/app/app.go b/app/app.go index 231c1ad49..f6fa541c3 100644 --- a/app/app.go +++ b/app/app.go @@ -743,6 +743,7 @@ func New( app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) + // TODO: Remove this after cheqd-node release v1.x is successful //nolint: errcheck app.configurator.RegisterMigration( didtypes.ModuleName, diff --git a/tests/upgrade/integration/cli/helpers.go b/tests/upgrade/integration/cli/helpers.go index 0a411c90c..66038d017 100644 --- a/tests/upgrade/integration/cli/helpers.go +++ b/tests/upgrade/integration/cli/helpers.go @@ -203,6 +203,7 @@ func TrimExtraLineOffset(input string, offset int) string { func MakeCodecWithExtendedRegistry() codec.Codec { interfaceRegistry := types.NewInterfaceRegistry() + // TODO: Remove nolint after cheqd-node release v1.x is successful // Register the interfaces from the cosmos-sdk codebase. interfaceRegistry.RegisterImplementations( (*govtypesv1beta1.Content)(nil), From 9a1dd4ba1f2217b640b0c5abedc399b2bed56f50 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:05:22 +0000 Subject: [PATCH 36/42] Update buf.lock --- proto/buf.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/buf.lock b/proto/buf.lock index 137859ffd..2b9acde70 100644 --- a/proto/buf.lock +++ b/proto/buf.lock @@ -8,7 +8,7 @@ deps: - remote: buf.build owner: cosmos repository: cosmos-sdk - commit: 794eb423daef4787a1f3c59443d1d11e + commit: bdacf2723fe749b18b00c7347cd0501c - remote: buf.build owner: cosmos repository: gogo-proto From b2c1b20fdd29ecb8d2a2cd6d372f338205670de2 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:06:37 +0000 Subject: [PATCH 37/42] buf format --- proto/cheqd/did/v1/did.proto | 18 ++++++++--------- proto/cheqd/did/v1/query.proto | 4 +++- proto/cheqd/did/v1/tx.proto | 4 +++- proto/cheqd/did/v2/fee.proto | 6 +++--- proto/cheqd/did/v2/query.proto | 14 +++++++------ proto/cheqd/did/v2/tx.proto | 15 +++++++++----- proto/cheqd/resource/v1/genesis.proto | 4 +++- proto/cheqd/resource/v1/query.proto | 23 +++++++++++----------- proto/cheqd/resource/v2/fee.proto | 6 +++--- proto/cheqd/resource/v2/query.proto | 27 +++++++++++++------------- proto/cheqd/resource/v2/resource.proto | 4 +++- proto/cheqd/resource/v2/tx.proto | 4 +++- 12 files changed, 73 insertions(+), 56 deletions(-) diff --git a/proto/cheqd/did/v1/did.proto b/proto/cheqd/did/v1/did.proto index a5221cfc8..367c1cddf 100644 --- a/proto/cheqd/did/v1/did.proto +++ b/proto/cheqd/did/v1/did.proto @@ -9,15 +9,15 @@ option go_package = "github.com/cheqd/cheqd-node/x/did/types/v1"; message Did { repeated string context = 1; // optional string id = 2; - repeated string controller = 3; // optional + repeated string controller = 3; // optional repeated VerificationMethod verification_method = 4; // optional - repeated string authentication = 5; // optional - repeated string assertion_method = 6; // optional - repeated string capability_invocation = 7; // optional - repeated string capability_delegation = 8; // optional - repeated string key_agreement = 9; // optional - repeated Service service = 10; // optional - repeated string also_known_as = 11; // optional + repeated string authentication = 5; // optional + repeated string assertion_method = 6; // optional + repeated string capability_invocation = 7; // optional + repeated string capability_delegation = 8; // optional + repeated string key_agreement = 9; // optional + repeated Service service = 10; // optional + repeated string also_known_as = 11; // optional } message VerificationMethod { @@ -25,7 +25,7 @@ message VerificationMethod { string type = 2; string controller = 3; repeated KeyValuePair public_key_jwk = 4; // optional - string public_key_multibase = 5; // optional + string public_key_multibase = 5; // optional } message Service { diff --git a/proto/cheqd/did/v1/query.proto b/proto/cheqd/did/v1/query.proto index b79d39908..3a972af3c 100644 --- a/proto/cheqd/did/v1/query.proto +++ b/proto/cheqd/did/v1/query.proto @@ -14,7 +14,9 @@ service Query { } } -message QueryGetDidRequest { string id = 1; } +message QueryGetDidRequest { + string id = 1; +} message QueryGetDidResponse { Did did = 1; diff --git a/proto/cheqd/did/v1/tx.proto b/proto/cheqd/did/v1/tx.proto index 2f22d3cb5..a7f376f9f 100644 --- a/proto/cheqd/did/v1/tx.proto +++ b/proto/cheqd/did/v1/tx.proto @@ -35,7 +35,9 @@ message SignInfo { string signature = 2; } -message MsgDeactivateDidPayload { string id = 1; } +message MsgDeactivateDidPayload { + string id = 1; +} message MsgDeactivateDidResponse { Did did = 1; diff --git a/proto/cheqd/did/v2/fee.proto b/proto/cheqd/did/v2/fee.proto index 841af9cef..9696b09bd 100644 --- a/proto/cheqd/did/v2/fee.proto +++ b/proto/cheqd/did/v2/fee.proto @@ -11,9 +11,9 @@ option (gogoproto.equal_all) = true; // FeeParams defines the parameters for the `did` module fixed fee. message FeeParams { // Tx types define the fixed fee each for the `did` module. - cosmos.base.v1beta1.Coin create_did = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin update_did = 2 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin deactivate_did = 3 [ (gogoproto.nullable) = false ]; + cosmos.base.v1beta1.Coin create_did = 1 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin update_did = 2 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin deactivate_did = 3 [(gogoproto.nullable) = false]; string burn_factor = 4 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", diff --git a/proto/cheqd/did/v2/query.proto b/proto/cheqd/did/v2/query.proto index 113779eda..37538bfcd 100644 --- a/proto/cheqd/did/v2/query.proto +++ b/proto/cheqd/did/v2/query.proto @@ -12,13 +12,11 @@ service Query { option (google.api.http).get = "/cheqd/did/v2/{id}"; } - rpc DidDocVersion(QueryGetDidDocVersionRequest) - returns (QueryDidDocVersionResponse) { + rpc DidDocVersion(QueryGetDidDocVersionRequest) returns (QueryDidDocVersionResponse) { option (google.api.http).get = "/cheqd/did/v2/{id}/version/{version}"; } - rpc AllDidDocVersionsMetadata(QueryGetAllDidDocVersionsMetadataRequest) - returns (QueryAllDidDocVersionsMetadataResponse) { + rpc AllDidDocVersionsMetadata(QueryGetAllDidDocVersionsMetadataRequest) returns (QueryAllDidDocVersionsMetadataResponse) { option (google.api.http).get = "/cheqd/did/v2/{id}/metadata"; } } @@ -28,7 +26,9 @@ message QueryGetDidDocRequest { string id = 1; } -message QueryDidDocResponse { DidDocWithMetadata value = 1; } +message QueryDidDocResponse { + DidDocWithMetadata value = 1; +} message QueryGetDidDocVersionRequest { // is a DID @@ -37,7 +37,9 @@ message QueryGetDidDocVersionRequest { string version = 2; } -message QueryDidDocVersionResponse { DidDocWithMetadata value = 1; } +message QueryDidDocVersionResponse { + DidDocWithMetadata value = 1; +} message QueryGetAllDidDocVersionsMetadataRequest { // is a DID diff --git a/proto/cheqd/did/v2/tx.proto b/proto/cheqd/did/v2/tx.proto index ae59b618c..aa1eb46df 100644 --- a/proto/cheqd/did/v2/tx.proto +++ b/proto/cheqd/did/v2/tx.proto @@ -9,8 +9,7 @@ option go_package = "github.com/cheqd/cheqd-node/x/did/types"; service Msg { rpc CreateDidDoc(MsgCreateDidDoc) returns (MsgCreateDidDocResponse); rpc UpdateDidDoc(MsgUpdateDidDoc) returns (MsgUpdateDidDocResponse); - rpc DeactivateDidDoc(MsgDeactivateDidDoc) - returns (MsgDeactivateDidDocResponse); + rpc DeactivateDidDoc(MsgDeactivateDidDoc) returns (MsgDeactivateDidDocResponse); } message MsgCreateDidDoc { @@ -48,7 +47,9 @@ message MsgCreateDidDocPayload { string version_id = 12; } -message MsgCreateDidDocResponse { DidDocWithMetadata value = 1; } +message MsgCreateDidDocResponse { + DidDocWithMetadata value = 1; +} message MsgUpdateDidDocPayload { repeated string context = 1; @@ -65,11 +66,15 @@ message MsgUpdateDidDocPayload { string version_id = 12; } -message MsgUpdateDidDocResponse { DidDocWithMetadata value = 1; } +message MsgUpdateDidDocResponse { + DidDocWithMetadata value = 1; +} message MsgDeactivateDidDocPayload { string id = 1; string version_id = 2; } -message MsgDeactivateDidDocResponse { DidDocWithMetadata value = 1; } +message MsgDeactivateDidDocResponse { + DidDocWithMetadata value = 1; +} diff --git a/proto/cheqd/resource/v1/genesis.proto b/proto/cheqd/resource/v1/genesis.proto index 9fe44085d..a58349633 100644 --- a/proto/cheqd/resource/v1/genesis.proto +++ b/proto/cheqd/resource/v1/genesis.proto @@ -6,4 +6,6 @@ import "cheqd/resource/v1/resource.proto"; option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v1"; // GenesisState defines the cheqd module's genesis state. -message GenesisState { repeated Resource resourceList = 1; } +message GenesisState { + repeated Resource resourceList = 1; +} diff --git a/proto/cheqd/resource/v1/query.proto b/proto/cheqd/resource/v1/query.proto index 74d1d93b5..7aa732f0a 100644 --- a/proto/cheqd/resource/v1/query.proto +++ b/proto/cheqd/resource/v1/query.proto @@ -9,18 +9,13 @@ option go_package = "github.com/cheqd/cheqd-node/x/resource/types/v1"; // Query defines the gRPC querier service. service Query { rpc Resource(QueryGetResourceRequest) returns (QueryResourceResponse) { - option (google.api.http).get = - "/1.0/identifiers/{collection_id}/resources/{id}"; + option (google.api.http).get = "/1.0/identifiers/{collection_id}/resources/{id}"; } - rpc CollectionResources(QueryGetCollectionResourcesRequest) - returns (QueryCollectionResourcesResponse) { - option (google.api.http).get = - "/1.0/identifiers/{collection_id}/resources/all"; + rpc CollectionResources(QueryGetCollectionResourcesRequest) returns (QueryCollectionResourcesResponse) { + option (google.api.http).get = "/1.0/identifiers/{collection_id}/resources/all"; } - rpc AllResourceVersions(QueryGetAllResourceVersionsRequest) - returns (QueryGetAllResourceVersionsResponse) { - option (google.api.http).get = - "/1.0/identifiers/{collection_id}/resources/versions/{name}"; + rpc AllResourceVersions(QueryGetAllResourceVersionsRequest) returns (QueryGetAllResourceVersionsResponse) { + option (google.api.http).get = "/1.0/identifiers/{collection_id}/resources/versions/{name}"; } } @@ -29,9 +24,13 @@ message QueryGetResourceRequest { string id = 2; } -message QueryResourceResponse { Resource resource = 1; } +message QueryResourceResponse { + Resource resource = 1; +} -message QueryGetCollectionResourcesRequest { string collection_id = 1; } +message QueryGetCollectionResourcesRequest { + string collection_id = 1; +} message QueryCollectionResourcesResponse { repeated ResourceHeader resources = 1; diff --git a/proto/cheqd/resource/v2/fee.proto b/proto/cheqd/resource/v2/fee.proto index abdbb156c..500324ade 100644 --- a/proto/cheqd/resource/v2/fee.proto +++ b/proto/cheqd/resource/v2/fee.proto @@ -11,9 +11,9 @@ option (gogoproto.equal_all) = true; // FeeParams defines the parameters for the `resource` module fixed fee. message FeeParams { // Media types define the fixed fee each for the `resource` module. - cosmos.base.v1beta1.Coin image = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin json = 2 [ (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin default = 3 [ (gogoproto.nullable) = false ]; + cosmos.base.v1beta1.Coin image = 1 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin json = 2 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin default = 3 [(gogoproto.nullable) = false]; string burn_factor = 4 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", diff --git a/proto/cheqd/resource/v2/query.proto b/proto/cheqd/resource/v2/query.proto index 115505d81..1ea47caa8 100644 --- a/proto/cheqd/resource/v2/query.proto +++ b/proto/cheqd/resource/v2/query.proto @@ -9,20 +9,15 @@ option go_package = "github.com/cheqd/cheqd-node/x/resource/types"; service Query { rpc Resource(QueryGetResourceRequest) returns (QueryResourceResponse) { - option (google.api.http).get = - "/cheqd/resource/v2/{collection_id}/resources/{id}"; + option (google.api.http).get = "/cheqd/resource/v2/{collection_id}/resources/{id}"; } - rpc ResourceMetadata(QueryGetResourceMetadataRequest) - returns (QueryResourceMetadataResponse) { - option (google.api.http).get = - "/cheqd/resource/v2/{collection_id}/resources/{id}/metadata"; + rpc ResourceMetadata(QueryGetResourceMetadataRequest) returns (QueryResourceMetadataResponse) { + option (google.api.http).get = "/cheqd/resource/v2/{collection_id}/resources/{id}/metadata"; } - rpc CollectionResources(QueryGetCollectionResourcesRequest) - returns (QueryCollectionResourcesResponse) { - option (google.api.http).get = - "/cheqd/resource/v2/{collection_id}/metadata"; + rpc CollectionResources(QueryGetCollectionResourcesRequest) returns (QueryCollectionResourcesResponse) { + option (google.api.http).get = "/cheqd/resource/v2/{collection_id}/metadata"; } } @@ -33,7 +28,9 @@ message QueryGetResourceRequest { string id = 2; } -message QueryResourceResponse { ResourceWithMetadata resource = 1; } +message QueryResourceResponse { + ResourceWithMetadata resource = 1; +} message QueryGetResourceMetadataRequest { // is unique identifier a for collection @@ -42,11 +39,15 @@ message QueryGetResourceMetadataRequest { string id = 2; } -message QueryResourceMetadataResponse { Metadata resource = 1; } +message QueryResourceMetadataResponse { + Metadata resource = 1; +} message QueryGetCollectionResourcesRequest { // is unique identifier a for collection string collection_id = 1; } -message QueryCollectionResourcesResponse { repeated Metadata resources = 1; } +message QueryCollectionResourcesResponse { + repeated Metadata resources = 1; +} diff --git a/proto/cheqd/resource/v2/resource.proto b/proto/cheqd/resource/v2/resource.proto index 68455ff7f..60e756327 100644 --- a/proto/cheqd/resource/v2/resource.proto +++ b/proto/cheqd/resource/v2/resource.proto @@ -4,7 +4,9 @@ package cheqd.resource.v2; option go_package = "github.com/cheqd/cheqd-node/x/resource/types"; -message Resource { bytes data = 1; } +message Resource { + bytes data = 1; +} message ResourceWithMetadata { Resource resource = 1; diff --git a/proto/cheqd/resource/v2/tx.proto b/proto/cheqd/resource/v2/tx.proto index 03a6b888c..fa0c6cf93 100644 --- a/proto/cheqd/resource/v2/tx.proto +++ b/proto/cheqd/resource/v2/tx.proto @@ -27,4 +27,6 @@ message MsgCreateResourcePayload { repeated cheqd.resource.v2.AlternativeUri also_known_as = 7; } -message MsgCreateResourceResponse { Metadata resource = 1; } +message MsgCreateResourceResponse { + Metadata resource = 1; +} From 47500ce5ea306a10792990fba7ff777a336f5fb3 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:06:50 +0000 Subject: [PATCH 38/42] Fix stylecheck --- x/resource/keeper/query_server_collection_resources.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/resource/keeper/query_server_collection_resources.go b/x/resource/keeper/query_server_collection_resources.go index ca09da17e..82ea99c76 100644 --- a/x/resource/keeper/query_server_collection_resources.go +++ b/x/resource/keeper/query_server_collection_resources.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (m queryServer) CollectionResources(c context.Context, req *types.QueryGetCollectionResourcesRequest) (*types.QueryCollectionResourcesResponse, error) { //nolint:stylecheck +func (q queryServer) CollectionResources(c context.Context, req *types.QueryGetCollectionResourcesRequest) (*types.QueryCollectionResourcesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -21,14 +21,14 @@ func (m queryServer) CollectionResources(c context.Context, req *types.QueryGetC req.Normalize() // Validate corresponding DIDDoc exists - namespace := m.didKeeper.GetDidNamespace(&ctx) + namespace := q.didKeeper.GetDidNamespace(&ctx) did := didutils.JoinDID(didtypes.DidMethod, namespace, req.CollectionId) - if !m.didKeeper.HasDidDoc(&ctx, did) { + if !q.didKeeper.HasDidDoc(&ctx, did) { return nil, didtypes.ErrDidDocNotFound.Wrap(did) } // Get all resources - resources := m.GetResourceCollection(&ctx, req.CollectionId) + resources := q.GetResourceCollection(&ctx, req.CollectionId) return &types.QueryCollectionResourcesResponse{ Resources: resources, From 4640f8efb087b7e6f1301ad04aa3a05194a1b9fb Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:09:44 +0000 Subject: [PATCH 39/42] Fix alpine version --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0e6c3f96c..107a78446 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,7 @@ RUN make install && make build ### STAGE 2: Build cheqd-node image ### ############################################################### -FROM alpine:3.18 AS runner +FROM alpine:3.17 AS runner # Install pre-requisites RUN apk update && apk add --no-cache bash ca-certificates From 5421ca65c18105e3c7cc3649dfa5d00ddb8519f4 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:10:15 +0000 Subject: [PATCH 40/42] Update build.yml --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97074905d..f399cbeb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,6 @@ jobs: build-docker: name: "Docker image" runs-on: ubuntu-20.04 - needs: build-binary env: IMAGE_NAME: ${{ github.repository }} From f582931dd93a4e8f10abbcfef1d721c4f32c822c Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:13:27 +0000 Subject: [PATCH 41/42] Work super linter only on diffs --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f66c7cb9d..7b964387b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -88,7 +88,7 @@ jobs: DEFAULT_BRANCH: main GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LOG_LEVEL: WARN - VALIDATE_ALL_CODEBASE: true + VALIDATE_ALL_CODEBASE: false MULTI_STATUS: true VALIDATE_BASH: true From 154d7f14cf8faf44e1d8ce6a072b002c5459d8a9 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Fri, 6 Jan 2023 16:17:11 +0000 Subject: [PATCH 42/42] Lint all codebase on release --- .github/workflows/release.yml | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index de4bacba9..719646628 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,10 +10,42 @@ permissions: jobs: + # Super Linter only runs on diffs in PRs, so we run it on VALIDATE_ALL_CODEBASE=true before release + super-lint: + name: "Super Linter" + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Required to fetch version + + - name: Run Super Linter + uses: github/super-linter/slim@v4 + env: + IGNORE_GITIGNORED_FILES: true + DEFAULT_BRANCH: main + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LOG_LEVEL: WARN + VALIDATE_ALL_CODEBASE: true + MULTI_STATUS: true + + VALIDATE_BASH: true + VALIDATE_DOCKERFILE_HADOLINT: true + VALIDATE_ENV: true + VALIDATE_GITHUB_ACTIONS: true + VALIDATE_JSON: true + VALIDATE_MARKDOWN: true + VALIDATE_OPENAPI: true + VALIDATE_PYTHON_PYLINT: true + VALIDATE_XML: true + VALIDATE_YAML: true + release-binary: name: "Node binary" runs-on: ubuntu-20.04 + needs: super-lint outputs: RELEASE_VERSION: ${{ steps.set-version.outputs.RELEASE_VERSION }} @@ -79,7 +111,7 @@ jobs: release-docker: name: "Docker image" - needs: release-binary + needs: [ super-lint, release-binary ] runs-on: ubuntu-20.04 env: IMAGE_NAME: ${{ github.repository }}