Skip to content

Schema claims are optional, but creating a proof for a credential with optional claims fails #42

Open
@goncalo-frade-iohk

Description

@goncalo-frade-iohk

Hi there.

I found this issue, and as per my understanding a credential issued CAN have any of the claims specified on the schema.

So basically if I got a schema like:

{
    "name": "Driving licence Anoncred Schema",
    "version": "1.0",
    "attrNames": [
        "emailAddress",
        "familyName",
        "dateOfIssuance",
        "drivingLicenseID",
        "drivingClass"
    ],
    "issuerId": "did:test:mock"
}

If then I issue a credential with only "familyName".
The credential is issued successfully, but because of this code, any credential that doest fully have all claims defined of a schema will not be able to create a proof:

let schema_attrs = non_credential_schema
            .attrs
            .union(&cred_schema.attrs)
            .cloned()
            .collect::<BTreeSet<String>>();

        let cred_attrs = BTreeSet::from_iter(cred_values.attrs_values.keys().cloned());

        if schema_attrs != cred_attrs {
            return Err(err_msg!(
                "Credential doesn't correspond to credential schema"
            ));
        }

Here is the location of the code:

if schema_attrs != cred_attrs {

If this logic is correct then IMO a credential cannot be issued without all the claims on a schema, and should fail there.

Metadata

Metadata

Assignees

No one assigned

    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