Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using different keys for VC issuance vs VP signing causes VerificationError #103

Open
xtrycatchx opened this issue Jul 27, 2021 · 2 comments

Comments

@xtrycatchx
Copy link

xtrycatchx commented Jul 27, 2021

The tests when being run always uses the same KP for VC issuance and VP signing/verification.

Using a different KP for issuance will result in the presentationResult part as verified but failed in the :

{
    "presentationResult": {
      "verified": true,
      "results": [
        {
          "proof": {
            "@context": [
              "https://www.w3.org/2018/credentials/v1"
            ],
            "type": "Ed25519Signature2018",
            "created": "2021-07-27T10:53:44Z",
            "verificationMethod": "did:holder:123456789abcdefghi#keys-1",
            "proofPurpose": "authentication",
            "challenge": "a39bacda-48a8-4720-9cf4-5cdbdf824d99",
            "jws": "eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..ihKWlt4DAkthlihI0wtAkL7A5e4hOQvBuXSzUEEzQ-rZSLBBn5hqrWS4R8OA3O8ANgogWbR37eKDwqK92jgwDA"
          },
          "verified": true,
          "verificationMethod": {
            "id": "did:holder:123456789abcdefghi#keys-1",
            "type": "Ed25519VerificationKey2018",
            "controller": "did:holder:123456789abcdefghi",
            "publicKeyBase58": "2hhMV8pKDjZt68JZSr82rCycTrT5eYoWvNJW6qZCEbcK"
          },
          "purposeResult": {
            "valid": true,
            "controller": {
              "@context": "https://www.w3.org/ns/did/v1",
              "id": "did:holder:123456789abcdefghi",
              "authentication": [
                {
                  "id": "did:holder:123456789abcdefghi#keys-1",
                  "type": "Ed25519VerificationKey2018",
                  "controller": "did:holder:123456789abcdefghi",
                  "publicKeyBase58": "2hhMV8pKDjZt68JZSr82rCycTrT5eYoWvNJW6qZCEbcK",
                  "privateKeyBase58": "8Z9GD2nrZS2gEMX9JFqTSzpbxbnMxGbEffcvgUccpjwiE2QC4DPo1gGdie38ovT1H5Pr1uzLvMaNvUNMvGuea47"
                }
              ]
            }
          }
        }
      ]
    },
    "verified": false,
    "credentialResults": [
      {
        "verified": false,
        "error": {
          "name": "VerificationError",
          "errors": [
            {
              "name": "NotFoundError",
              "message": "Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).",
              "stack": "NotFoundError: Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).\n    at ProofSet.verify (C:\\Users\\batman\\try-vc-js\\vc-js\\node_modules\\jsonld-signatures\\lib\\ProofSet.js:152:23)\n    at async Object.verify (C:\\Users\\batman\\try-vc-js\\vc-js\\node_modules\\jsonld-signatures\\lib\\jsonld-signatures.js:114:18)\n    at async _verifyCredential (C:\\Users\\batman\\try-vc-js\\vc-js\\lib\\vc.js:271:18)\n    at async Promise.all (index 0)\n
    at async _verifyPresentation (C:\\Users\\batman\\try-vc-js\\vc-js\\lib\\vc.js:408:25)\n    at async run (C:\\Users\\batman\\try-vc-js\\digital-bazaar-experiment\\experiment.js:189:18)"
            }
          ]
        },
        "credentialId": "http://example.edu/credentials/74d888fc-720d-41eb-bb29-5e6c84e572f8"
      }
    ]
  }

snippet for issuance:

 const verifiableCredential = await vc.issue({
    credential: mockCredential,
    suite: suiteOfIssuer
  });

snippet for presentation:

const presentation = vc.createPresentation({
    verifiableCredential: mockCredential,
    // id: "ebc6f1c2",
    // holder: "did:ex:holder123",
  });

  const challenge = uuid();

  const vp = await vc.signPresentation({
    presentation,
    suite: suiteOfHolder,
    // suite: suiteOfIssuer,
    challenge,
    // documentLoader: documentLoader,
  });

snippet for failing verify:

const result = await vc.verify({
    challenge,
    suite: suiteOfHolder,
    // suite: suiteOfIssuer,
    documentLoader,
    presentation: vp,
  });

but manual credential verification works:

const result2 = await vc.verifyCredential({
      credential: jsonld.clone(vp.verifiableCredential[0]),
      suite: suiteOfIssuer,
      documentLoader,
    });
@xtrycatchx
Copy link
Author

Actually, I missed to add the suite of the issuer for the verification part ( I'm on the assumption the keys can be resolved from documentLoader )

having this works now

const result = await vc.verify({
    challenge,
    suite: [suiteOfHolder, suiteOfIssuer],
    documentLoader,
    presentation: vp,
  });

best if we don't share the private keys from the suites

const holderPubKey = await keyPairOfHolder.export({ publicKey: true })
const issuerPubKey = await keyPairOfIssuer.export({ publicKey: true })

const result = await vc.verify({
    challenge,
    suite: [
      new Ed25519Signature2018({
        key: new Ed25519VerificationKey2018(holderPubKey),
      }),
      new Ed25519Signature2018({
        key: new Ed25519VerificationKey2018(issuerPubKey),
      }),
    ],
    documentLoader,
    presentation: vp,
  });

but why do we need the options.suite in the vc.verify? Can't it be just retrieved from options.documentLoader ?

Tnx

@bishalkc
Copy link

bishalkc commented Jan 4, 2022

Actually, I missed to add the suite of the issuer for the verification part ( I'm on the assumption the keys can be resolved from documentLoader )

having this works now

const result = await vc.verify({
    challenge,
    suite: [suiteOfHolder, suiteOfIssuer],
    documentLoader,
    presentation: vp,
  });

best if we don't share the private keys from the suites

const holderPubKey = await keyPairOfHolder.export({ publicKey: true })
const issuerPubKey = await keyPairOfIssuer.export({ publicKey: true })

const result = await vc.verify({
    challenge,
    suite: [
      new Ed25519Signature2018({
        key: new Ed25519VerificationKey2018(holderPubKey),
      }),
      new Ed25519Signature2018({
        key: new Ed25519VerificationKey2018(issuerPubKey),
      }),
    ],
    documentLoader,
    presentation: vp,
  });

but why do we need the options.suite in the vc.verify? Can't it be just retrieved from options.documentLoader ?

Tnx

Were you able to resolve this? I am now experiencing same. vc.verifyCredential and vc.verify (presentation) with IssuerSuite works but cant get it working with holder and also get the proof check by verifier? any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants