How to add custom additional fields - BlockcertValidationError


#1

Hello,

I’m trying to create certificates containing custom additional fields. My cert-tools conf.ini contains the following line:
additional_global_fields = {"fields": [{"path": "$.badge.xyz_custom_field","value": "this going to contain some data"}]}

When trying to execute the cert-issuer I get the following error:
cert_schema.schema_tools.schema_validator.BlockcertValidationError: There are some fields in the certificate that do not correspond to the expected schema. This has likely been tampered with. Unmapped fields are: <http://fallback.org/xyz_custom_field>

How can I add a custom additional field both as additional_global_fields and as additional_per_recipient_fields in the cert-tools conf.ini?

I probably have to add a @context because of the canonicalization of the JSON-LD certificate. But how can I do this and do I have to do something else?

Thanks in advance!

Kind regards,
uzu


#2

Hi Uzu,
Yes, that’s exactly right. Each of your new terms has to be defined in a JSON-LD context. You can either point to an existing JSON-LD context, or embed them directly in the context of the certificate. For an example of the latter, see the JSON-LD specification section 3.1. In this case, the @context value would be an array listing the existing context links, and your new definition. Roughly like this:

{
  "@context": [
        "https://w3id.org/openbadges/v2",
        "https://w3id.org/blockcerts/v2",
        {
             "xyz_custom_field": "http://path/to/xyz_custom_field",
              ... // and all other custom fields
        }
    ]
}

This is a doc oversight, so I’m going to create an issue to fix this.


#3

Hi Kim and Uzu,

Can you guys help me understand how to add a custom field in the CSV roster file.I.e. instead of just ‘name’,‘pubkey’,‘identity’ in the file ‘roster_testnet.csv’, I want to add ‘additional1’. I am a little confused by the above.

  • What does it mean by JSON path?

  • Do I still need to add a JSON-LD file for custom recipient fields? If so can this be done as a local file?

  • What is path in the below for, is it to the csv file or the JSON-LD?

additional_per_recipient_fields = {“fields”: [{“path”: “$.xyz_additional”,“value”: “|EVIDENCE|”,“csv_column”: “additional1”}]}

  • Do any other fields have to be filled out e.g. ‘value’ or ‘evidence’?

Thanks.


#4

Hi @jake666 & @uzu;

Did you succeed to create custom field? Could you create an additional field for cert which is verifiable? If you did, could you share steps and structure?

Thanks.