@@ -81,6 +81,22 @@ func (doc *JsonLdCredentialStatus) GetContext() []contextObject {
81
81
return doc .Context
82
82
}
83
83
84
+ type JsonLdCredentialStatusBJJ struct {
85
+ Context []contextObject `json:"@context,omitempty"`
86
+ Id string `json:"id,omitempty"`
87
+ Revoked bool `json:"revoked,omitempty"`
88
+ Suspended bool `json:"suspended,omitempty"`
89
+ Remarks string `json:"remarks,omitempty"`
90
+ Issuer string `json:"issuer,omitempty"`
91
+ IssuanceDate string `json:"issuanceDate,omitempty"`
92
+ CredentialMerkleRootHash string `json:"credentialMerkleRootHash,omitempty"`
93
+ Proof JsonLdDocumentProof `json:"proof,omitempty"`
94
+ }
95
+
96
+ func (doc * JsonLdCredentialStatusBJJ ) GetContext () []contextObject {
97
+ return doc .Context
98
+ }
99
+
84
100
// NewJsonLdCredentialStatus returns a new JsonLdCredentialStatus struct from input Credential Status
85
101
func NewJsonLdCredentialStatus (credStatusDoc * types.CredentialStatusDocument ) * JsonLdCredentialStatus {
86
102
if len (credStatusDoc .Context ) == 0 {
@@ -108,6 +124,37 @@ func NewJsonLdCredentialStatus(credStatusDoc *types.CredentialStatusDocument) *J
108
124
return jsonLdCredentialStatus
109
125
}
110
126
127
+ func NewJsonLdCredentialStatusBJJ (credStatusDoc * types.CredentialStatusDocument , docProof * types.DocumentProof ) * JsonLdCredentialStatusBJJ {
128
+ if len (credStatusDoc .Context ) == 0 {
129
+ panic ("atleast one context url must be provided in the Credential Status Document for Canonization" )
130
+ }
131
+
132
+ var jsonLdCredentialStatus * JsonLdCredentialStatusBJJ = & JsonLdCredentialStatusBJJ {}
133
+
134
+ for _ , url := range credStatusDoc .Context {
135
+ contextObj , ok := ContextUrlMap [url ]
136
+ if ! ok {
137
+ panic (fmt .Sprintf ("invalid or unsupported context url: %v" , url ))
138
+ }
139
+ jsonLdCredentialStatus .Context = append (jsonLdCredentialStatus .Context , contextObj )
140
+ }
141
+
142
+ jsonLdCredentialStatus .Id = credStatusDoc .Id
143
+ jsonLdCredentialStatus .Revoked = credStatusDoc .Revoked
144
+ jsonLdCredentialStatus .Remarks = credStatusDoc .Remarks
145
+ jsonLdCredentialStatus .Suspended = credStatusDoc .Suspended
146
+ jsonLdCredentialStatus .Issuer = credStatusDoc .Issuer
147
+ jsonLdCredentialStatus .IssuanceDate = credStatusDoc .IssuanceDate
148
+ jsonLdCredentialStatus .CredentialMerkleRootHash = credStatusDoc .CredentialMerkleRootHash
149
+
150
+ jsonLdCredentialStatus .Proof .Type = docProof .Type
151
+ jsonLdCredentialStatus .Proof .Created = docProof .Created
152
+ jsonLdCredentialStatus .Proof .ProofPurpose = docProof .ProofPurpose
153
+ jsonLdCredentialStatus .Proof .VerificationMethod = docProof .VerificationMethod
154
+
155
+ return jsonLdCredentialStatus
156
+ }
157
+
111
158
// Document Proof
112
159
113
160
type JsonLdDocumentProof struct {
@@ -163,6 +210,22 @@ func (doc *JsonLdCredentialSchema) GetContext() []contextObject {
163
210
return doc .Context
164
211
}
165
212
213
+ type JsonLdCredentialSchemaBJJ struct {
214
+ Context []contextObject `json:"@context,omitempty"`
215
+ Type string `json:"type,omitempty"`
216
+ ModelVersion string `json:"modelVersion,omitempty"`
217
+ Id string `json:"id,omitempty"`
218
+ Name string `json:"name,omitempty"`
219
+ Author string `json:"author,omitempty"`
220
+ Authored string `json:"authored,omitempty"`
221
+ Schema * types.CredentialSchemaProperty `json:"schema,omitempty"`
222
+ Proof JsonLdDocumentProof `json:"proof,omitempty"`
223
+ }
224
+
225
+ func (doc * JsonLdCredentialSchemaBJJ ) GetContext () []contextObject {
226
+ return doc .Context
227
+ }
228
+
166
229
func NewJsonLdCredentialSchema (credSchema * types.CredentialSchemaDocument ) * JsonLdCredentialSchema {
167
230
if len (credSchema .Context ) == 0 {
168
231
panic ("atleast one context url must be provided for DID Document for Canonization" )
@@ -189,24 +252,60 @@ func NewJsonLdCredentialSchema(credSchema *types.CredentialSchemaDocument) *Json
189
252
return jsonLdDoc
190
253
}
191
254
255
+ func NewJsonLdCredentialSchemaBJJ (credSchema * types.CredentialSchemaDocument , docProof * types.DocumentProof ) * JsonLdCredentialSchemaBJJ {
256
+ if len (credSchema .Context ) == 0 {
257
+ panic ("atleast one context url must be provided for DID Document for Canonization" )
258
+ }
259
+
260
+ var jsonLdDoc * JsonLdCredentialSchemaBJJ = & JsonLdCredentialSchemaBJJ {}
261
+
262
+ for _ , url := range credSchema .Context {
263
+ contextObj , ok := ContextUrlMap [url ]
264
+ if ! ok {
265
+ panic (fmt .Sprintf ("invalid or unsupported context url: %v" , url ))
266
+ }
267
+ jsonLdDoc .Context = append (jsonLdDoc .Context , contextObj )
268
+ }
269
+
270
+ jsonLdDoc .Type = credSchema .Type
271
+ jsonLdDoc .ModelVersion = credSchema .ModelVersion
272
+ jsonLdDoc .Id = credSchema .Id
273
+ jsonLdDoc .Name = credSchema .Name
274
+ jsonLdDoc .Author = credSchema .Author
275
+ jsonLdDoc .Authored = credSchema .Authored
276
+ jsonLdDoc .Schema = credSchema .Schema
277
+
278
+ jsonLdDoc .Proof .Type = docProof .Type
279
+ jsonLdDoc .Proof .Created = docProof .Created
280
+ jsonLdDoc .Proof .ProofPurpose = docProof .ProofPurpose
281
+ jsonLdDoc .Proof .VerificationMethod = docProof .VerificationMethod
282
+
283
+ return jsonLdDoc
284
+ }
285
+
192
286
// It is a similar to `Did` struct, with the exception that the `context` attribute is of type
193
287
// `contextObject` instead of `[]string`, which is meant for accomodating Context JSON body
194
288
// having arbritrary attributes. It should be used for performing Canonization.
195
289
type JsonLdDidDocumentWithoutVM struct {
196
- Context []contextObject `json:"@context,omitempty"`
197
- Id string `json:"id,omitempty"`
198
- Controller []string `json:"controller,omitempty"`
199
- AlsoKnownAs []string `json:"alsoKnownAs,omitempty"`
200
- Authentication []verificationMethodWithoutController `json:"authentication,omitempty"`
201
- AssertionMethod []verificationMethodWithoutController `json:"assertionMethod,omitempty"`
290
+ Context []contextObject `json:"@context,omitempty"`
291
+ Id string `json:"id,omitempty"`
292
+ Controller []string `json:"controller,omitempty"`
293
+ // AlsoKnownAs []string `json:"alsoKnownAs,omitempty"`
294
+ Authentication []verificationMethodWithoutController `json:"authentication,omitempty"`
295
+ AssertionMethod []verificationMethodWithoutController `json:"assertionMethod,omitempty"`
296
+ CapabilityDelegation []verificationMethodWithoutController `json:"capabilityDelegation,omitempty"`
297
+ CapabilityInvocation []verificationMethodWithoutController `json:"capabilityInvocation,omitempty"`
298
+ KeyAgreement []verificationMethodWithoutController `json:"keyAgreement,omitempty"`
299
+ Proof JsonLdDocumentProof `json:"proof,omitempty"`
300
+ Service []* types.Service `protobuf:"bytes,11,rep,name=service,proto3" json:"service,omitempty"`
202
301
}
203
302
204
303
func (doc * JsonLdDidDocumentWithoutVM ) GetContext () []contextObject {
205
304
return doc .Context
206
305
}
207
306
208
307
// NewJsonLdDidDocument returns a new JsonLdDid struct from input Did
209
- func NewJsonLdDidDocumentWithoutVM (didDoc * types.DidDocument ) * JsonLdDidDocumentWithoutVM {
308
+ func NewJsonLdDidDocumentWithoutVM (didDoc * types.DidDocument , docProof * types. DocumentProof ) * JsonLdDidDocumentWithoutVM {
210
309
if len (didDoc .Context ) == 0 {
211
310
panic ("atleast one context url must be provided for DID Document for Canonization" )
212
311
}
@@ -223,8 +322,6 @@ func NewJsonLdDidDocumentWithoutVM(didDoc *types.DidDocument) *JsonLdDidDocument
223
322
224
323
jsonLdDoc .Id = didDoc .Id
225
324
jsonLdDoc .Controller = didDoc .Controller
226
- jsonLdDoc .AlsoKnownAs = didDoc .AlsoKnownAs
227
-
228
325
// Replace verification method ids with their corresponding Verification Method object
229
326
var vmMap map [string ]verificationMethodWithoutController = map [string ]verificationMethodWithoutController {}
230
327
@@ -250,8 +347,31 @@ func NewJsonLdDidDocumentWithoutVM(didDoc *types.DidDocument) *JsonLdDidDocument
250
347
jsonLdDoc .AssertionMethod = append (jsonLdDoc .AssertionMethod , vmObj )
251
348
jsonLdDoc .AssertionMethod [len (jsonLdDoc .AssertionMethod )- 1 ].Id = jsonLdDoc .AssertionMethod [len (jsonLdDoc .AssertionMethod )- 1 ].Id + "assertionMethod"
252
349
}
350
+
351
+ for _ , vmId := range didDoc .CapabilityDelegation {
352
+ vmObj := vmMap [vmId ]
353
+ jsonLdDoc .CapabilityDelegation = append (jsonLdDoc .CapabilityDelegation , vmObj )
354
+ jsonLdDoc .CapabilityDelegation [len (jsonLdDoc .CapabilityDelegation )- 1 ].Id = jsonLdDoc .CapabilityDelegation [len (jsonLdDoc .CapabilityDelegation )- 1 ].Id + "capabilityDelegation"
355
+ }
356
+
357
+ for _ , vmId := range didDoc .CapabilityInvocation {
358
+ vmObj := vmMap [vmId ]
359
+ jsonLdDoc .CapabilityInvocation = append (jsonLdDoc .CapabilityInvocation , vmObj )
360
+ jsonLdDoc .CapabilityInvocation [len (jsonLdDoc .CapabilityInvocation )- 1 ].Id = jsonLdDoc .CapabilityInvocation [len (jsonLdDoc .CapabilityInvocation )- 1 ].Id + "capabilityInvocation"
361
+ }
362
+
363
+ for _ , vmId := range didDoc .KeyAgreement {
364
+ vmObj := vmMap [vmId ]
365
+ jsonLdDoc .KeyAgreement = append (jsonLdDoc .KeyAgreement , vmObj )
366
+ jsonLdDoc .KeyAgreement [len (jsonLdDoc .KeyAgreement )- 1 ].Id = jsonLdDoc .KeyAgreement [len (jsonLdDoc .KeyAgreement )- 1 ].Id + "keyAgreement"
367
+ }
253
368
}
254
369
370
+ jsonLdDoc .Proof .Type = docProof .Type
371
+ jsonLdDoc .Proof .Created = docProof .Created
372
+ jsonLdDoc .Proof .ProofPurpose = docProof .ProofPurpose
373
+ jsonLdDoc .Proof .VerificationMethod = docProof .VerificationMethod + docProof .ProofPurpose
374
+ jsonLdDoc .Service = didDoc .Service
255
375
return jsonLdDoc
256
376
}
257
377
0 commit comments