Public Key Missing During W3C JsonLd Credential Signing
Opened this issue · 0 comments
I'm encountering an issue where the publicKey
field is not processed correctly during the signing of a W3C JSON-LD Credential. The signing process fails with an error indicating that the verification method is missing the publicKeyBase58
. Below are the logs and relevant code snippets:
Error Logs:
Error signing credential: CredoError: verification method is missing publicKeyBase58
at getKeyFromEd25519VerificationKey2018 (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/dids/domain/verificationMethod/Ed25519VerificationKey2018.ts:42:2)
at Object.getKeyFromVerificationMethod (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/dids/domain/key-type/ed25519.ts:36:50)
at getKeyFromVerificationMethod (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/dids/domain/key-type/keyDidMapping.ts:101:17)
at W3cJsonLdCredentialService.getPublicKeyFromVerificationMethod (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/vc/data-integrity/W3cJsonLdCredentialService.ts:346:45)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at W3cJsonLdCredentialService.signCredential (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/vc/data-integrity/W3cJsonLdCredentialService.ts:57:24)
at W3cCredentialService.signCredential (/home/ubu/Escritorio/Workeito/node_modules/@credo-ts/core/src/modules/vc/W3cCredentialService.ts:65:22)
at isscred (/home/ubu/Escritorio/Workeito/src/App/controllers/maincontroller.ts:140:7) {
[cause]: undefined
}
DEBUG: Closing wallet Issuer_Wallet
Code for Signing the Credential:
const signCredentialOptions: W3cJsonLdSignCredentialOptions = {
format: ClaimFormat.LdpVc,
credential: credential,
verificationMethod: dids[0].didDocument!.verificationMethod![0].id,
proofType: 'DataIntegrityProof',
proofPurpose: 'VerificationMethod',
created: new Date().toISOString(),
};
await w3cCredentialServ
.signCredential(User.context, signCredentialOptions)
.then((signedCredential) => {
console.log('Credential signed successfully:', signedCredential);
res.send(signedCredential);
})
.catch((error) => {
console.error('Error signing credential:', error);
});
Verification Method:
{
"id": "did:web:localhost%3A5000:entity#z6Mku12qrBKWcBtkDwFxFc5Uc3ZcrCpuQMVVJmb3n3J8it9S",
"type": "Ed25519VerificationKey2018",
"controller": "did:web:localhost%3A5000:entity",
"publicKeyBase58": "FYmoFw55GeQH7SRFa37dkx1d2dZ3zUF8ckg7wmL7ofN4"
}
Even though the publicKey
is present in the input DID document, it seems to be missing when the signing function attempts to retrieve it. The issue arises in the following function where it fails to retrieve the public key:
async getPublicKeyFromVerificationMethod(agentContext, verificationMethod) {
const documentLoader = this.w3cCredentialsModuleConfig.documentLoader(agentContext);
const verificationMethodObject = await documentLoader(verificationMethod);
const verificationMethodClass = utils_1.JsonTransformer.fromJSON(
verificationMethodObject.document,
dids_1.VerificationMethod
);
const key = key_type_1.getKeyFromVerificationMethod(verificationMethodClass);
return key;
}
Here is the value of verificationMethodObject
when running this function, and as you can see, the publicKey
is missing:
{
"@context": "https://w3id.org/did/v1",
"id": "did:web:localhost%3A5000:entity#z6Mku12qrBKWcBtkDwFxFc5Uc3ZcrCpuQMVVJmb3n3J8it9S",
"type": "Ed25519VerificationKey2018",
"controller": "did:web:localhost%3A5000:entity"
}
Expected Behavior:
The publicKey
should be included in the verification method object and used in the signing process.
Actual Behavior:
The publicKey
is missing, which causes the signing process to fail with the error message: verification method is missing publicKeyBase58
.