decentralized-identity / did-jwt-vc

Create and verify W3C Verifiable Credentials and Presentations in JWT format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ask]how do i add creator in proof property?

joeg9soft opened this issue · comments

hi im trying to add creator property in proof property of vc after verify.
this is verifiableCredential property of result of verify.

verifiableCredential: {
aud: 'did:ethr:0x1e240:0x0231b9be0926e6e2791e8e0a0af894134de7d01c9dc1312d7b799c462626e61c25',
credentialSubject: {
degree: [Object],
id: 'did:ethr:0x1e240:0x0231b9be0926e6e2791e8e0a0af894134de7d01c9dc1312d7b799c462626e61c25'
},
issuer: {
id: 'did:ethr:0x1e240:0x03f67afe0fea3f47af4848553d730897c7730569f4b0d7617a278d7acf7508298a'
},
id: 'abcd',
type: [ 'VerifiableCredential' ],
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
issuanceDate: '2022-05-10T10:04:10.000Z',
expirationDate: '2022-06-21T02:04:10.000Z',
proof: {
type: 'JwtProof2020',
jwt: 'eyJhbGciOiJFUzI1NkstUiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTU3NzcwNTAsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsiZGVncmVlIjp7InR5cGUiOiJCYWNoZWxvckRlZ3JlZSIsIm5hbWUiOiJCYWNjYWxhdXLDqWF0IGVuIG11c2lxdWVzIG51bcOpcmlxdWVzIn19LCJwcm9vZiI6eyJjcmVhdG9yIjoidGVzdCJ9fSwic3ViIjoiZGlkOmV0aHI6MHgxZTI0MDoweDAyMzFiOWJlMDkyNmU2ZTI3OTFlOGUwYTBhZjg5NDEzNGRlN2QwMWM5ZGMxMzEyZDdiNzk5YzQ2MjYyNmU2MWMyNSIsIm5iZiI6MTY1MjE3NzA1MCwiYXVkIjoiZGlkOmV0aHI6MHgxZTI0MDoweDAyMzFiOWJlMDkyNmU2ZTI3OTFlOGUwYTBhZjg5NDEzNGRlN2QwMWM5ZGMxMzEyZDdiNzk5YzQ2MjYyNmU2MWMyNSIsImp0aSI6ImFiY2QiLCJpc3MiOiJkaWQ6ZXRocjoweDFlMjQwOjB4MDNmNjdhZmUwZmVhM2Y0N2FmNDg0ODU1M2Q3MzA4OTdjNzczMDU2OWY0YjBkNzYxN2EyNzhkN2FjZjc1MDgyOThhIn0.v4KZQeAnDcayzLLTNoCYgvnUnGf2lIGNxvZag99RlJz4d_aMreD5u9dzdESydDGZ4JSk1Ede_ve3bO7Wm2r9kAE'
}
}

i want form like this
proof : { type: 'JwtProof2020', jwt: '~~~~', creator: 'test univ' }

Hi @joeg9soft that's not possible with this library.

The JwtProof2020 proof type is a synthetic proof and it is provided only for convenience. The credential is presented by the library in this JSON format for convenience when working with the VC-spec.

The actual VerifiableCredential is the jwt property of the proof. Everything else about the JSON representation of the credential is decoded from that JWT.

Because the object is decoded from the JWT, there is no way to add custom properties to the proof property of the decoded object.

Closing this because there is no direct fix.

@mirceanis
then
issuer : { id : "~~", name : "test"}
is this not possible neither?

@mirceanis then issuer : { id : "~~", name : "test"} is this not possible neither?

That should work. Did you try it?

@mirceanis
const vcPayload = {
aud: otherOne.did, // 발급받는자
exp: 1957463421, // 토큰 유효 만료 시간
nbf: 1557021724, // 토큰 유효 시작 시간
sub: otherOne.did, // 발급명
iss: issuer.did, // 발급자
iat: 1557021724, // 발급 시간
jti: 'jwt id', // jwt id, vc id랑 통일
vc: {
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
type: [ 'VerifiableCredential' ],
credentialSubject: {
degree: {
type: 'BachelorDegree',
name: 'Baccalauréat en musiques numériques'
}
},
id: 'http://localhost:9090/did/vc/123', // vc id
issuer: { id: issuer.did, name: 'test'},
issuanceDate: '2022-05-11 03:03:03',
expirationDate: '2023-05-11 03:03:03'
}
};

this is what i tried
and result is

verifiableCredential: {
iat: 1557021724,
vc: {
id: 'http://localhost:9090/did/vc/123',
issuer: [Object],
issuanceDate: '2022-05-11 03:03:03',
expirationDate: '2023-05-11 03:03:03'
},
aud: 'did:ethr:0x1e240:0x0231b9be0926e6e2791e8e0a0af894134de7d01c9dc1312d7b799c462626e61c25',
credentialSubject: {
degree: [Object],
id: 'did:ethr:0x1e240:0x0231b9be0926e6e2791e8e0a0af894134de7d01c9dc1312d7b799c462626e61c25'
},
issuer: {
id: 'did:ethr:0x1e240:0x03f67afe0fea3f47af4848553d730897c7730569f4b0d7617a278d7acf7508298a'
},
id: 'jwt id',
type: [ 'VerifiableCredential' ],
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
issuanceDate: '2019-05-05T02:02:04.000Z',
expirationDate: '2032-01-11T19:50:21.000Z',
proof: {
type: 'JwtProof2020',
jwt: 'eyJhbGciOiJFUzI1NkstUiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTcwMjE3MjQsImV4cCI6MTk1NzQ2MzQyMSwidmMiOnsiQGNvbnRleHQiOlsiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiXSwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJkZWdyZWUiOnsidHlwZSI6IkJhY2hlbG9yRGVncmVlIiwibmFtZSI6IkJhY2NhbGF1csOpYXQgZW4gbXVzaXF1ZXMgbnVtw6lyaXF1ZXMifX0sImlkIjoiaHR0cDovL2xvY2FsaG9zdDo5MDkwL2RpZC92Yy8xMjMiLCJpc3N1ZXIiOnsiaWQiOiJkaWQ6ZXRocjoweDFlMjQwOjB4MDNmNjdhZmUwZmVhM2Y0N2FmNDg0ODU1M2Q3MzA4OTdjNzczMDU2OWY0YjBkNzYxN2EyNzhkN2FjZjc1MDgyOThhIiwibmFtZSI6InRlc3QifSwiaXNzdWFuY2VEYXRlIjoiMjAyMi0wNS0xMSAwMzowMzowMyIsImV4cGlyYXRpb25EYXRlIjoiMjAyMy0wNS0xMSAwMzowMzowMyJ9LCJhdWQiOiJkaWQ6ZXRocjoweDFlMjQwOjB4MDIzMWI5YmUwOTI2ZTZlMjc5MWU4ZTBhMGFmODk0MTM0ZGU3ZDAxYzlkYzEzMTJkN2I3OTljNDYyNjI2ZTYxYzI1IiwibmJmIjoxNTU3MDIxNzI0LCJzdWIiOiJkaWQ6ZXRocjoweDFlMjQwOjB4MDIzMWI5YmUwOTI2ZTZlMjc5MWU4ZTBhMGFmODk0MTM0ZGU3ZDAxYzlkYzEzMTJkN2I3OTljNDYyNjI2ZTYxYzI1IiwiaXNzIjoiZGlkOmV0aHI6MHgxZTI0MDoweDAzZjY3YWZlMGZlYTNmNDdhZjQ4NDg1NTNkNzMwODk3Yzc3MzA1NjlmNGIwZDc2MTdhMjc4ZDdhY2Y3NTA4Mjk4YSIsImp0aSI6Imp3dCBpZCJ9.0QkMWqik3hdVhCkEXI6PKomojkVj4UMy60gmnarpjInKIIJCkCZDdmYz5lHvlBWOiAY65LKke_JHoK3karW58QA'
}
}

issuer doesn't have name property

I see that you are setting JWT specific properties as well as VC properties in the payload.

Veramo automatically computes the JWT properties from the corresponding VC properties, but it can be confused if both of them are present.

Try to use only VC props, don't use the aud, exp, nbf, sub, iss, iat, jti...

@mirceanis
const vcPayload = {
vc: {
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
type: [ 'VerifiableCredential' ],
credentialSubject: {
degree: {
type: 'BachelorDegree',
name: 'Baccalauréat en musiques numériques'
}
},
id: 'http://localhost:9090/did/vc/123', // vc id
issuer: { id: issuer.did, name: 'test'}
}
}

result is

verifiableCredential: {
vc: { id: 'http://localhost:9090/did/vc/123', issuer: [Object] },
credentialSubject: { degree: [Object] },
issuer: {
id: 'did:ethr:0x1e240:0x03f67afe0fea3f47af4848553d730897c7730569f4b0d7617a278d7acf7508298a'
},
type: [ 'VerifiableCredential' ],
'@context': [ 'https://www.w3.org/2018/credentials/v1' ],
proof: {
type: 'JwtProof2020',
jwt: 'eyJhbGciOiJFUzI1NkstUiIsInR5cCI6IkpXVCJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImRlZ3JlZSI6eyJ0eXBlIjoiQmFjaGVsb3JEZWdyZWUiLCJuYW1lIjoiQmFjY2FsYXVyw6lhdCBlbiBtdXNpcXVlcyBudW3DqXJpcXVlcyJ9fSwiaWQiOiJodHRwOi8vbG9jYWxob3N0OjkwOTAvZGlkL3ZjLzEyMyIsImlzc3VlciI6eyJpZCI6ImRpZDpldGhyOjB4MWUyNDA6MHgwM2Y2N2FmZTBmZWEzZjQ3YWY0ODQ4NTUzZDczMDg5N2M3NzMwNTY5ZjRiMGQ3NjE3YTI3OGQ3YWNmNzUwODI5OGEiLCJuYW1lIjoidGVzdCJ9fSwiaXNzIjoiZGlkOmV0aHI6MHgxZTI0MDoweDAzZjY3YWZlMGZlYTNmNDdhZjQ4NDg1NTNkNzMwODk3Yzc3MzA1NjlmNGIwZDc2MTdhMjc4ZDdhY2Y3NTA4Mjk4YSJ9.vSsalzD1YP4iTWiLBCDPfjPazhUsQjzqy2u4ekZPXIUGpxuYcgXfz7uaIc9NmzwW9cXyG3xiaDIi9_kFepdvBQE'
}
}

it still doesn't have issuer name....

What is in the vc.issuer property?

@mirceanis
https://www.w3.org/TR/vc-data-model/#example-usage-of-issuer-expanded-property

"issuer": {
"id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
"name": "Example University"
},

i was trying to get like this
but result of verify doesn't have issuer as it

I think I understand what you mean now, and I think it is a bug in the library that parses the credentials into this format, did-jwt-vc.
The bug is that issuer claims are not interpreted at the top level issuer property and remain nested in the vc.issuer property when parsing JWT credentials.

ok i see
thank you for answering my question
have a good day

Thanks for raising this issue. If you want to continue to push for a fix, can you please create an issue in https://github.com/decentralized-identity/did-jwt-vc?