Skip to content

Avoid duplication of CredentialItem when it answers multiple different CredentialQueries #69

Open

Description

@GarethCOliver

It's possible to have a single credential that answer multiple CredentialQueries. e.g. if one queries says 'I want your address, from a DocType' and another says 'I want your first name, last name' from an DocType'. Lets say, in different scenario sets.

I would then use the same CredentialItem (signed and containing both first name/last name and address) in the response. So the credential response Enveope would look like:

{
credentials: { address_query_id => { my_big_credential}, name_query_id => { my_big_credential } }
scenarios: { address_scenario_id => [ address_query_id], name_scenario_id => [name_query_id] }
}

This is the same as what OpenID4VP does, but we can do better if we just do:
(rename CredentialRef => QueryRef as it is a reference to a query not a credential)

Envelope: {
  credentials: 1 => { +CredentialRef => CredentialItem} 
  queries: 2 => { +QueryRef => CredentialRef }
  scenarios: 3=> { + ScenarioRef => [ QueryRef ] } 
}

CredentialRef = int

Now we would be able to return the above as:
{
credentials: { cr_1 => { my_big_credential} }
queries: { address_query_id => { cr_1}, name_query_id => { cr_1 } }
scenarios: { address_scenario_id => [ address_query_id], name_scenario_id => [name_query_id] }
}

which avoids duplicating it (at the cost of having to id-trace).

An alternative option would be to allow CredentialItem to be polymorphic, and able to return a 'CredentialRef' instead of the exact value, indicating which query the credential will be found in.

Activity

  1. martijnharing commented on Oct 8, 2026

    @martijnharing
    Collaborator

    Okay, so I read the other issue (#70) first and made the response there, But I think the solutions I mentioned there address this issue right?
    Your solution also works. In general I like the rename to QueryRef to what's in the current text called credentialRef.

    Should we merge this issue and #70? If we do that, I think the choice should be between:

    Your option (I made the change to support allow_multiple)

    Envelope: {
      credentials: 1 => { +CredentialRef => [+CredentialItem]} 
      queries: 2 => { +QueryRef => CredentialRef }
      scenarios: 3=> { + ScenarioRef => [ QueryRef ] } 
    }
    
    CredentialRef = int
    
    CredentialItem = {
      format:          1 => tstr,
      data:            2 => Document / ZkDocument / SdJwtData,
    }
    

    Option 2 from #70 (with the change to queryref)

    Envelope = {
      credentials:  1 => [ + CredentialItem ],
      scenarios:    2 => { + ScenarioRef => [ + QueryRef ] },
    }
    
    CredentialItem = {
      format:          1 => tstr,
      data:            2 => Document / ZkDocument / SdJwtData,
      credential_refs: 3 => [ + QueryRef ], 
    }
    
  2. GarethCOliver commented on Oct 12, 2026

    @GarethCOliver
    CollaboratorAuthor

    Yeah, I like your Option 2 better as well, it's nicer than being polymorphic, and keeps the simple cases simpler (rather than introducing an extra indirection).

    Makes sense to solve the issues together (I just noticed them both so filed separately for clarity).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions