How to add custom additional fields - BlockcertValidationError

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

1 Like

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.

1 Like

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.

1 Like

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.

Is this solved? We would like to add a custom field to the CSV file

Do you have any examples on how to inser the name of the recipient in the displayHTML field? Thank you!

Is it any document available to add additional fields? I tried to add additional fields but after adding additional field and create template, template created but got following while verify the json. Where(json path) I need to add my additonal field in the json. How to configure additional fiels on conf.ini file properly?

0|Blockcer | File “/usr/local/lib/python3.6/dist-packages/cert_core-2.1.9-py3.6.egg/cert_core/cert_model/model.py”, line 382, in to_certificate_model

0|Blockcer | raise InvalidCertificateError(‘V1.1 Blockchain Certificates require a transaction id and raw bytes’)

0|Blockcer | cert_core.InvalidCertificateError: V1.1 Blockchain Certificates require a transaction id and raw bytes

0|Blockcer | /usr/local/lib/python3.6/dist-packages/merkletools-1.0.2-py3.6.egg/merkletools/init.py:7: UserWarning: sha3 is not working!

0|Blockcer | warn(“sha3 is not working!”)

0|Blockcer | Traceback (most recent call last):

0|Blockcer | File “/home/ubuntu/cert-verifier/cert_verifier/verifier.py”, line 59, in

0|Blockcer | result = verify_certificate_file(cert_file)

0|Blockcer | File “/home/ubuntu/cert-verifier/cert_verifier/verifier.py”, line 50, in verify_certificate_file

0|Blockcer | certificate_bytes=certificate_bytes)

0|Blockcer | File “/usr/local/lib/python3.6/dist-packages/cert_core-2.1.9-py3.6.egg/cert_core/cert_model/model.py”, line 382, in to_certificate_model

0|Blockcer | raise InvalidCertificateError(‘V1.1 Blockchain Certificates require a transaction id and raw bytes’)

0|Blockcer | cert_core.InvalidCertificateError: V1.1 Blockchain Certificates require a transaction id and raw bytes

0|Blockcer | /bin/sh: 1: /home/ubuntu/blockcerts.sh: not found

0|Blockcer | /bin/sh: 1: /home/ubuntu/blockcerts.sh: not found