eclipse-edc / eclipse-edc/Connector

Problem verifying credential when DID document has multiple keys

Open
#4,943 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
424
Forks
300
Avg merge
13h 11m
Merged PRs (30d)
35

Description

# Bug Report

## Describe the Bug

When resolving the key from the issuers did document, the first key is always resolved (ldpVerifier).

### Expected Behavior

If the did document of the issuer has multiple public keys, the key that was specified as verificationmethod in the ldp credential should be used for verification

### Observed Behavior

Instead, the first key in the document is used

## Steps to Reproduce

Steps to reproduce the behavior:

1. create did document with multiple keys
2. define a ldp credential where the verificationmethod in the proof is a key in the did which is not the first key
3. try transfer

## Context Information

_Add any other context about the problem here._

- Used version [e.g. EDC v1.0.0]
- OS: [e.g. iOS, Windows]
- ...

## Detailed Description

If the did document has multiple keys and you have specified one of the lower keys as verificationmethod in the proof segment, then the first key is still used for verification, which end in an invalid signature error

## Possible Implementation
I think the problem is in [DidMethodResolver.java](https://github.com/eclipse-edc/Connector/blob/2591d083d9668bf3e78750988361be632a9dd35a/extensions/common/crypto/ldp-verifiable-credentials/src/main/java/org/eclipse/edc/verifiablecredentials/linkeddata/DidMethodResolver.java#L39). Here the first of the verificationmethods in the did document is taken. I think that instead the first one, the one which equals the id must be taken as verificatioMethod.
```.filter(keypair -> keypair.id().equals(id))```
before the findFirst() should fix the problem

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.