mattrglobal/jsonld-signatures-bbs

deriveProof prints out @graph property

picardcapt1212 opened this issue · 2 comments

Hi, Im testing selective disclosure with jsonld-signatures-bbs. package version was 1.0.0

I have made an custom context and based on this I issued verifiable credential and derivedProof.
But when I get derivedProof I get @graphproperty which i didnt expect.

The context I made is below:

{
    "@context": {
        "@version": 1.1,
        "@protected": true,
        "Route": {
            "@id": "http://127.0.0.1:4000/Credentials.jsonld#Route",
            "@context": {
                "@version": 1.1,
                "@protected": true,
                "id": "@id",
                "type": "@type",
                "url": "http://127.0.0.1:4000/vocab.json#",
                "vcId": "url:vcId",
                "locations": "url:locations",
                "school": "url:school",
                "residencenumber": "url:residencenumber",
                "phone": "url:phone",
                "account": "url:account",
                "balance": "url:balance"
            }
        }
    }
}

The verifiable credential i issued is below:

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    "https://w3id.org/security/bbs/v1",
    "http://127.0.0.1:4000/Credentials.jsonld"
  ],
  "id": "http://THISISVERIFIABLECREDENTIAL",
  "vcId": "19f92489-ba85-454f-bbb1-7c60c274c9b9",
  "type": [
    "VerifiableCredential",
    "Route"
  ],
  "issuer": "did:lit:Aqu1wif79W85PYmbMTS8xQ",
  "issuanceDate": "2019-12-03T12:19:52Z",
  "expirationDate": "2029-12-03T12:19:52Z",
  "credentialSubject": {
    "id": "did:lit:PCKeVwajdP7rWB7jwhpgWh",
    "type": "Route",
    "locations": "지역입니다",
    "school": "한국대학교",
    "residencenumber": "980418-1837465",
    "phone": "010-1234-5678",
    "account": "1002-304-014683",
    "balance": "100,000,000,000"
  },
  "proof": {
    "type": "BbsBlsSignature2020",
    "created": "2022-02-22T01:59:03Z",
    "proofPurpose": "assertionMethod",
    "proofValue": "j+BIRab6S9Aoc+NwdeciyNM1fvc4jQsGKH7wN/npLWH3wKTLO5cgcHccb1dACyuUPAdPA+cMPODTF++z18ulQZ1MbM8axO1BE3jIDp8yykswqQHTCDAh04ozY00G6uh7zmZnBfzmxDZvsEMUAelVMw==",
    "verificationMethod": "did:lit:Aqu1wif79W85PYmbMTS8xQ#101"
  }
}

The deriveProofFrame I used is below:
I only want to disclose account.

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://w3id.org/security/bbs/v1",
        "http://127.0.0.1:4000/Credentials.jsonld"
    ],
    "type": ["VerifiableCredential", "Route"],
    "credentialSubject": {
        "@explicit": true,
        "type": "Route",
        **"account"**: {}
    }
}

And when i created derivedProof, I got this result:

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    "https://w3id.org/security/bbs/v1",
    "http://127.0.0.1:4000/Credentials.jsonld"
  ],
  **"@graph"**: [
    {
      "id": "did:lit:PCKeVwajdP7rWB7jwhpgWh",
      "type": "Route",
      "account": "1002-304-014683",
      "balance": "100,000,000,000",
      "locations": "지역입니다",
      "phone": "010-1234-5678",
      "residencenumber": "980418-1837465",
      "school": "한국대학교",
      "https://www.w3.org/2018/credentials#credentialSubject": null
    },
    {
      "id": "http://THISISVERIFIABLECREDENTIAL",
      "type": [
        "Route",
        "VerifiableCredential"
      ],
      "vcId": "19f92489-ba85-454f-bbb1-7c60c274c9b9",
      "credentialSubject": {
        "id": "did:lit:PCKeVwajdP7rWB7jwhpgWh",
        "type": "Route",
        "account": "1002-304-014683"
      },
      "expirationDate": "2029-12-03T12:19:52Z",
      "issuanceDate": "2019-12-03T12:19:52Z",
      "issuer": "did:lit:Aqu1wif79W85PYmbMTS8xQ"
    }
  ],
  "proof": {
    "type": "BbsBlsSignatureProof2020",
    "created": "2022-02-22T01:59:03Z",
    "nonce": "nZy2vfxJFWbCHTob8DR0wztFwKvgiWDmszchmLn4vnREgZubm4rH+rETl12Vb9WUsm8=",
    "proofPurpose": "assertionMethod",
    "proofValue": "ABID//+Fd9gW1RMiaeTY0zt6plLyKP3GUfWJAWrQ8LOjeRY3jPWiNbwg8KBNM0ayzh7C60+CCmHr1u6BWNbcaBK9p7cMJkA54DRpurDdm9rwf+D7PgYyFN4nPcfUJG5FojllfMONFyNY4bSaP0LzBUnC9+AmSyfO/3jrW7bH1KK2PSAMwUVTfNVbCZlKdJTNuPhrHRAAAAB0k/8ZGllSOeAxKm2/GwN9fN0UVlNCZype/0uDgXp/0Tt+0FavqiNQWsE2c6U7bZwoAAAAAg4aMf2AgUt2Xa7jKwA5pnzYRzeGz61Xje6h0W29u51RQFPlyIkVqZAJ3n/3mfgvV/yua+tiDYTKN1r3FIKRrj6GiybSg9rg4NgsYtjliFWhpgQruAWrg/88MiKBr3KHH45d4S4dDP6L0ngi03MK8igAAAACCZh6LZl3qf13Ja4eg8phEuXpfJClU5TYhyphkrWmb/seo754dSiuqwIiwZiAozF+OXPr1+wUIPxkpnPRk/iU8g==",
    "verificationMethod": "did:lit:Aqu1wif79W85PYmbMTS8xQ#101"
  }
}

So, My question is:

In the deriveProofFrame I only pointed out "account": {} value. But the derivedProof result I see has @graphproperty. It has the derivedProof I wanted, but also has all the credential subject information.

I guess the the first array(@graph[0]) object is the verifiable credential. And the second array(@graph[1]) object is the derivedProof that I actually wanted.

Is there something wrong I am doing?

Thanks!

The main issue is that in the frame, you're including the "Route" type in the top level which is indicating to the Frame API that you want to match on node types. Since there's two potential subgraphs that can be generated from these which rely on different contexts it causes the odd behavior that you're seeing with your frame.

Change your frame to this without making changes to the context or the VC and it will work. Note the gist.github.com URL is the same context as the one you provided, but I put it in a gist so that I could use it on https://json-ld.org/playground

Here's the example I used to work with modifying the frame.

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://w3id.org/security/bbs/v1",
    "https://gist.githubusercontent.com/kdenhartog/2b6a22c1d9d4f92600f671465e697e8e/raw/ddce70abc65a7aef1ffc6c4ab9b230415d6834e0/playground.jsonld"
    ],
    "type": ["VerifiableCredential"],
    "credentialSubject": {
        "@explicit": true,
        "type": "Route",
        "account": {}
    },
   "proof": {}
}

@kdenhartog Thank you!
I guess my deriveProofFrame or context was wrong haha.

�I solved the problem as in the following way.

  1. Remove Route in "type":["VerifiableCredential", "Route"] as you said. (With the same context!)
{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://w3id.org/security/bbs/v1",
    "https://gist.githubusercontent.com/kdenhartog/2b6a22c1d9d4f92600f671465e697e8e/raw/ddce70abc65a7aef1ffc6c4ab9b230415d6834e0/playground.jsonld"
    ],
    "type": ["VerifiableCredential"],
    "credentialSubject": {
        "@explicit": true,
        "type": "Route",
        "account": {}
    },
   "proof": {}
}
  1. Change the context with new type property which is RouteCredential
{
    "@context": {
        "@version": 1.1,
        "@protected": true,
        "RouteCredential": {
            "@id": "http://127.0.0.1:4000/Credentials.jsonld#RouteCredential",
            "@context": {
                "@version": 1.1,
                "@protected": true,
                "id": "@id",
                "type": "@type",
                "vcId": "url:vcId"
            }
        },
        "Route": {
            "@id": "http://127.0.0.1:4000/Credentials.jsonld#Route",
            "@context": {
                "@version": 1.1,
                "@protected": true,
                "id": "@id",
                "type": "@type",
                "url": "http://127.0.0.1:4000/vocab.json#",
                "locations": "url:locations",
                "school": "url:school",
                "residencenumber": "url:residencenumber",
                "phone": "url:phone",
                "account": "url:account",
                "balance": "url:balance"
            }
        }
    }
}

And I also tested with the context you gave me And it worked well. Thank you :)
("https://gist.githubusercontent.com/kdenhartog/2b6a22c1d9d4f92600f671465e697e8e/raw/ddce70abc65a7aef1ffc6c4ab9b230415d6834e0/playground.jsonld").

I will close this issue. Thanks :)