Display v3 issue

Hi, me again.

I could embed a pdf into a bunch of tests certificates porperly but, at verify time, Im having troubles with the json ld normalization.

Code: getTransactionId Getting transaction ID - Status: starting
Code: getTransactionId Getting transaction ID - Status: success
Code: computeLocalHash Computing local hash - Status: starting
Code: computeLocalHash Computing local hash - Status: failure
The step computeLocalHash fails with the error: Found unmapped fields during JSON-LD normalization: content, contentEncoding, contentMediaType

I reviewed the contexts included by default in the certs and in one of them (https://w3id.org/blockcerts/schema/3.0/context.json) the display term and its sub-terms: content, contentEncoding, contentMediaType are defined.

Here is one of the test certificates.

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://w3id.org/blockcerts/schema/3.0/context.json",
        "https://www.w3.org/2018/credentials/examples/v1"
    ],
    "type": [
        "VerifiableCredential",
        "BlockcertsCredential"
    ],
    "issuer": "https://6eer.github.io/stunning-chainsaw/issuer.json",
    "issuanceDate": "2022-01-24T14:07:16Z",
    "id": "urn:uuid:c35c6bdd-23a4-488b-8fd4-9c796926876a",
    "credentialSubject": {
        "id": "ecdsa-koblitz-pubkey:13K9BsiSAWzxt7arvEdMYbo4biQGTpWXMW",
        "alumniOf": {
            "id": "https://github.com/6eer"
        }
    },
    "display": {
        "contentMediaType": "application/pdf",
        "contentEncoding": "base64",
        "content": "JVBERi0xLjUKJc [...] pzdGFydHhyZWYKNTAyMDUKJSVFT0YK"
    },
    "nonce": "0",
    "proof": {
        "type": "MerkleProof2019",
        "created": "2022-01-24T11:11:39.174337",
        "proofValue": "zMcm4LfQFUZkWZyLqD7toSCuoLSKksH9Td7iZ4Rq6M4ZyjnaSDdwMcVbLiukvpm86E9aSukBEbzSW9h2jHAxDbjwnprPfqwB4aSD8spRA4AiCmYCY13m9Q1BBw6hGB4sLK7Lt2s91zHZ3dgoS7bb1A5j42S8jsavDjMPYpdHggz9YUq9QYe28HT9c9X7MAkiMuUUa3f2kmbZYWNLXdCjxSxaG8NCcarhYCxc6f2hCpT5NFj8zeCWhN5iQZmF1wBTmq4nkAfu1jyVEGKuXqcbQTGSDgvdHUExfvtBeq1zHcTS1J1Z6iS",
        "proofPurpose": "assertionMethod",
        "verificationMethod": "https://6eer.github.io/stunning-chainsaw/issuer.json"
    }
}

Can you see what Im missing?

thanks,
6eer.

Ok so I’ve found that it’s because the example context is defined after the blockcerts context, if you change the order it’s working. Now I want to understand why this is the case, but at least this can let you move a bit further

1 Like

Ok I have found why, the odlr context that is linked by the VC example context defines a display which overwrites the one from blockcerts context. Now I wanna see if I can fix that, as the display property should point to blockcerts context

1 Like

actually I had faced this issue before and thus, putting the vc example context first is the preferred way: Word retrieved for other context? · Issue #450 · digitalbazaar/jsonld.js · GitHub
If I put @protected to the context, it will throw an error as we are trying to redefine the display property with the ODLR context. It seems somewhat logical to put the Blockcerts context last too, as this is the final say in the what the content of the file is.

1 Like

thanks for the support lemoustachiste, really appreciate it. ill try asap & let you know.

6eer.

Just a question, do you use the python package or the github source code to issue your certs?

I think (im new in python) im using the github repo.

In all the cases i follow the installation steps on the readmes.
To give u an example, on cert-issuer:

git clone https://github.com/blockchain-certificates/cert-issuer.git && cd cert-issuer

python setup.py install

cert-issuer -c conf.ini

This was made on a new conda enviroment (for each github repo cert-tools, cert-issuer) with python 3.10.
After install i had to solve some dependencies issues.

Im kinda abusing of your help here but i had time to try the solution on changing the orders in the context to solve the display issue (i did it manually, in the template made by cert-tools).

The cert after the change

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        "https://www.w3.org/2018/credentials/examples/v1",
        "https://w3id.org/blockcerts/schema/3.0/context.json"
    ],
    "type": [
        "VerifiableCredential",
        "BlockcertsCredential"
    ],
    "issuer": "https://6eer.github.io/stunning-chainsaw/issuer.json",
    "issuanceDate": "2022-01-26T14:47:12Z",
    "id": "urn:uuid:7840f854-aa11-42f9-837e-c05b03e1ea5a",
    "credentialSubject": {
        "id": "ecdsa-koblitz-pubkey:13K9BsiSAWzxt7arvEdMYbo4biQGTpWXMW",
        "alumniOf": {
            "id": "https://github.com/6eer"
        }
    },
    "display": {
        "contentMediaType": "application/pdf",
        "contentEncoding": "base64",
        "content": "JVBERi0xLjUKJcOkw7zD [...] hyZWYKNjQ5OTQKJSVFT0YK"
    },
    "nonce": "0"
}

And when i try to issue it

(issuer) sammy@debian:~/dev/blockcerts-0/cert-issuer$ cert-issuer -c conf.ini

WARNING - Your app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - This run will try to issue on the bitcoin_testnet chain
/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/pycoin-0.80-py3.10.egg/pycoin/contrib/segwit_addr.py:121: SyntaxWarning: "is not" with a literal. Did you mean "!="?
/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/pycoin-0.80-py3.10.egg/pycoin/contrib/segwit_addr.py:121: SyntaxWarning: "is not" with a literal. Did you mean "!="?
/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py:577: SyntaxWarning: "is" with a literal. Did you mean "=="?
/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py:577: SyntaxWarning: "is" with a literal. Did you mean "=="?
INFO - Set cost constants to recommended_tx_fee=0.000600,min_per_output=0.000028,satoshi_per_byte=250
INFO - Processing 1 certificates
INFO - Processing 1 certificates under work path=/home/sammy/dev/blockcerts-0/cert-issuer/data/work
INFO - Total cost will be 133500 satoshis
INFO - Starting finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
INFO - Stopping finalizable signer
WARNING - app is configured to skip the wifi check when the USB is plugged in. Read the documentation to ensure this is what you want, since this is less secure
Traceback (most recent call last):
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1134, in to_rdf
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 835, in expand
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2089, in _expand
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2737, in _process_context
pyld.jsonld.JsonLdError: ('Invalid JSON-LD syntax; @context must be an object.',)
Type: jsonld.SyntaxError
Code: invalid local context
Details: {'context': 'https://w3id.org/blockcerts/schema/3.0/context.json'}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1052, in normalize
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1136, in to_rdf
pyld.jsonld.JsonLdError: ('Could not expand input before serialization to RDF.',)
Type: jsonld.RdfError
Cause: ('Invalid JSON-LD syntax; @context must be an object.',)
Type: jsonld.SyntaxError
Code: invalid local context
Details: {'context': 'https://w3id.org/blockcerts/schema/3.0/context.json'}  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1134, in to_rdf
    expanded = self.expand(input_, options)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 835, in expand
    expanded = self._expand(active_ctx, None, document, options, False)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2089, in _expand
    active_ctx = self._process_context(
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2737, in _process_context
    raise JsonLdError(


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sammy/anaconda3/envs/issuer/bin/cert-issuer", line 33, in <module>
    sys.exit(load_entry_point('cert-issuer==3.0.0', 'console_scripts', 'cert-issuer')())
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/__main__.py", line 17, in cert_issuer_main
    issue_certificates.main(parsed_config)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/issue_certificates.py", line 36, in main
    return issue(app_config, certificate_batch_handler, transaction_handler)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/issue_certificates.py", line 22, in issue
    tx_id = issuer.issue(app_config.chain)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/issuer.py", line 23, in issue
    blockchain_bytes = self.certificate_batch_handler.prepare_batch()
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/certificate_handlers.py", line 110, in prepare_batch
    self.merkle_tree.populate(self.get_certificate_generator())
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/merkle_tree_generator.py", line 34, in populate
    for data in node_generator:
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/certificate_handlers.py", line 120, in get_certificate_generator
    data_to_issue = self.certificate_handler.get_byte_array_to_issue(metadata)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_issuer-3.0.0-py3.10.egg/cert_issuer/certificate_handlers.py", line 15, in get_byte_array_to_issue
    normalized = normalize_jsonld(certificate_json, detect_unmapped_fields=False)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/cert_schema-3.0.2-py3.10.egg/cert_schema/jsonld_helpers.py", line 252, in normalize_jsonld
    normalized = jsonld.normalize(json_ld, options=options)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 249, in normalize
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1054, in normalize
pyld.jsonld.JsonLdError: ('Could not convert input to RDF dataset before normalization.',)
Type: jsonld.NormalizeError
Cause: ('Could not expand input before serialization to RDF.',)
Type: jsonld.RdfError
Cause: ('Invalid JSON-LD syntax; @context must be an object.',)
Type: jsonld.SyntaxError
Code: invalid local context
Details: {'context': 'https://w3id.org/blockcerts/schema/3.0/context.json'}  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1134, in to_rdf
    expanded = self.expand(input_, options)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 835, in expand
    expanded = self._expand(active_ctx, None, document, options, False)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2089, in _expand
    active_ctx = self._process_context(
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 2737, in _process_context
    raise JsonLdError(
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1052, in normalize
    dataset = self.to_rdf(input_, opts)
  File "/home/sammy/anaconda3/envs/issuer/lib/python3.10/site-packages/PyLD-1.0.5-py3.10.egg/pyld/jsonld.py", line 1136, in to_rdf
    raise JsonLdError(

Im doing something wrong? Are we using the same version of PyLD (this is a dependency that i have to downgrade) and/or python?

thanks & sorry for bothering to much,
6eer.

The cert looks good, it could be that it’s not preloaded correctly for jsonld.
Maybe try with this context which would be the preferred way: https://w3id.org/blockcerts/v3

hey, could solve it.

i ended up throwing away the “https://www.w3.org/2018/credentials/examples/v1” context and defining alumniOf inline

{
    "@context": [
        "https://www.w3.org/2018/credentials/v1",
        {
            "alumniOf": {
                "@id": "http://schema.org/alumniOf",
                "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML"
            }
        },
        "https://w3id.org/blockcerts/v3"
    ],
    "type": [
        "VerifiableCredential",
        "BlockcertsCredential"
    ],
    "issuer": "https://6eer.github.io/stunning-chainsaw/issuer.json",
    "issuanceDate": "2022-01-26T14:47:12Z",
    "id": "urn:uuid:7840f854-aa11-42f9-837e-c05b03e1ea5b",
    "credentialSubject": {
        "id": "ecdsa-koblitz-pubkey:13K9BsiSAWzxt7arvEdMYbo4biQGTpWXMW",
        "alumniOf": {
            "id": "https://github.com/6eer"
        }
    },
    "display": {
        "contentMediaType": "application/pdf",
        "contentEncoding": "base64",
        "content": "OTQKJ [...] SVFT0YK"
    },
    "nonce": "0"
}

thanks for the help,
6eer.