Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

feat: DID schema to support publicKeyJwk & secp256k1 #1510

Merged
merged 1 commit into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/aries-agent-rest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec v1.0.0 h1:W+z6Es+Rai3MXYVoPAxYr5U1DGis0Co33scJ6uH2J6o=
github.com/decred/dcrd/dcrec v1.0.0/go.mod h1:HIaqbEJQ+PDzQcORxnqen5/V1FR3B4VpIfmePklt8Q8=
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.0 h1:3GIJYXQDAKpLEFriGFN8SbSffak10UXHGdIcFaMPykY=
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.0/go.mod h1:3s92l0paYkZoIHuj4X93Teg/HB7eGM9x/zokGw+u4mY=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ require (
github.com/VictoriaMetrics/fastcache v1.5.7
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
github.com/btcsuite/btcutil v1.0.1
github.com/decred/dcrd/dcrec v1.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.0
github.com/golang/mock v1.4.0
github.com/golang/protobuf v1.3.3
github.com/google/tink v1.3.0
Expand Down
19 changes: 19 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSR
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/VictoriaMetrics/fastcache v1.5.7 h1:4y6y0G8PRzszQUYIQHHssv/jgPHAb5qQuuDNdCbyAgw=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/aws/aws-sdk-go v1.25.39/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
troyronda marked this conversation as resolved.
Show resolved Hide resolved
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.1 h1:GKOz8BnRjYrb/JTKgaOk+zh26NWNdSNvdvv0xoAZMSA=
github.com/btcsuite/btcutil v1.0.1/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd h1:qdGvebPBDuYDPGi1WCPjy1tGyMpmDK8IEapSsszn7HE=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723 h1:ZA/jbKoGcVAnER6pCHPEkGdZOV7U1oLUedErBHCUMs0=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc=
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk=
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand All @@ -30,6 +38,14 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd v1.3.0 h1:EEXm7BdiROfazDtuFsOu9mfotnyy00bgCuVwUqaszFo=
github.com/decred/dcrd/chaincfg/chainhash v1.0.2/go.mod h1:BpbrGgrPTr3YJYRN3Bm+D9NuaFd+zGyNeIKgrhCXK60=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec v1.0.0 h1:W+z6Es+Rai3MXYVoPAxYr5U1DGis0Co33scJ6uH2J6o=
github.com/decred/dcrd/dcrec v1.0.0/go.mod h1:HIaqbEJQ+PDzQcORxnqen5/V1FR3B4VpIfmePklt8Q8=
github.com/decred/dcrd/dcrec/secp256k1 v1.0.3 h1:u4XpHqlscRolxPxt2YHrFBDVZYY1AK+KMV02H1r+HmU=
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.0 h1:3GIJYXQDAKpLEFriGFN8SbSffak10UXHGdIcFaMPykY=
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.0/go.mod h1:3s92l0paYkZoIHuj4X93Teg/HB7eGM9x/zokGw+u4mY=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
Expand Down Expand Up @@ -77,10 +93,13 @@ github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89 h1:12K8AlpT0/6QUXSfV0yi4Q0jkbq8NDtIKFtF61AoqV0=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jrick/logrotate v1.0.0 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/compress v1.10.0 h1:92XGj1AcYzA6UrVdd4qIIBrT8OroryvRvdmg/IfmC7Y=
github.com/klauspost/compress v1.10.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
Expand Down
30 changes: 26 additions & 4 deletions pkg/doc/did/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/btcsuite/btcutil/base58"
"github.com/xeipuuv/gojsonschema"

"github.com/hyperledger/aries-framework-go/pkg/doc/jose"
"github.com/hyperledger/aries-framework-go/pkg/doc/signature/verifier"
)

Expand Down Expand Up @@ -47,6 +48,7 @@ const (
jsonldPublicKeyBase58 = "publicKeyBase58"
jsonldPublicKeyHex = "publicKeyHex"
jsonldPublicKeyPem = "publicKeyPem"
jsonldPublicKeyjwk = "publicKeyJwk"
schemaV1 = `{
"required": [
"@context",
Expand All @@ -58,7 +60,7 @@ const (
"items": [
{
"type": "string",
"pattern": "^https://w3id.org/did/v1$"
"pattern": "^https://(w3id.org|www.w3.org/ns)/did/v1$"
}
],
"additionalItems": {
Expand Down Expand Up @@ -142,7 +144,6 @@ const (
],
"type": "object",
"minProperties": 4,
"maxProperties": 4,
"properties": {
"id": {
"type": "string"
Expand Down Expand Up @@ -189,7 +190,7 @@ const (
"items": [
{
"type": "string",
"pattern": "^https://w3id.org/did/v0.11$"
"pattern": "^https://(w3id.org|www.w3.org/ns)/did/v0.11$"
}
],
"additionalItems": {
Expand Down Expand Up @@ -272,7 +273,6 @@ const (
],
"type": "object",
"minProperties": 3,
"maxProperties": 4,
"properties": {
"id": {
"type": "string"
Expand Down Expand Up @@ -637,6 +637,15 @@ func decodePK(rawPK map[string]interface{}) ([]byte, error) {
return block.Bytes, nil
}

if jwkMap := mapEntry(rawPK[jsonldPublicKeyjwk]); jwkMap != nil {
jwkBytes, err := json.Marshal(jwkMap)
if err != nil {
return nil, fmt.Errorf("failed to marshal '%s', cause: %w ", jsonldPublicKeyjwk, err)
}

return jose.DecodePublicKey(jwkBytes)
}

return nil, errors.New("public key encoding not supported")
}

Expand Down Expand Up @@ -731,6 +740,19 @@ func stringArray(entry interface{}) []string {
return result
}

func mapEntry(entry interface{}) map[string]interface{} {
if entry == nil {
return nil
}

result, ok := entry.(map[string]interface{})
if !ok {
return nil
}

return result
}

// JSONBytes converts document to json bytes
func (doc *Doc) JSONBytes() ([]byte, error) {
context := Context
Expand Down
159 changes: 128 additions & 31 deletions pkg/doc/did/doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func TestValidateDidDocContext(t *testing.T) {
require.NoError(t, err)
err = validate(bytes, raw.schemaLoader())
require.Error(t, err)
require.Contains(t, err.Error(), "Does not match pattern '^https://w3id.org/did/v1$'")
require.Contains(t, err.Error(), "Does not match pattern '^https://")
})
}

Expand Down Expand Up @@ -468,20 +468,6 @@ func TestValidateDidDocPublicKey(t *testing.T) {
err = validate(bytes, raw.schemaLoader())
require.NoError(t, err)
})

t.Run("test did doc public key with extra key", func(t *testing.T) {
docs := []string{validDoc, validDocV011}
for _, d := range docs {
raw := &rawDoc{}
require.NoError(t, json.Unmarshal([]byte(d), &raw))
raw.PublicKey[0]["key1"] = ""
bytes, err := json.Marshal(raw)
require.NoError(t, err)
err = validate(bytes, raw.schemaLoader())
require.Error(t, err)
require.Contains(t, err.Error(), "Must have at most 4 properties")
}
})
}

func TestValidateDidDocAuthentication(t *testing.T) {
Expand Down Expand Up @@ -568,22 +554,6 @@ func TestValidateDidDocAuthentication(t *testing.T) {
err = validate(bytes, raw.schemaLoader())
require.NoError(t, err)
})

t.Run("test did doc auth public key with extra key", func(t *testing.T) {
docs := []string{validDoc, validDocV011}
for _, d := range docs {
raw := &rawDoc{}
require.NoError(t, json.Unmarshal([]byte(d), &raw))
pk, ok := raw.Authentication[1].(map[string]interface{})
require.True(t, ok)
pk["key1"] = ""
bytes, err := json.Marshal(raw)
require.NoError(t, err)
err = validate(bytes, raw.schemaLoader())
require.Error(t, err)
require.Contains(t, err.Error(), "Must have at most 4 properties")
}
})
}

func TestValidateDidDocService(t *testing.T) {
Expand Down Expand Up @@ -957,6 +927,133 @@ func Test_DID_String(t *testing.T) {
require.Equal(t, expected, did.String())
}

func TestDIDSchemas(t *testing.T) {
t.Run("Test decode public key", func(t *testing.T) {
tests := []struct {
name string
didStr string
}{
{
name: "DID with JWK & multiple contexts & extra public Key properties",
didStr: `{
"authentication": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"capabilityDelegation": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"keyAgreement": [{
"type": "X25519KeyAgreementKey2019",
"publicKeyBase58": "HFJE99F2iCaxCTKJdNPU8fML3N5jemVXksxcXvozRJu1",
"id": "#keyAgreement",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}],
"assertionMethod": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"@context": ["https://www.w3.org/ns/did/v1", "https://docs.example.com/contexts/sample/sample-v0.1.jsonld"],
"publicKey": [{
"id": "#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA",
"usage": "signing",
"publicKeyJwk": {
"x": "DSE4CfCVKNgxNMDV6dK_DbcwshievbxwHJwOsGoSpaw",
"kty": "EC",
"crv": "secp256k1",
"y": "xzrnm-VHA22nfGrNGGaLL9aPHRN26qyJNli3jByQSfQ",
"kid": "5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA"
},
"type": "EcdsaSecp256k1VerificationKey2019",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"publicKeyHex": "020d213809f09528d83134c0d5e9d2bf0db730b2189ebdbc701c9c0eb06a12a5ac",
"type": "EcdsaSecp256k1VerificationKey2019",
"id": "#primary",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"publicKeyHex": "02d5a045f28c14b3d5971b0df9aabd8ee44a3e3af52a1a14a206327991c6e54a80",
"type": "EcdsaSecp256k1VerificationKey2019",
"id": "#recovery",
"usage": "recovery",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"type": "Ed25519VerificationKey2018",
"publicKeyBase58": "GUXiqNHCdirb6NKpH6wYG4px3YfMjiCh6dQhU3zxQVQ7",
"id": "#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}],
"capabilityInvocation": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"id": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}`,
},
{
name: "DID with JWK & single context & extra public Key properties",
didStr: `{
"authentication": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"capabilityDelegation": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"keyAgreement": [{
"type": "X25519KeyAgreementKey2019",
"publicKeyBase58": "HFJE99F2iCaxCTKJdNPU8fML3N5jemVXksxcXvozRJu1",
"id": "#keyAgreement",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}],
"assertionMethod": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"@context": "https://w3id.org/did/v1",
"publicKey": [{
"id": "#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA",
"usage": "signing",
"publicKeyJwk": {
"x": "DSE4CfCVKNgxNMDV6dK_DbcwshievbxwHJwOsGoSpaw",
"kty": "EC",
"crv": "secp256k1",
"y": "xzrnm-VHA22nfGrNGGaLL9aPHRN26qyJNli3jByQSfQ",
"kid": "5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA"
},
"type": "EcdsaSecp256k1VerificationKey2019",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"publicKeyHex": "020d213809f09528d83134c0d5e9d2bf0db730b2189ebdbc701c9c0eb06a12a5ac",
"type": "EcdsaSecp256k1VerificationKey2019",
"id": "#primary",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"publicKeyHex": "02d5a045f28c14b3d5971b0df9aabd8ee44a3e3af52a1a14a206327991c6e54a80",
"type": "EcdsaSecp256k1VerificationKey2019",
"id": "#recovery",
"usage": "recovery",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}, {
"type": "Ed25519VerificationKey2018",
"publicKeyBase58": "GUXiqNHCdirb6NKpH6wYG4px3YfMjiCh6dQhU3zxQVQ7",
"id": "#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s",
"usage": "signing",
"controller": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}],
"capabilityInvocation": ["#5hgq2bNVTqyns_Nvcc_ybVHnFMx33_dAsfrfpZMTqTA", "#primary", "#recovery",
"#aBpRoPAbz0yw0evvPM1aEot39hAkG-XHgxFptPYAd6s"],
"id": "did:sample:EiAiSE10ugVUHXsOp4pm86oN6LnjuCdrkt3s12rcVFkilQ"
}`,
},
}

t.Parallel()

for _, test := range tests {
tc := test
t.Run(tc.name, func(t *testing.T) {
doc, err := ParseDocument([]byte(tc.didStr))
require.NoError(t, err)
require.NotNil(t, doc)
})
}
})
}

func createDidDocumentWithSigningKey(pubKey []byte) *Doc {
const didContext = "https://w3id.org/did/v1"

Expand Down