-
Notifications
You must be signed in to change notification settings - Fork 18
Description
-
I'm submitting a ...
[x] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project -
Summary
According to the note here you need to decode the sd-jwt in case the hasher function is async (which is in my canse since its executed in the browser via webcrypto). So I am decoding the list of credentials like this:
const vcs: SdJwtDecodedVerifiableCredential[] = [];
for (const credential of credentials) {
const decoded = await CredentialMapper.decodeSdJwtVcAsync(
credential.value,
getHasher()
);
vcs.push(decoded);
}
const pex = new PresentationExchange({
allVerifiableCredentials: vcs,
});
But then I am running in this error Hasher must be provided when creating a presentation with an SD-JWT VC. After logging the credentials and the conditions I get this:
{"compactSdJwtVc":"eyJ0eXAiOiJ2YytzZC1qd3QiLCJhbGciOiJFZERTQSJ9.eyJpYXQiOjE3MTIwOTI0NzU1MjUsImlzcyI6Iklzc3VlciIsInZjdCI6IklkZW50aXR5IiwianRpIjoiNzE2OTBiOTItYjI1My00OGFiLThlNjctMjFkYzAzN2I2YWY0IiwiY25mIjp7ImtpZCI6ImRpZDpqd2s6ZXlKcmRIa2lPaUpGUXlJc0luZ2lPaUpCY1hSQmMzVlFRMnN5WVd4cmNVazBaRkZpVUdaQlpHWnRNMHN5TFRZdGNVbE9WRVJ5YUZoaFJFazBJaXdpZVNJNklsaEJVVWh2UzBWdGVHWnRiVkZXUldoQ0xVcFlVMXBMV0VWa1JHSjVha3BpVEZacE5WbGxRMEZvVHpBaUxDSmpjbllpT2lKUUxUSTFOaUo5IzAifSwiX3NkIjpbIkdEdEIweTg5ZzRmMzJBeUhzU2F4N0pHbDA2VkhlV2IxZVozZXloZ0dsN0UiLCJsdW5zQjJ5a3pQVEowd0NKYlZndlpaV3BsUUktOFpnRW1QNjV2X1o5N1IwIl0sIl9zZF9hbGciOiJTSEEtMjU2In0.wmwlrsfXYa-B15yPRTjCulWNBeWLHxIjVynKN0UgIBatzGcmloWENCVBSLPYt1xc-o0ueYyemKDa8icOaPPu1w~WyJhZmE3Mzg2OTMzOTJlOTE3IiwicHJlbmFtZSIsIk1pcmtvIl0~WyI1NzcxYjhiMDA5YzMxMzMzIiwic3VybmFtZSIsIk1vbGxpayJd~","decodedPayload":{"iat":1712092475525,"iss":"Issuer","vct":"Identity","jti":"71690b92-b253-48ab-8e67-21dc037b6af4","cnf":{"kid":"did:jwk:eyJrdHkiOiJFQyIsIngiOiJBcXRBc3VQQ2syYWxrcUk0ZFFiUGZBZGZtM0syLTYtcUlOVERyaFhhREk0IiwieSI6IlhBUUhvS0VteGZtbVFWRWhCLUpYU1pLWEVkRGJ5akpiTFZpNVllQ0FoTzAiLCJjcnYiOiJQLTI1NiJ9#0"},"prename":"Mirko","surname":"Mollik"},"disclosures":[{"decoded":["afa738693392e917","prename","Mirko"],"digest":"GDtB0y89g4f32AyHsSax7JGl06VHeWb1eZ3eyhgGl7E","encoded":"WyJhZmE3Mzg2OTMzOTJlOTE3IiwicHJlbmFtZSIsIk1pcmtvIl0"},{"decoded":["5771b8b009c31333","surname","Mollik"],"digest":"lunsB2ykzPTJ0wCJbVgvZZWplQI-8ZgEmP65v_Z97R0","encoded":"WyI1NzcxYjhiMDA5YzMxMzMzIiwic3VybmFtZSIsIk1vbGxpayJd"}],"signedPayload":{"iat":1712092475525,"iss":"Issuer","vct":"Identity","jti":"71690b92-b253-48ab-8e67-21dc037b6af4","cnf":{"kid":"did:jwk:eyJrdHkiOiJFQyIsIngiOiJBcXRBc3VQQ2syYWxrcUk0ZFFiUGZBZGZtM0syLTYtcUlOVERyaFhhREk0IiwieSI6IlhBUUhvS0VteGZtbVFWRWhCLUpYU1pLWEVkRGJ5akpiTFZpNVllQ0FoTzAiLCJjcnYiOiJQLTI1NiJ9#0"},"_sd":["GDtB0y89g4f32AyHsSax7JGl06VHeWb1eZ3eyhgGl7E","lunsB2ykzPTJ0wCJbVgvZZWplQI-8ZgEmP65v_Z97R0"],"_sd_alg":"SHA-256"}}
isdecoded true
isEncoded false
So is the intention of if (credentials.some((c) => CredentialMapper.isSdJwtDecodedCredential(c) || CredentialMapper.isSdJwtEncoded(c))) { to only get the sd-jwt-vc credentials, the error seems to be here.
To avoid the hash call in the function, we need to pass the pre calculated sdHash in the SdJwtDecodedVerifiableCredential object.
Or we just make the hasher call async since PresentationExchange.findValidPresentationDefinitions is already async :)