diff --git a/.golangci.yaml b/.golangci.yaml index 6a884a8e..08024868 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -31,7 +31,13 @@ linters-settings: lines: 100 statements: 50 gci: - local-prefixes: github.com/elesto-dao/elesto + #local-prefixes: github.com/elesto-dao/elesto + sections: + - standard # Captures all standard packages if they do not match another section. + - default # Contains all imports that could not be matched to another section type. + #- comment(your text here) # Prints the specified indented comment. + #- newLine # Prints an empty line + - prefix(github.com/elesto-dao/elesto) # Groups all imports with the specified Prefix. goimports: local-prefixes: github.com/elesto-dao/elesto goconst: @@ -82,4 +88,4 @@ linters-settings: config: G101: pattern: "(?i)private_key|secret_key|mnemonic|password" - \ No newline at end of file + diff --git a/Makefile b/Makefile index 70707cc5..84dd2f39 100644 --- a/Makefile +++ b/Makefile @@ -209,7 +209,7 @@ test-sim-profile \ ############################################################################### protogen: - starport generate proto-go + ignite generate proto-go -y ############################################################################### ### Documentation ### diff --git a/app/app.go b/app/app.go index 4487a226..fab0474c 100644 --- a/app/app.go +++ b/app/app.go @@ -382,6 +382,8 @@ func New( appCodec, keys[credentials.StoreKey], keys[credentials.MemStoreKey], + app.DidKeeper, + app.AccountKeeper, ) credentialsModule := credentialsmodule.NewAppModule(appCodec, app.CredentialsKeeper, app.AccountKeeper, app.BankKeeper, app.DidKeeper) diff --git a/go.mod b/go.mod index 8643fddc..b56a90e3 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/elesto-dao/elesto go 1.17 require ( - github.com/coinbase/kryptology v1.5.5 github.com/cosmos/cosmos-sdk v0.45.1 github.com/cosmos/ibc-go/v3 v3.0.0 github.com/gogo/protobuf v1.3.3 @@ -18,6 +17,7 @@ require ( github.com/tendermint/starport v0.19.5 github.com/tendermint/tendermint v0.34.14 github.com/tendermint/tm-db v0.6.4 + github.com/xeipuuv/gojsonschema v1.2.0 google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.27.1 @@ -25,7 +25,6 @@ require ( require ( filippo.io/edwards25519 v1.0.0-rc.1 // indirect - git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9 // indirect github.com/99designs/keyring v1.1.6 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/DataDog/zstd v1.4.5 // indirect @@ -34,12 +33,10 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect github.com/btcsuite/btcd v0.22.0-beta // indirect - github.com/bwesterb/go-ristretto v1.2.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect github.com/confio/ics23/go v0.7.0 // indirect - github.com/consensys/gnark-crypto v0.5.3 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/iavl v0.17.3 // indirect @@ -90,10 +87,8 @@ require ( github.com/minio/highwayhash v1.0.1 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/nixberg/chacha-rng-go v0.1.0 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect - github.com/piprate/json-gold v0.4.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.11.0 // indirect @@ -116,7 +111,6 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.5 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect @@ -124,6 +118,7 @@ require ( golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect diff --git a/go.sum b/go.sum index 90f8bff6..51ad363a 100644 --- a/go.sum +++ b/go.sum @@ -56,9 +56,6 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7 filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= -git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= -git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9 h1:Ahny8Ud1LjVMMAlt8utUFKhhxJtwBAualvsbc/Sk7cE= -git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= github.com/AlecAivazis/survey/v2 v2.1.1/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk= github.com/Antonboom/errname v0.1.4/go.mod h1:jRXo3m0E0EuCnK3wbsSVH3X55Z4iTDLl6ZfCxwFj4TM= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= @@ -217,7 +214,6 @@ github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BR github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= -github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= @@ -238,8 +234,6 @@ github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7 github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= -github.com/bwesterb/go-ristretto v1.2.0 h1:xxWOVbN5m8NNKiSDZXE1jtZvZnC6JSJ9cYFADiZcWtw= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/calmh/randomart v1.1.0/go.mod h1:DQUbPVyP+7PAs21w/AnfMKG5NioxS3TbZ2F9MSK/jFM= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -284,8 +278,6 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/kryptology v1.5.5 h1:iSB2AOGYBxvq+/4huDWVEnyCWWWrVBbb7yiCcLrE2rw= -github.com/coinbase/kryptology v1.5.5/go.mod h1:3zId6V3k/8v/o5gksjffbWMkH7Ik1UgeZVGTBvlpIxc= github.com/coinbase/rosetta-sdk-go v0.6.10/go.mod h1:J/JFMsfcePrjJZkwQFLh+hJErkAmdm9Iyy3D5Y0LfXo= github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= @@ -294,9 +286,6 @@ github.com/confio/ics23/go v0.6.3/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4ur github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= -github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.5.3 h1:4xLFGZR3NWEH2zy+YzvzHicpToQR8FXFbfLNvpGB+rE= -github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4/go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE= github.com/containerd/aufs v0.0.0-20201003224125-76a6863f2989/go.mod h1:AkGGQs9NM2vtYHaUen+NljV0/baGCAPELGm2q9ZXpWU= github.com/containerd/aufs v0.0.0-20210316121734-20793ff83c97/go.mod h1:kL5kd6KM5TzQjR79jljyi4olc1Vrx6XBlcyj3gNv2PU= @@ -980,8 +969,6 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+sBqGZrRkMwPgg= github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= github.com/ldez/tagliatelle v0.2.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= @@ -1140,8 +1127,6 @@ github.com/nishanths/exhaustive v0.2.3/go.mod h1:bhIX678Nx8inLM9PbpvK1yv6oGtoP8B github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/nishanths/predeclared v0.2.1/go.mod h1:HvkGJcA3naj4lOwnFXFDkFxVtSqQMB9sbB1usJ+xjQE= -github.com/nixberg/chacha-rng-go v0.1.0 h1:2Y90hS8H/O+82yLWKD4MldkJM7Pzhezc7rT6EILvDNo= -github.com/nixberg/chacha-rng-go v0.1.0/go.mod h1:iPf1i6Vcwgoue86dblORobEXNCd1PFQiysFiImawfCM= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -1239,8 +1224,6 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/piprate/json-gold v0.4.1 h1:JYbYN36n6YcAYipKy3ttv3X2HDQPeqWqmwta35NPj04= -github.com/piprate/json-gold v0.4.1/go.mod h1:OK1z7UgtBZk06n2cDE2OSq1kffmjFFp5/2yhLLCz9UM= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1255,7 +1238,6 @@ github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:w github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= @@ -1637,7 +1619,6 @@ golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1875,7 +1856,6 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -2151,8 +2131,6 @@ google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106 h1:ErU+UA6wxadoU8nWrsy5MZUVBs75K17zUCsUCIfrXCE= -google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e h1:fNKDNuUyC4WH+inqDMpfXDdfvwfYILbsX+oskGZ8hxg= google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= @@ -2266,7 +2244,6 @@ nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.14/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= diff --git a/proto/credentials/v1/credentials.proto b/proto/credentials/v1/credentials.proto index 012bdef0..fe190a6e 100644 --- a/proto/credentials/v1/credentials.proto +++ b/proto/credentials/v1/credentials.proto @@ -5,10 +5,15 @@ option go_package = "github.com/elesto-dao/elesto/x/credentials"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; + + + message CredentialDefinition { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; // the credential definition did string id = 1; @@ -49,15 +54,15 @@ message PublicVerifiableCredential { option (gogoproto.goproto_getters) = false; // json-ld context - string context = 1 [(gogoproto.jsontag) = "@context,omitempty"]; + repeated string context = 1 [(gogoproto.jsontag) = "@context,omitempty"]; // the credential id string id = 2; - // the definition + // the credential types repeated string type = 3; - // the + // the DID of the issuer string issuer = 4; // the date-time of issuance @@ -67,8 +72,30 @@ message PublicVerifiableCredential { google.protobuf.Timestamp expirationDate = 6 [(gogoproto.stdtime) = true]; // the subject of the credential - google.protobuf.Any credentialSubject = 7; - + // the preferred way to handle the subject will be to use the Struct type + // but at the moment is not supported + // google.protobuf.Struct credentialSubject = 7; + bytes credentialSubject = 7; + + // One or more cryptographic proofs that can be used to detect tampering + // and verify the authorship of a credential or presentation. The specific + // method used for an embedded proof MUST be included using the type property. + Proof proof = 8; } + +// The Proof message represents a cryptographic proof that the +// credential has not been tampered with or changed without the issuersi +// knowledge. This can be used to verify the verifiable credential. +message Proof { + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; + + string type = 1; + string created = 2; + string proof_purpose = 3; + string verification_method = 4; + string signature = 5; +} + diff --git a/proto/credentials/v1/tx.proto b/proto/credentials/v1/tx.proto index f78632e3..11b7250c 100644 --- a/proto/credentials/v1/tx.proto +++ b/proto/credentials/v1/tx.proto @@ -41,6 +41,7 @@ message MsgIssuePublicVerifiableCredentialRequest { option (gogoproto.goproto_getters) = false; PublicVerifiableCredential credential = 1; - string signer = 2; + string credential_definition_did = 2; + string signer = 3; } message MsgIssuePublicVerifiableCredentialResponse {} \ No newline at end of file diff --git a/scripts/seeds/03_credential.json b/scripts/seeds/03_credential.json new file mode 100644 index 00000000..e83761b6 --- /dev/null +++ b/scripts/seeds/03_credential.json @@ -0,0 +1,15 @@ +{ + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://w3id.org/vc-revocation-list-2020/v1" + ], + "id": "https://example.com/credentials/status/3", + "type": ["VerifiableCredential", "RevocationList2020Credential"], + "issuer": "did:cosmos:elesto:example-credential-issuer", + "issuanceDate": "2020-04-05T14:27:40Z", + "credentialSubject": { + "id": "https://example.com/status/3#list", + "type": "RevocationList2020", + "encodedList": "H4sIAAAAAAAAA-3BMQEAAADCoPVPbQsvoAAAAAAAAAAAAAAAAP4GcwM92tQwAAA" + } +} diff --git a/scripts/seeds/03_credential_seeds.sh b/scripts/seeds/03_credential_seeds.sh index 3501258a..179e76d5 100755 --- a/scripts/seeds/03_credential_seeds.sh +++ b/scripts/seeds/03_credential_seeds.sh @@ -10,5 +10,20 @@ echo "Query credential" elestod query credentials credential-definition did:cosmos:elesto:revocation-list-2020 --output json | jq -echo "Issue public credential" +echo "Create issuer DDO" + +elestod tx did create-did example-credential-issuer \ + --from regulator \ + --chain-id elesto -y --broadcast-mode block + +echo "Sign and issue public credential" + +elestod tx credentials issue-public-credential revocation-list-2020 03_credential.json \ + --export 03_credential.signed.json \ + --from regulator \ + --chain-id elesto -y --broadcast-mode block + +echo "Query credential" + +elestod query credentials public-credential 'https://example.com/credentials/status/3' --output json | jq diff --git a/x/credentials/client/cli/query.go b/x/credentials/client/cli/query.go index 946ebecc..bea23321 100644 --- a/x/credentials/client/cli/query.go +++ b/x/credentials/client/cli/query.go @@ -96,9 +96,9 @@ func NewQueryRevocationListCmd() *cobra.Command { func NewQueryPublicCredentialCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "public-credential ID", + Use: "public-credential [ID]", Short: "fetch a public credential by id", - Example: "elestod credentials query public-credential example-credential-id", + Example: "elestod query credentials public-credential example-credential-id", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -116,7 +116,13 @@ func NewQueryPublicCredentialCmd() *cobra.Command { if err != nil { return err } - return clientCtx.PrintProto(result) + + wc, err := credentials.NewWrappedCredential(result.Credential) + if err != nil { + return err + } + + return clientCtx.PrintBytes(wc.GetBytes()) }, } flags.AddQueryFlagsToCmd(cmd) diff --git a/x/credentials/client/cli/tx.go b/x/credentials/client/cli/tx.go index 3e8b2589..d605e5b1 100644 --- a/x/credentials/client/cli/tx.go +++ b/x/credentials/client/cli/tx.go @@ -1,11 +1,16 @@ package cli import ( + "encoding/base64" "fmt" + "os" + "time" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/cobra" "github.com/elesto-dao/elesto/x/credentials" @@ -25,6 +30,7 @@ func GetTxCmd() *cobra.Command { // this line is used by starport scaffolding # 1 cmd.AddCommand( NewPublishCredentialDefinition(), + NewIssuePublicCredential(), ) return cmd @@ -33,6 +39,77 @@ func GetTxCmd() *cobra.Command { // NewPublishCredentialDefinition defines the command to publish credential definitions func NewPublishCredentialDefinition() *cobra.Command { + var credentialFileOut string + + cmd := &cobra.Command{ + Use: "issue-public-credential credential-definition-id credential_file", + Short: "issue a public, on-chain, credential", + Example: "elestod tx credentials issue-public-credential example-definition-id credential.json", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + + cID, credentialFile := args[0], args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + // did + definitionDID := did.NewChainDID(clientCtx.ChainID, cID) + // verification + signer := clientCtx.GetFromAddress() + + // initialize the definition + wc, err := credentials.NewWrappedPublicCredentialFromFile(credentialFile) + if err != nil { + println("error building credential definition", err) + return err + } + // get the issuer did + vmID := wc.GetIssuerDID().NewVerificationMethodID(signer.String()) + if err = sign(wc, clientCtx.Keyring, signer, vmID); err != nil { + println("error signing the credential:", err) + return err + } + // write to the output file + if !credentials.IsEmpty(credentialFileOut) { + if err = os.WriteFile(credentialFileOut, wc.GetBytes(), 0600); err != nil { + fmt.Printf("error writing the credential to %v: %v", credentialFileOut, err) + return err + } + } + + if err = sign(wc, clientCtx.Keyring, signer, vmID); err != nil { + println("error signing the credential:", err) + return err + } + + pvc, err := wc.GetCredential() + if err != nil { + println("error extracting the credential:", err) + return err + } + + // create the message + msg := credentials.NewMsgIssuePublicVerifiableCredentialRequest( + pvc, + definitionDID, + signer, + ) + // execute + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + // add flags + cmd.Flags().StringVar(&credentialFileOut, "export", "", "export the signed credential to a json file") + + flags.AddTxFlagsToCmd(cmd) + return cmd +} + +// NewIssuePublicCredential defines the command to publish credential definitions +func NewIssuePublicCredential() *cobra.Command { + var ( isPublic bool inactive bool @@ -89,3 +166,32 @@ func NewPublishCredentialDefinition() *cobra.Command { flags.AddTxFlagsToCmd(cmd) return cmd } + +// Sign signs a credential with a provided private key +func sign( + wc *credentials.WrappedCredential, + keyring keyring.Keyring, + address sdk.Address, + verificationMethodID string, +) error { + tm := time.Now() + // reset the proof + wc.Proof = nil + // TODO: this could be expensive review this signing method + // TODO: we can hash this an make this less expensive + signature, pubKey, err := keyring.SignByAddress(address, wc.GetBytes()) + if err != nil { + return err + } + + p := credentials.NewProof( + pubKey.Type(), + tm.Format(time.RFC3339), + // TODO: define proof purposes + did.AssertionMethod, + verificationMethodID, + base64.StdEncoding.EncodeToString(signature), + ) + wc.Proof = &p + return nil +} diff --git a/x/credentials/credentials.go b/x/credentials/credentials.go index e0750804..94fcaa57 100644 --- a/x/credentials/credentials.go +++ b/x/credentials/credentials.go @@ -1,7 +1,12 @@ package credentials import ( + "encoding/base64" + "encoding/json" "fmt" + "os" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/elesto-dao/elesto/x/did" ) @@ -34,3 +39,113 @@ func NewCredentialDefinitionFromFile(did, publisherDID did.DID, return def, nil } + +// WrappedCredential wraps a PublicVerifiableCredential, this is a workaround +// to deal with the variable content of the credential subject +type WrappedCredential struct { + *PublicVerifiableCredential + CredentialSubject map[string]interface{} `json:"credentialSubject"` +} + +// NewWrappedCredential wrap a PublicVerifiableCredential to go around serialization +func NewWrappedCredential(pvc *PublicVerifiableCredential) (wc *WrappedCredential, err error) { + wc = &WrappedCredential{ + PublicVerifiableCredential: pvc, + CredentialSubject: map[string]interface{}{}, + } + err = json.Unmarshal(pvc.CredentialSubject, &wc.CredentialSubject) + return +} + +func NewWrappedPublicCredentialFromFile(credentialFile string) (wc *WrappedCredential, err error) { + wc = &WrappedCredential{} + data, err := os.ReadFile(credentialFile) + if err != nil { + return nil, err + } + if err = json.Unmarshal(data, wc); err != nil { + return + } + return +} + +func (wc *WrappedCredential) GetCredential() (*PublicVerifiableCredential, error) { + sbj, err := json.Marshal(wc.CredentialSubject) + if err != nil { + return nil, err + } + wc.PublicVerifiableCredential.CredentialSubject = sbj + return wc.PublicVerifiableCredential, nil +} + +func (wc *WrappedCredential) GetBytes() []byte { + dAtA, err := json.Marshal(wc) + if err != nil { + panic(err) //[(gogoproto.sizer) = true, (gogoproto.marshaler) = true, (gogoproto.unmarshaler) = true]; + } + return dAtA +} + +func (wc *WrappedCredential) GetSubjectID() (s string, hasSubject bool) { + v, hasSubject := wc.CredentialSubject["id"] + if !hasSubject || IsEmpty(v.(string)) { + return + } + id, hasSubject := v.(string) + if !hasSubject { + return + } + return id, IsEmpty(id) +} + +func (pvc PublicVerifiableCredential) GetIssuerDID() did.DID { + return did.DID(pvc.Issuer) +} + +// GetBytes is a helper for serializing +func (pvc PublicVerifiableCredential) GetBytes() []byte { + dAtA, err := pvc.Marshal() + if err != nil { + panic(err) //[(gogoproto.sizer) = true, (gogoproto.marshaler) = true, (gogoproto.unmarshaler) = true]; + } + return dAtA +} + +// Validate validates a verifiable credential against a provided public key +func (wc WrappedCredential) Validate( + pk cryptotypes.PubKey, +) bool { + s, err := base64.StdEncoding.DecodeString(wc.Proof.Signature) + if err != nil { + panic(err) + } + + // reset the proof + wc.Proof = nil + + // TODO: this is an expensive operation, could lead to DDOS + // TODO: we can hash this and make this less expensive + isCorrectPubKey := pk.VerifySignature( + wc.GetBytes(), + s, + ) + + return isCorrectPubKey +} + +// NewProof create a new proof for a verifiable credential +func NewProof( + proofType string, + created string, + proofPurpose string, + verificationMethod string, + signature string, +) Proof { + return Proof{ + Type: proofType, + Created: created, + ProofPurpose: proofPurpose, + VerificationMethod: verificationMethod, + Signature: signature, + } +} diff --git a/x/credentials/credentials.pb.go b/x/credentials/credentials.pb.go index bf57430b..300d286f 100644 --- a/x/credentials/credentials.pb.go +++ b/x/credentials/credentials.pb.go @@ -4,10 +4,11 @@ package credentials import ( + bytes "bytes" fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "google.golang.org/protobuf/types/known/timestamppb" io "io" @@ -84,86 +85,30 @@ func (m *CredentialDefinition) XXX_DiscardUnknown() { var xxx_messageInfo_CredentialDefinition proto.InternalMessageInfo -func (m *CredentialDefinition) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *CredentialDefinition) GetPublisherId() string { - if m != nil { - return m.PublisherId - } - return "" -} - -func (m *CredentialDefinition) GetSchema() string { - if m != nil { - return m.Schema - } - return "" -} - -func (m *CredentialDefinition) GetVocab() string { - if m != nil { - return m.Vocab - } - return "" -} - -func (m *CredentialDefinition) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *CredentialDefinition) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *CredentialDefinition) GetIsPublic() bool { - if m != nil { - return m.IsPublic - } - return false -} - -func (m *CredentialDefinition) GetSupersededBy() string { - if m != nil { - return m.SupersededBy - } - return "" -} - -func (m *CredentialDefinition) GetIsActive() bool { - if m != nil { - return m.IsActive - } - return false -} - // DidMetadata defines metadata associated to a did document such as // the status of the DID document type PublicVerifiableCredential struct { // json-ld context - Context string `protobuf:"bytes,1,opt,name=context,proto3" json:"@context,omitempty"` + Context []string `protobuf:"bytes,1,rep,name=context,proto3" json:"@context,omitempty"` // the credential id Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - // the definition + // the credential types Type []string `protobuf:"bytes,3,rep,name=type,proto3" json:"type,omitempty"` - // the + // the DID of the issuer Issuer string `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"` // the date-time of issuance IssuanceDate *time.Time `protobuf:"bytes,5,opt,name=issuanceDate,proto3,stdtime" json:"issuanceDate,omitempty"` // the date-time of expiration ExpirationDate *time.Time `protobuf:"bytes,6,opt,name=expirationDate,proto3,stdtime" json:"expirationDate,omitempty"` // the subject of the credential - CredentialSubject *types.Any `protobuf:"bytes,7,opt,name=credentialSubject,proto3" json:"credentialSubject,omitempty"` + // the preferred way to handle the subject will be to use the Struct type + // but at the moment is not supported + // google.protobuf.Struct credentialSubject = 7; + CredentialSubject []byte `protobuf:"bytes,7,opt,name=credentialSubject,proto3" json:"credentialSubject,omitempty"` + // One or more cryptographic proofs that can be used to detect tampering + // and verify the authorship of a credential or presentation. The specific + // method used for an embedded proof MUST be included using the type property. + Proof *Proof `protobuf:"bytes,8,opt,name=proof,proto3" json:"proof,omitempty"` } func (m *PublicVerifiableCredential) Reset() { *m = PublicVerifiableCredential{} } @@ -199,48 +144,148 @@ func (m *PublicVerifiableCredential) XXX_DiscardUnknown() { var xxx_messageInfo_PublicVerifiableCredential proto.InternalMessageInfo +// The Proof message represents a cryptographic proof that the +// credential has not been tampered with or changed without the issuersi +// knowledge. This can be used to verify the verifiable credential. +type Proof struct { + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Created string `protobuf:"bytes,2,opt,name=created,proto3" json:"created,omitempty"` + ProofPurpose string `protobuf:"bytes,3,opt,name=proof_purpose,json=proofPurpose,proto3" json:"proof_purpose,omitempty"` + VerificationMethod string `protobuf:"bytes,4,opt,name=verification_method,json=verificationMethod,proto3" json:"verification_method,omitempty"` + Signature string `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *Proof) Reset() { *m = Proof{} } +func (m *Proof) String() string { return proto.CompactTextString(m) } +func (*Proof) ProtoMessage() {} +func (*Proof) Descriptor() ([]byte, []int) { + return fileDescriptor_bc5d85b2b80c68f8, []int{2} +} +func (m *Proof) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Proof.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Proof) XXX_Merge(src proto.Message) { + xxx_messageInfo_Proof.Merge(m, src) +} +func (m *Proof) XXX_Size() int { + return m.Size() +} +func (m *Proof) XXX_DiscardUnknown() { + xxx_messageInfo_Proof.DiscardUnknown(m) +} + +var xxx_messageInfo_Proof proto.InternalMessageInfo + func init() { proto.RegisterType((*CredentialDefinition)(nil), "elestodao.elesto.credentials.v1.CredentialDefinition") proto.RegisterType((*PublicVerifiableCredential)(nil), "elestodao.elesto.credentials.v1.PublicVerifiableCredential") + proto.RegisterType((*Proof)(nil), "elestodao.elesto.credentials.v1.Proof") } func init() { proto.RegisterFile("credentials/v1/credentials.proto", fileDescriptor_bc5d85b2b80c68f8) } var fileDescriptor_bc5d85b2b80c68f8 = []byte{ - // 494 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x31, 0x6f, 0xdb, 0x3c, - 0x10, 0xb5, 0x64, 0xc7, 0xf1, 0x47, 0x1b, 0x01, 0x3e, 0xc2, 0x08, 0x58, 0x0f, 0x92, 0xe1, 0x29, - 0x28, 0x5a, 0xa9, 0x49, 0xb7, 0x4e, 0x8d, 0xeb, 0xa1, 0xdd, 0x0a, 0xb5, 0xe8, 0xd0, 0x8d, 0xa2, - 0xce, 0x32, 0x0b, 0x49, 0x14, 0x44, 0xca, 0xb0, 0xfe, 0x41, 0xc6, 0xfc, 0x84, 0xfc, 0x9c, 0x8e, - 0x19, 0x3b, 0xb5, 0x85, 0xbd, 0x04, 0xfd, 0x15, 0x85, 0x48, 0xd9, 0x51, 0x92, 0xa5, 0xdb, 0xbd, - 0x77, 0xef, 0xdd, 0xd9, 0xef, 0x44, 0x34, 0x65, 0x05, 0x44, 0x90, 0x29, 0x4e, 0x13, 0xe9, 0xaf, - 0xcf, 0xfd, 0x16, 0xf4, 0xf2, 0x42, 0x28, 0x81, 0x5d, 0x48, 0x40, 0x2a, 0x11, 0x51, 0xe1, 0x99, - 0xca, 0x6b, 0x6b, 0xd6, 0xe7, 0x93, 0x71, 0x2c, 0x62, 0xa1, 0xb5, 0x7e, 0x5d, 0x19, 0xdb, 0xc4, - 0x8d, 0x85, 0x88, 0x13, 0xf0, 0x35, 0x0a, 0xcb, 0xa5, 0xaf, 0x78, 0x0a, 0x52, 0xd1, 0x34, 0x6f, - 0x04, 0xcf, 0x1e, 0x0b, 0x68, 0x56, 0x99, 0xd6, 0xec, 0xca, 0x46, 0xe3, 0x77, 0x87, 0x25, 0x0b, - 0x58, 0xf2, 0x8c, 0x2b, 0x2e, 0x32, 0x7c, 0x82, 0x6c, 0x1e, 0x11, 0x6b, 0x6a, 0x9d, 0xfd, 0x17, - 0xd8, 0x3c, 0xc2, 0x53, 0x34, 0xcc, 0xcb, 0x30, 0xe1, 0x72, 0x05, 0xc5, 0x87, 0x88, 0xd8, 0xba, - 0xd1, 0xa6, 0xf0, 0x29, 0xea, 0x4b, 0xb6, 0x82, 0x94, 0x92, 0xae, 0x6e, 0x36, 0x08, 0x8f, 0xd1, - 0xd1, 0x5a, 0x30, 0x1a, 0x92, 0x9e, 0xa6, 0x0d, 0xc0, 0x18, 0xf5, 0x32, 0x9a, 0x02, 0x39, 0xd2, - 0xa4, 0xae, 0xeb, 0x1d, 0x11, 0x48, 0x56, 0xf0, 0xbc, 0xfe, 0x09, 0xa4, 0x6f, 0x76, 0xb4, 0x28, - 0x3c, 0x41, 0x03, 0x2e, 0x3f, 0xd6, 0x4b, 0x19, 0x39, 0x9e, 0x5a, 0x67, 0x83, 0xe0, 0x80, 0xf1, - 0x0c, 0x8d, 0x64, 0x99, 0x43, 0x21, 0x21, 0x82, 0x68, 0x5e, 0x91, 0xa1, 0xb6, 0x3f, 0xe0, 0x8c, - 0xff, 0x92, 0x29, 0xbe, 0x06, 0x32, 0xda, 0xfb, 0x0d, 0x9e, 0xdd, 0xd9, 0x68, 0x62, 0x46, 0x7d, - 0x81, 0x82, 0x2f, 0x39, 0x0d, 0x13, 0xb8, 0x8f, 0x06, 0xbf, 0x42, 0xc7, 0x4c, 0x64, 0x0a, 0x36, - 0xca, 0xa4, 0x32, 0x3f, 0xfd, 0xf3, 0xd3, 0xc5, 0x6f, 0x1b, 0xee, 0x85, 0x48, 0xb9, 0x82, 0x34, - 0x57, 0x55, 0xb0, 0x97, 0x35, 0x11, 0xda, 0x87, 0x08, 0x31, 0xea, 0xa9, 0x2a, 0x07, 0xd2, 0x9d, - 0x76, 0xeb, 0xbf, 0x5c, 0xd7, 0x75, 0x68, 0x5c, 0xca, 0x12, 0x8a, 0x26, 0x9d, 0x06, 0xe1, 0x05, - 0x1a, 0xd5, 0x15, 0xcd, 0x18, 0x2c, 0xa8, 0x32, 0x31, 0x0d, 0x2f, 0x26, 0x9e, 0xb9, 0xa4, 0xb7, - 0xbf, 0xa4, 0xf7, 0x79, 0x7f, 0xea, 0x79, 0xef, 0xfa, 0x97, 0x6b, 0x05, 0x0f, 0x5c, 0xf8, 0x3d, - 0x3a, 0x81, 0x4d, 0xce, 0x0b, 0x5a, 0x87, 0xa7, 0xe7, 0xf4, 0xff, 0x71, 0xce, 0x23, 0x1f, 0x9e, - 0xa3, 0xff, 0xef, 0xbf, 0xc5, 0x4f, 0x65, 0xf8, 0x0d, 0x98, 0xd2, 0x17, 0x18, 0x5e, 0x8c, 0x9f, - 0x0c, 0xbb, 0xcc, 0xaa, 0xe0, 0xa9, 0xfc, 0xcd, 0xe0, 0xea, 0xc6, 0xed, 0xdc, 0xdd, 0xb8, 0xd6, - 0x7c, 0xf1, 0x7d, 0xeb, 0x58, 0xb7, 0x5b, 0xc7, 0xfa, 0xbd, 0x75, 0xac, 0xeb, 0x9d, 0xd3, 0xb9, - 0xdd, 0x39, 0x9d, 0x1f, 0x3b, 0xa7, 0xf3, 0xf5, 0x79, 0xcc, 0xd5, 0xaa, 0x0c, 0x3d, 0x26, 0x52, - 0xdf, 0xbc, 0x81, 0x97, 0x11, 0x15, 0x4d, 0xe9, 0x6f, 0xda, 0x8f, 0x26, 0xec, 0xeb, 0x85, 0xaf, - 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x4e, 0x61, 0x4a, 0x59, 0x03, 0x00, 0x00, + // 596 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0x8d, 0xf3, 0xd7, 0x74, 0x9a, 0xaf, 0xd2, 0x37, 0x54, 0xd5, 0x28, 0xaa, 0xec, 0xa8, 0x48, + 0xa8, 0x42, 0xc5, 0xa6, 0xb0, 0x43, 0x2c, 0x20, 0x64, 0x01, 0x0b, 0xa4, 0xca, 0x20, 0x16, 0x6c, + 0xaa, 0xf1, 0xf8, 0xc6, 0x19, 0x14, 0x7b, 0xac, 0x99, 0x71, 0xd4, 0xbe, 0x01, 0xcb, 0x8a, 0x27, + 0xe8, 0x3b, 0xf0, 0x12, 0x2c, 0xbb, 0x64, 0x05, 0xa8, 0xdd, 0x20, 0x9e, 0x02, 0x79, 0xc6, 0x4e, + 0xdc, 0xb2, 0x80, 0xdd, 0x3d, 0xe7, 0xde, 0x33, 0xd7, 0x39, 0xe7, 0x2a, 0x68, 0xcc, 0x24, 0xc4, + 0x90, 0x69, 0x4e, 0x17, 0x2a, 0x58, 0x1e, 0x05, 0x0d, 0xe8, 0xe7, 0x52, 0x68, 0x81, 0x3d, 0x58, + 0x80, 0xd2, 0x22, 0xa6, 0xc2, 0xb7, 0x95, 0xdf, 0x9c, 0x59, 0x1e, 0x8d, 0x76, 0x12, 0x91, 0x08, + 0x33, 0x1b, 0x94, 0x95, 0x95, 0x8d, 0xbc, 0x44, 0x88, 0x64, 0x01, 0x81, 0x41, 0x51, 0x31, 0x0b, + 0x34, 0x4f, 0x41, 0x69, 0x9a, 0xe6, 0xd5, 0xc0, 0xde, 0xed, 0x01, 0xa5, 0x65, 0xc1, 0xb4, 0xed, + 0xee, 0x7f, 0x6a, 0xa3, 0x9d, 0x17, 0xab, 0x3d, 0x53, 0x98, 0xf1, 0x8c, 0x6b, 0x2e, 0x32, 0xbc, + 0x8d, 0xda, 0x3c, 0x26, 0xce, 0xd8, 0x39, 0xd8, 0x0c, 0xdb, 0x3c, 0xc6, 0x63, 0xb4, 0x95, 0x17, + 0xd1, 0x82, 0xab, 0x39, 0xc8, 0x57, 0x31, 0x69, 0x9b, 0x46, 0x93, 0xc2, 0xbb, 0xa8, 0xaf, 0xd8, + 0x1c, 0x52, 0x4a, 0x3a, 0xa6, 0x59, 0x21, 0xbc, 0x83, 0x7a, 0x4b, 0xc1, 0x68, 0x44, 0xba, 0x86, + 0xb6, 0x00, 0x63, 0xd4, 0xcd, 0x68, 0x0a, 0xa4, 0x67, 0x48, 0x53, 0x97, 0x3b, 0x62, 0x50, 0x4c, + 0xf2, 0xbc, 0xfc, 0x04, 0xd2, 0xb7, 0x3b, 0x1a, 0x14, 0x1e, 0xa1, 0x01, 0x57, 0xc7, 0xe5, 0x52, + 0x46, 0x36, 0xc6, 0xce, 0xc1, 0x20, 0x5c, 0x61, 0xbc, 0x8f, 0x86, 0xaa, 0xc8, 0x41, 0x2a, 0x88, + 0x21, 0x9e, 0x9c, 0x91, 0x2d, 0x23, 0xbf, 0xc1, 0x59, 0xfd, 0x73, 0xa6, 0xf9, 0x12, 0xc8, 0xb0, + 0xd6, 0x5b, 0xfc, 0x64, 0xf0, 0xf1, 0xc2, 0x6b, 0xfd, 0xbc, 0xf0, 0x9c, 0xfd, 0xf3, 0x0e, 0x1a, + 0xd9, 0x47, 0xdf, 0x81, 0xe4, 0x33, 0x4e, 0xa3, 0x05, 0xac, 0x4d, 0xc2, 0x0f, 0xd1, 0x06, 0x13, + 0x99, 0x86, 0x53, 0x4d, 0x9c, 0x71, 0xe7, 0x60, 0x73, 0xb2, 0xfb, 0xeb, 0x9b, 0x87, 0x9f, 0x55, + 0xdc, 0xa1, 0x48, 0xb9, 0x86, 0x34, 0xd7, 0x67, 0x61, 0x3d, 0x56, 0x99, 0xd9, 0x5e, 0x99, 0x89, + 0x51, 0x57, 0x9f, 0xe5, 0x40, 0x3a, 0xa5, 0x3c, 0x34, 0x75, 0x69, 0x1f, 0x57, 0xaa, 0x00, 0x59, + 0xf9, 0x54, 0x21, 0x3c, 0x45, 0xc3, 0xb2, 0xa2, 0x19, 0x83, 0x29, 0xd5, 0xd6, 0xb0, 0xad, 0x47, + 0x23, 0xdf, 0xc6, 0xea, 0xd7, 0xb1, 0xfa, 0x6f, 0xeb, 0xdc, 0x27, 0xdd, 0xf3, 0xef, 0x9e, 0x13, + 0xde, 0x50, 0xe1, 0x97, 0x68, 0x1b, 0x4e, 0x73, 0x2e, 0x69, 0x69, 0xa3, 0x79, 0xa7, 0xff, 0x8f, + 0xef, 0xdc, 0xd2, 0xe1, 0x43, 0xf4, 0xff, 0xfa, 0x30, 0xdf, 0x14, 0xd1, 0x07, 0x60, 0xda, 0x64, + 0x31, 0x0c, 0xff, 0x6c, 0xe0, 0xa7, 0xa8, 0x97, 0x4b, 0x21, 0x66, 0x64, 0x60, 0xd6, 0xdd, 0xf3, + 0xff, 0x72, 0xe5, 0xfe, 0x71, 0x39, 0x1d, 0x5a, 0x51, 0x23, 0x92, 0xcf, 0x0e, 0xea, 0x99, 0xd6, + 0xca, 0x3b, 0x7b, 0x9a, 0xd6, 0x3b, 0x82, 0x36, 0x98, 0x04, 0xaa, 0xa1, 0x36, 0xb9, 0x86, 0xf8, + 0x2e, 0xfa, 0xcf, 0x3c, 0x75, 0x92, 0x17, 0x32, 0x17, 0x0a, 0xaa, 0xdb, 0x1c, 0x1a, 0xf2, 0xd8, + 0x72, 0x38, 0x40, 0x77, 0x96, 0x26, 0x68, 0x66, 0x7e, 0xe6, 0x49, 0x0a, 0x7a, 0x2e, 0xe2, 0x2a, + 0x07, 0xdc, 0x6c, 0xbd, 0x36, 0x1d, 0xbc, 0x87, 0x36, 0x15, 0x4f, 0x32, 0xaa, 0x0b, 0x59, 0x5f, + 0xf0, 0x9a, 0x58, 0x7f, 0xf5, 0x64, 0xfa, 0xe5, 0xca, 0x75, 0x2e, 0xaf, 0x5c, 0xe7, 0xc7, 0x95, + 0xeb, 0x9c, 0x5f, 0xbb, 0xad, 0xcb, 0x6b, 0xb7, 0xf5, 0xf5, 0xda, 0x6d, 0xbd, 0xbf, 0x9f, 0x70, + 0x3d, 0x2f, 0x22, 0x9f, 0x89, 0x34, 0xb0, 0x46, 0x3c, 0x88, 0xa9, 0xa8, 0xca, 0xe0, 0xb4, 0xf9, + 0xff, 0x10, 0xf5, 0x4d, 0x36, 0x8f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x50, 0x7b, 0x38, + 0x44, 0x04, 0x00, 0x00, } +func (this *CredentialDefinition) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CredentialDefinition) + if !ok { + that2, ok := that.(CredentialDefinition) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Id != that1.Id { + return false + } + if this.PublisherId != that1.PublisherId { + return false + } + if this.Schema != that1.Schema { + return false + } + if this.Vocab != that1.Vocab { + return false + } + if this.Name != that1.Name { + return false + } + if this.Description != that1.Description { + return false + } + if this.IsPublic != that1.IsPublic { + return false + } + if this.SupersededBy != that1.SupersededBy { + return false + } + if this.IsActive != that1.IsActive { + return false + } + return true +} func (this *PublicVerifiableCredential) Equal(that interface{}) bool { if that == nil { return this == nil @@ -260,9 +305,14 @@ func (this *PublicVerifiableCredential) Equal(that interface{}) bool { } else if this == nil { return false } - if this.Context != that1.Context { + if len(this.Context) != len(that1.Context) { return false } + for i := range this.Context { + if this.Context[i] != that1.Context[i] { + return false + } + } if this.Id != that1.Id { return false } @@ -291,7 +341,46 @@ func (this *PublicVerifiableCredential) Equal(that interface{}) bool { } else if !this.ExpirationDate.Equal(*that1.ExpirationDate) { return false } - if !this.CredentialSubject.Equal(that1.CredentialSubject) { + if !bytes.Equal(this.CredentialSubject, that1.CredentialSubject) { + return false + } + if !this.Proof.Equal(that1.Proof) { + return false + } + return true +} +func (this *Proof) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Proof) + if !ok { + that2, ok := that.(Proof) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Type != that1.Type { + return false + } + if this.Created != that1.Created { + return false + } + if this.ProofPurpose != that1.ProofPurpose { + return false + } + if this.VerificationMethod != that1.VerificationMethod { + return false + } + if this.Signature != that1.Signature { return false } return true @@ -408,9 +497,9 @@ func (m *PublicVerifiableCredential) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if m.CredentialSubject != nil { + if m.Proof != nil { { - size, err := m.CredentialSubject.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Proof.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -418,6 +507,13 @@ func (m *PublicVerifiableCredential) MarshalToSizedBuffer(dAtA []byte) (int, err i = encodeVarintCredentials(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x42 + } + if len(m.CredentialSubject) > 0 { + i -= len(m.CredentialSubject) + copy(dAtA[i:], m.CredentialSubject) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.CredentialSubject))) + i-- dAtA[i] = 0x3a } if m.ExpirationDate != nil { @@ -464,9 +560,69 @@ func (m *PublicVerifiableCredential) MarshalToSizedBuffer(dAtA []byte) (int, err dAtA[i] = 0x12 } if len(m.Context) > 0 { - i -= len(m.Context) - copy(dAtA[i:], m.Context) - i = encodeVarintCredentials(dAtA, i, uint64(len(m.Context))) + for iNdEx := len(m.Context) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Context[iNdEx]) + copy(dAtA[i:], m.Context[iNdEx]) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.Context[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Proof) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Proof) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x2a + } + if len(m.VerificationMethod) > 0 { + i -= len(m.VerificationMethod) + copy(dAtA[i:], m.VerificationMethod) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.VerificationMethod))) + i-- + dAtA[i] = 0x22 + } + if len(m.ProofPurpose) > 0 { + i -= len(m.ProofPurpose) + copy(dAtA[i:], m.ProofPurpose) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.ProofPurpose))) + i-- + dAtA[i] = 0x1a + } + if len(m.Created) > 0 { + i -= len(m.Created) + copy(dAtA[i:], m.Created) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.Created))) + i-- + dAtA[i] = 0x12 + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintCredentials(dAtA, i, uint64(len(m.Type))) i-- dAtA[i] = 0xa } @@ -533,9 +689,11 @@ func (m *PublicVerifiableCredential) Size() (n int) { } var l int _ = l - l = len(m.Context) - if l > 0 { - n += 1 + l + sovCredentials(uint64(l)) + if len(m.Context) > 0 { + for _, s := range m.Context { + l = len(s) + n += 1 + l + sovCredentials(uint64(l)) + } } l = len(m.Id) if l > 0 { @@ -559,8 +717,41 @@ func (m *PublicVerifiableCredential) Size() (n int) { l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.ExpirationDate) n += 1 + l + sovCredentials(uint64(l)) } - if m.CredentialSubject != nil { - l = m.CredentialSubject.Size() + l = len(m.CredentialSubject) + if l > 0 { + n += 1 + l + sovCredentials(uint64(l)) + } + if m.Proof != nil { + l = m.Proof.Size() + n += 1 + l + sovCredentials(uint64(l)) + } + return n +} + +func (m *Proof) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Type) + if l > 0 { + n += 1 + l + sovCredentials(uint64(l)) + } + l = len(m.Created) + if l > 0 { + n += 1 + l + sovCredentials(uint64(l)) + } + l = len(m.ProofPurpose) + if l > 0 { + n += 1 + l + sovCredentials(uint64(l)) + } + l = len(m.VerificationMethod) + if l > 0 { + n += 1 + l + sovCredentials(uint64(l)) + } + l = len(m.Signature) + if l > 0 { n += 1 + l + sovCredentials(uint64(l)) } return n @@ -945,7 +1136,7 @@ func (m *PublicVerifiableCredential) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Context = string(dAtA[iNdEx:postIndex]) + m.Context = append(m.Context, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 2 { @@ -1119,6 +1310,40 @@ func (m *PublicVerifiableCredential) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CredentialSubject", wireType) } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CredentialSubject = append(m.CredentialSubject[:0], dAtA[iNdEx:postIndex]...) + if m.CredentialSubject == nil { + m.CredentialSubject = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { @@ -1144,12 +1369,222 @@ func (m *PublicVerifiableCredential) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.CredentialSubject == nil { - m.CredentialSubject = &types.Any{} + if m.Proof == nil { + m.Proof = &Proof{} + } + if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if err := m.CredentialSubject.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCredentials(dAtA[iNdEx:]) + if err != nil { return err } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCredentials + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Proof) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Proof: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Proof: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Created", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Created = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofPurpose", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProofPurpose = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VerificationMethod", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VerificationMethod = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCredentials + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCredentials + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCredentials + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/credentials/errors.go b/x/credentials/errors.go index 1c15c351..2071ddf6 100644 --- a/x/credentials/errors.go +++ b/x/credentials/errors.go @@ -9,6 +9,17 @@ import ( // x/did module sentinel errors // TODO update error messages var ( - ErrCredentialDefinitionFound = sdkerrors.Register(ModuleName, 2100, "credential definition found") - ErrCredentialDefinitionNotFound = sdkerrors.Register(ModuleName, 2101, "credential definition not found") + ErrCredentialDefinitionFound = sdkerrors.Register(ModuleName, 2100, "credential definition found") + ErrCredentialDefinitionNotFound = sdkerrors.Register(ModuleName, 2101, "credential definition not found") + ErrCredentialDefinitionCorrupted = sdkerrors.Register(ModuleName, 2109, "credential definition corrupted") + + ErrVerifiableCredentialNotFound = sdkerrors.Register(ModuleName, 2102, "vc not found") + ErrVerifiableCredentialFound = sdkerrors.Register(ModuleName, 2103, "vc found") + ErrDidDocumentDoesNotExist = sdkerrors.Register(ModuleName, 2104, "did does not exist in the store") + ErrVerifiableCredentialIssuer = sdkerrors.Register(ModuleName, 2105, "provided verifiable credential and did public key do not match") + ErrMessageSigner = sdkerrors.Register(ModuleName, 2106, "message signer does not match provided did") + ErrCredentialIsNotPublic = sdkerrors.Register(ModuleName, 2107, "credential cannot be issued on-chain") + ErrCredentialIsNotActive = sdkerrors.Register(ModuleName, 2108, "issuance of this credential is suspended") + ErrInvalidCredential = sdkerrors.Register(ModuleName, 2110, "credential is invalid") + ErrCredentialSchema = sdkerrors.Register(ModuleName, 2130, "the credential doesn't match the definition schema") ) diff --git a/x/credentials/expected_keepers.go b/x/credentials/expected_keepers.go index a980add9..d058a078 100644 --- a/x/credentials/expected_keepers.go +++ b/x/credentials/expected_keepers.go @@ -1,6 +1,7 @@ package credentials import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -10,6 +11,7 @@ import ( // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error) } // BankKeeper defines the expected interface needed to retrieve account balances. diff --git a/x/credentials/helpers.go b/x/credentials/helpers.go index cf4b79dc..e6f8ba43 100644 --- a/x/credentials/helpers.go +++ b/x/credentials/helpers.go @@ -6,6 +6,9 @@ import ( "os" "sort" "strings" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/gogo/protobuf/proto" ) // IsEmpty checks if a string is empty, it trims spaces before checking for empty string @@ -13,7 +16,7 @@ func IsEmpty(v string) bool { return strings.TrimSpace(v) == "" } -// CompactJSON read a json from a file and return a compact version of it +// CompactJSON read a JSON from a file and return a compact version of it func CompactJSON(filePath string) (compact string, err error) { data, err := os.ReadFile(filePath) if err != nil { @@ -27,6 +30,15 @@ func CompactJSON(filePath string) (compact string, err error) { return } +// LoadProtoJSON read JSON data from a file and un-marshall it to a struct +func LoadProtoJSON(cdc codec.Codec, filePath string, to proto.Message) (err error) { + data, err := os.ReadFile(filePath) + if err != nil { + return + } + return cdc.UnmarshalJSON(data, to) +} + // StringUnion perform union, distinct amd sort operation between two slices // duplicated element in list are removed func StringUnion(a, b []string) []string { diff --git a/x/credentials/keeper/credentials.go b/x/credentials/keeper/credentials.go index e94f280f..c6757251 100644 --- a/x/credentials/keeper/credentials.go +++ b/x/credentials/keeper/credentials.go @@ -23,6 +23,22 @@ func (k Keeper) GetCredentialDefinition(ctx sdk.Context, key string) (credential return val.(credentials.CredentialDefinition), found } +// SetPublicCredential persist a public verifiable credential to the store. The credential ID is used as key +func (k Keeper) SetPublicCredential(ctx sdk.Context, pc *credentials.PublicVerifiableCredential) { + k.Set(ctx, []byte(pc.Id), credentials.PublicCredentialKey, pc, k.cdc.MustMarshal) +} + +// GetPublicCredential retrieve a public verifiable credential by its key. +// The boolean return will be false if the credential is not found +func (k Keeper) GetPublicCredential(ctx sdk.Context, key string) (credentials.PublicVerifiableCredential, bool) { + val, found := k.Get(ctx, []byte(key), credentials.PublicCredentialKey, func(value []byte) (interface{}, bool) { + var data credentials.PublicVerifiableCredential + ok := k.Unmarshal(value, &data) + return data, ok + }) + return val.(credentials.PublicVerifiableCredential), found +} + // Unmarshal from byte slice to a struct, return false in case of errors func (k Keeper) Unmarshal(data []byte, val codec.ProtoMarshaler) bool { if len(data) == 0 { diff --git a/x/credentials/keeper/grpc_query.go b/x/credentials/keeper/grpc_query.go index 45dc5c4d..9da51ec9 100644 --- a/x/credentials/keeper/grpc_query.go +++ b/x/credentials/keeper/grpc_query.go @@ -53,7 +53,16 @@ func (k Keeper) PublicCredential( c context.Context, req *credentials.QueryPublicCredentialRequest, ) (*credentials.QueryPublicCredentialResponse, error) { - return nil, fmt.Errorf("not implemented") + + ctx := sdk.UnwrapSDKContext(c) + + pc, found := k.GetPublicCredential(ctx, req.Id) + if !found { + return nil, status.Error(codes.NotFound, "credential definition not found") + } + + return &credentials.QueryPublicCredentialResponse{Credential: &pc}, nil + } func (k Keeper) PublicCredentialsByHolder( diff --git a/x/credentials/keeper/keeper.go b/x/credentials/keeper/keeper.go index 0e047113..68e23f0b 100644 --- a/x/credentials/keeper/keeper.go +++ b/x/credentials/keeper/keeper.go @@ -20,13 +20,17 @@ type Keeper struct { cdc codec.Codec storeKey sdk.StoreKey memKey sdk.StoreKey + did credentials.DidKeeper + account credentials.AccountKeeper } -func NewKeeper(cdc codec.Codec, storeKey, memKey sdk.StoreKey) *Keeper { +func NewKeeper(cdc codec.Codec, storeKey, memKey sdk.StoreKey, did credentials.DidKeeper, account credentials.AccountKeeper) *Keeper { return &Keeper{ cdc: cdc, storeKey: storeKey, memKey: memKey, + did: did, + account: account, } } diff --git a/x/credentials/keeper/msg_server.go b/x/credentials/keeper/msg_server.go index 5f8ce1d1..a4041ff9 100644 --- a/x/credentials/keeper/msg_server.go +++ b/x/credentials/keeper/msg_server.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/xeipuuv/gojsonschema" "github.com/elesto-dao/elesto/x/credentials" "github.com/elesto-dao/elesto/x/did" @@ -24,14 +25,6 @@ func NewMsgServerImpl(keeper Keeper, dids credentials.DidKeeper) credentials.Msg var _ credentials.MsgServer = msgServer{} -func (k msgServer) IssuePublicVerifiableCredential( - goCtx context.Context, - msg *credentials.MsgIssuePublicVerifiableCredentialRequest, -) (*credentials.MsgIssuePublicVerifiableCredentialResponse, error) { - - return nil, fmt.Errorf("not implemented") -} - func (k msgServer) PublishCredentialDefinition( goCtx context.Context, msg *credentials.MsgPublishCredentialDefinitionRequest, @@ -72,64 +65,159 @@ func (k msgServer) UpdateCredentialDefinition( return nil, fmt.Errorf("not implemented") } -// TODO: probably reuse for credential verification -//func executeOnCredentialIssuer(goCtx context.Context, ms *msgServer, constraints did.VerificationRelationships, issuerDID, signer string, update func(issuer *credentials.CredentialIssuer) error) (err error) { -// -// k := ms.Keeper -// ctx := sdk.UnwrapSDKContext(goCtx) -// k.Logger(ctx).Info("request to update a did document", "target did", issuerDID) -// // check that the did is not a key did -// if strings.HasPrefix(issuerDID, did.DidKeyPrefix) { -// err = sdkerrors.Wrapf(did.ErrInvalidInput, "did documents having id with key format are read only %s", issuerDID) -// k.Logger(ctx).Error(err.Error()) -// return -// } -// // get the did document -// didDoc, found := ms.DIDs.GetDidDocument(ctx, []byte(issuerDID)) -// if !found { -// err = sdkerrors.Wrapf(did.ErrDidDocumentNotFound, "did document at %s not found", issuerDID) -// k.Logger(ctx).Error(err.Error()) -// return -// } -// -// // Any verification method in the authentication relationship can update the DID document -// if !didDoc.HasRelationship(did.NewBlockchainAccountID(ctx.ChainID(), signer), constraints...) { -// // check also the controllers -// signerDID := did.NewKeyDID(signer) -// if !didDoc.HasController(signerDID) { -// // if also the controller was not set the error -// err = sdkerrors.Wrapf( -// did.ErrUnauthorized, -// "signer account %s not authorized to update the target did document at %s", -// signer, issuerDID, -// ) -// k.Logger(ctx).Error(err.Error()) -// return -// } -// } -// -// issuer, found := k.GetCredentialIssuer(ctx, []byte(issuerDID)) -// if !found { -// err = sdkerrors.Wrapf(credentials.ErrCredentialIssuerNotFound, "credential issuer definition for %s not found", issuerDID) -// k.Logger(ctx).Error(err.Error()) -// return -// } -// -// // apply the update -// err = update(&issuer) -// if err != nil { -// k.Logger(ctx).Error(err.Error()) -// return -// } -// -// // persist the did document -// k.SetCredentialIssuer(ctx, issuer) -// k.Logger(ctx).Info("credential issuer updated", "did", issuerDID, "controller", signer) -// -// //TODO: fire the event -// //if err := ctx.EventManager().EmitTypedEvent(credentials.NewCredentialIssuerUpdated(did, signer)); err != nil { -// // k.Logger(ctx).Error("failed to emit DidDocumentUpdatedEvent", "did", did, "signer", signer, "err", err) -// //} -// k.Logger(ctx).Info("request to update did document success", "did", didDoc.Id) -// return -//} +func (k msgServer) IssuePublicVerifiableCredential( + goCtx context.Context, + msg *credentials.MsgIssuePublicVerifiableCredentialRequest, +) (*credentials.MsgIssuePublicVerifiableCredentialResponse, error) { + + ctx := sdk.UnwrapSDKContext(goCtx) + k.Logger(ctx).Info("request to issuer a PublicCredential", "credential Definition ID", msg.Credential.Id) + // fetch the credential definition + cd, found := k.GetCredentialDefinition(ctx, msg.CredentialDefinitionDid) + if !found { + err := sdkerrors.Wrapf(credentials.ErrCredentialDefinitionFound, "a credential definition with did %s already exists", msg.CredentialDefinitionDid) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + // verify that can be published + if !cd.IsPublic { + err := sdkerrors.Wrapf(credentials.ErrCredentialIsNotPublic, "the credential definition %s cannot be issued on-chain", msg.CredentialDefinitionDid) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + // verify that is not suspended + if !cd.IsActive { + err := sdkerrors.Wrapf(credentials.ErrCredentialIsNotActive, "the credential definition %s cannot be issued on-chain", msg.CredentialDefinitionDid) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + // Wrap the credential + wc, err := credentials.NewWrappedCredential(msg.Credential) + if err != nil { + err = sdkerrors.Wrapf(credentials.ErrInvalidCredential, "the credential %s is malformed: %v", msg.Credential, err) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + // verify the credential against the schema + schema, err := gojsonschema.NewSchema(gojsonschema.NewStringLoader(cd.Schema)) + if err != nil { + err = sdkerrors.Wrapf(credentials.ErrCredentialDefinitionCorrupted, "the credential definition %s is corrupted: %v", msg.CredentialDefinitionDid, cd) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + crL := gojsonschema.NewBytesLoader(wc.GetBytes()) + dataValidator, err := schema.Validate(crL) + if err != nil { + err = sdkerrors.Wrapf(credentials.ErrInvalidCredential, "the credential doesn't match the schema: %v", msg.CredentialDefinitionDid) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + + if !dataValidator.Valid() { + err = sdkerrors.Wrapf(credentials.ErrCredentialSchema, "schema: %s, errors: %v", msg.CredentialDefinitionDid, dataValidator.Errors()) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + + // validate the proof + if err = ValidateProof(ctx, k.Keeper, wc, did.Authentication, did.AssertionMethod); err != nil { + err = sdkerrors.Wrapf(credentials.ErrMessageSigner, "signature mismatch: %v", err) + k.Logger(ctx).Error(err.Error()) + return nil, err + } + + k.SetPublicCredential(ctx, msg.Credential) + + // TODO fire events + return &credentials.MsgIssuePublicVerifiableCredentialResponse{}, err +} + +// ValidateProof validate the proof of a verifiable credential +func ValidateProof(ctx sdk.Context, k Keeper, wc *credentials.WrappedCredential, verificationRelationships ...string) (err error) { + // resolve the issuer + doc, err := k.did.ResolveDid(ctx, wc.GetIssuerDID()) + if err != nil { + return sdkerrors.Wrapf( + err, "issuer DID is not resolvable", + ) + } + + // see if the subject is a did + if id, hs := wc.GetSubjectID(); hs { + // if is a valid did, try to resolve + if did.IsValidDID(id) { + // resolve the subject + _, err = k.did.ResolveDid(ctx, did.DID(id)) + if err != nil { + return sdkerrors.Wrapf( + err, "subject DID is not resolvable", + ) + } + } + } + + // verify the signature + if wc.Proof == nil { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "proof is nil %v", + err, + ) + } + //check relationships + authorized := false + methodRelationships := doc.GetVerificationRelationships(wc.Proof.VerificationMethod) +Outer: + for _, gotR := range methodRelationships { + for _, wantR := range verificationRelationships { + if gotR == wantR { + authorized = true + break Outer + } + } + } + // verify the relationships + if !authorized { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "unauthorized, verification method ID not listed in any of the required relationships in the issuer did (want %v, got %v) ", verificationRelationships, methodRelationships, + ) + } + // get the address in the verification method + issuerAddress, err := doc.GetVerificationMethodBlockchainAddress(wc.Proof.VerificationMethod) + if err != nil { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "the issuer address cannot be retrieved due to %v", + err, + ) + } + + // verify that is the same of the vc + issuerAccount, err := sdk.AccAddressFromBech32(issuerAddress) + if err != nil { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "failed to convert the issuer address to account %v: %v", issuerAddress, + err, + ) + } + // get the public key from the account + pk, err := k.account.GetPubKey(ctx, issuerAccount) + if err != nil || pk == nil { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "issuer public key not found %v", + err, + ) + } + // + if isValid := wc.Validate(pk); !isValid { + return sdkerrors.Wrapf( + credentials.ErrMessageSigner, + "verification error %v", + err, + ) + } + return nil +} diff --git a/x/credentials/msg.go b/x/credentials/msg.go index 8754a61d..00b09672 100644 --- a/x/credentials/msg.go +++ b/x/credentials/msg.go @@ -92,11 +92,13 @@ var _ sdk.Msg = &MsgIssuePublicVerifiableCredentialRequest{} // NewMsgIssuePublicVerifiableCredentialRequest creates a new MsgIssuePublicVerifiableCredentialRequest instance func NewMsgIssuePublicVerifiableCredentialRequest( credential *PublicVerifiableCredential, - signerAccount string, + definitionDID did.DID, + signerAccount sdk.AccAddress, ) *MsgIssuePublicVerifiableCredentialRequest { return &MsgIssuePublicVerifiableCredentialRequest{ - Credential: credential, - Signer: signerAccount, + Credential: credential, + CredentialDefinitionDid: definitionDID.String(), + Signer: signerAccount.String(), } } diff --git a/x/credentials/tx.pb.go b/x/credentials/tx.pb.go index c66518a4..e832095c 100644 --- a/x/credentials/tx.pb.go +++ b/x/credentials/tx.pb.go @@ -180,8 +180,9 @@ func (m *MsgUpdateCredentialDefinitionResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateCredentialDefinitionResponse proto.InternalMessageInfo type MsgIssuePublicVerifiableCredentialRequest struct { - Credential *PublicVerifiableCredential `protobuf:"bytes,1,opt,name=credential,proto3" json:"credential,omitempty"` - Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` + Credential *PublicVerifiableCredential `protobuf:"bytes,1,opt,name=credential,proto3" json:"credential,omitempty"` + CredentialDefinitionDid string `protobuf:"bytes,2,opt,name=credential_definition_did,json=credentialDefinitionDid,proto3" json:"credential_definition_did,omitempty"` + Signer string `protobuf:"bytes,3,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgIssuePublicVerifiableCredentialRequest) Reset() { @@ -273,7 +274,7 @@ func init() { func init() { proto.RegisterFile("credentials/v1/tx.proto", fileDescriptor_135904727a547ea5) } var fileDescriptor_135904727a547ea5 = []byte{ - // 444 bytes of a gzipped FileDescriptorProto + // 467 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0x2e, 0x4a, 0x4d, 0x49, 0xcd, 0x2b, 0xc9, 0x4c, 0xcc, 0x29, 0xd6, 0x2f, 0x33, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x4f, 0xcd, 0x49, 0x2d, 0x2e, 0xc9, 0x4f, 0x49, 0xcc, 0xd7, 0x83, @@ -289,19 +290,21 @@ var fileDescriptor_135904727a547ea5 = []byte{ 0xe7, 0x3f, 0x31, 0x2e, 0xb6, 0xc4, 0xe4, 0x92, 0xcc, 0xb2, 0x54, 0xb0, 0x8f, 0x38, 0x82, 0xa0, 0x3c, 0x21, 0x25, 0x2e, 0x9e, 0xe2, 0xd2, 0x82, 0xd4, 0xa2, 0xe2, 0xd4, 0x94, 0xd4, 0x14, 0xa7, 0x4a, 0xa8, 0x93, 0x50, 0xc4, 0x90, 0x1c, 0xcc, 0x8c, 0xc3, 0xc1, 0xea, 0xe0, 0x60, 0xc6, 0xe7, - 0x0a, 0xa8, 0x7b, 0x57, 0x31, 0x72, 0x69, 0xfa, 0x16, 0xa7, 0x7b, 0x16, 0x17, 0x97, 0xa6, 0x82, + 0x0a, 0xa8, 0x7b, 0x9f, 0x31, 0x72, 0x69, 0xfa, 0x16, 0xa7, 0x7b, 0x16, 0x17, 0x97, 0xa6, 0x82, 0xfd, 0x97, 0x1c, 0x96, 0x5a, 0x94, 0x99, 0x96, 0x99, 0x98, 0x94, 0x83, 0xa4, 0x11, 0xe6, 0xe8, 0x68, 0x2e, 0x2e, 0x44, 0x08, 0x42, 0xa3, 0xc2, 0x9a, 0x60, 0x54, 0xe0, 0x31, 0x17, 0xc9, 0x38, - 0x22, 0xa2, 0x41, 0x87, 0x4b, 0x8b, 0x18, 0xb7, 0x42, 0xbc, 0x66, 0xb4, 0x90, 0x85, 0x8b, 0xd9, - 0xb7, 0x38, 0x5d, 0x68, 0x1d, 0x23, 0x97, 0x34, 0x9e, 0xa8, 0x13, 0x72, 0x23, 0xe8, 0x01, 0xa2, - 0x52, 0xac, 0x94, 0x3b, 0xc5, 0xe6, 0x40, 0x1c, 0x2e, 0xb4, 0x9a, 0x91, 0x4b, 0x0a, 0x77, 0xd4, - 0x09, 0xb9, 0x12, 0x63, 0x0f, 0xc1, 0x04, 0x28, 0xe5, 0x46, 0xa9, 0x31, 0x50, 0xd7, 0xee, 0x62, - 0xe4, 0x92, 0x27, 0x10, 0x25, 0x42, 0x5e, 0xc4, 0xd8, 0x45, 0x5c, 0x1a, 0x94, 0xf2, 0xa6, 0x8a, - 0x59, 0x10, 0xc7, 0x3b, 0xb9, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, - 0x56, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc4, 0x1a, 0xdd, 0x94, - 0xc4, 0x7c, 0x28, 0x53, 0xbf, 0x02, 0xb9, 0x6c, 0x4b, 0x62, 0x03, 0x17, 0x6e, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x64, 0x4b, 0x72, 0x54, 0x50, 0x05, 0x00, 0x00, + 0x21, 0x2b, 0x2e, 0x49, 0x04, 0x2f, 0x3e, 0x05, 0xee, 0xd6, 0xf8, 0x94, 0xcc, 0x14, 0x68, 0x30, + 0x88, 0x63, 0x8b, 0x3f, 0x97, 0xcc, 0x14, 0x22, 0x42, 0x44, 0x87, 0x4b, 0x8b, 0x18, 0x7f, 0x42, + 0x82, 0xc5, 0x68, 0x21, 0x0b, 0x17, 0xb3, 0x6f, 0x71, 0xba, 0xd0, 0x3a, 0x46, 0x2e, 0x69, 0x3c, + 0xd1, 0x2e, 0xe4, 0x46, 0xd0, 0xf3, 0x44, 0xa5, 0x76, 0x29, 0x77, 0x8a, 0xcd, 0x81, 0x38, 0x5c, + 0x68, 0x35, 0x23, 0x97, 0x14, 0xee, 0x68, 0x17, 0x72, 0x25, 0xc6, 0x1e, 0x82, 0x89, 0x57, 0xca, + 0x8d, 0x52, 0x63, 0xa0, 0xae, 0xdd, 0xc5, 0xc8, 0x25, 0x4f, 0x20, 0x4a, 0x84, 0xbc, 0x88, 0xb1, + 0x8b, 0xb8, 0xf4, 0x2b, 0xe5, 0x4d, 0x15, 0xb3, 0x20, 0x8e, 0x77, 0x72, 0x39, 0xf1, 0x48, 0x8e, + 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, + 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xad, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, + 0xfc, 0x5c, 0x7d, 0x88, 0x35, 0xba, 0x29, 0x89, 0xf9, 0x50, 0xa6, 0x7e, 0x05, 0x72, 0xb9, 0x98, + 0xc4, 0x06, 0x2e, 0x18, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x07, 0x70, 0x33, 0x8c, + 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -616,6 +619,13 @@ func (m *MsgIssuePublicVerifiableCredentialRequest) MarshalToSizedBuffer(dAtA [] copy(dAtA[i:], m.Signer) i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- + dAtA[i] = 0x1a + } + if len(m.CredentialDefinitionDid) > 0 { + i -= len(m.CredentialDefinitionDid) + copy(dAtA[i:], m.CredentialDefinitionDid) + i = encodeVarintTx(dAtA, i, uint64(len(m.CredentialDefinitionDid))) + i-- dAtA[i] = 0x12 } if m.Credential != nil { @@ -732,6 +742,10 @@ func (m *MsgIssuePublicVerifiableCredentialRequest) Size() (n int) { l = m.Credential.Size() n += 1 + l + sovTx(uint64(l)) } + l = len(m.CredentialDefinitionDid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = len(m.Signer) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -1172,6 +1186,38 @@ func (m *MsgIssuePublicVerifiableCredentialRequest) Unmarshal(dAtA []byte) error } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CredentialDefinitionDid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CredentialDefinitionDid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) }