Description
Problem
While verifying credentials i observed a strange behavior: At first it all works well and i could verify on credential after another, but as soon as i tried to verify a credential of another type, i.e. with another context, the verification failed with an ambiguous VerificationError
. The error persists, no matter which context is used first. As soon as the context is switched, the verification fails.
Tracking down the error
After some hours of digging into the digitalbazaar libraries it turned out that the error is actually a JSON-LD safemode validation error where one key word could not get expanded into an IRI. More digging revealed that this has to do with the ContextResolver.js which is used when processing the context in context.js line 87. When looking into the processed context it turned out that always the first key word was missing in the context mappings, causing dropped property. This must happen in the cache, because investigating the process method in context.js line 113 showed, that the particular key word was never return in on the the cached contexts. Further investigation is on course.
Fixes
- Just like in a previous caching issue disabling the static cache fixes the issue completely.
ContextResolver.js line 76
const key = JSON.stringify(ctx);
let resolved = this._get(key);
if(!resolved) {
// create a new static `ResolvedContext` and cache it
resolved = new ResolvedContext({document: ctx});
this._cacheResolvedContext({key, resolved, tag: 'static'}); // <-- disable static cache here by replacing 'static' with undefined
}
- Excluding certain contexts from the shared cache also resolves the issue. I did not try all of them, but disallowing the very basic https://www.w3.org/2018/credentials/v1 already solved the issue.
Used packages:
"@digitalbazaar/ed25519-signature-2020": "^5.0.0",
"@digitalbazaar/vc": "^5.0.0",