cardano-db-sync icon indicating copy to clipboard operation
cardano-db-sync copied to clipboard

DB-Sync mistakenly requires a hash for CIP-119 'data:image'

Open dmitrystas opened this issue 1 year ago • 3 comments

Table off_chain_vote_fetch_error has the following error

Error Offchain Voting Anchor: JSON decode error from when fetching metadata from Just https://ipfs.io/ipfs/QmVc6RwPSRtEPbLSZPbRQX65RyfB4y9ar2kwU5Ku97McVr resulted in : "Error in $.body.image: parsing Cardano.DbSync.OffChain.Vote.Types.Image(Image) failed, key \"sha256\" not found, CIP-100:Error in $: key \"authors\" not found"

Mainly that's fine, but there are some metadata like this one https://ipfs.io/ipfs/QmVc6RwPSRtEPbLSZPbRQX65RyfB4y9ar2kwU5Ku97McVr where

"image": {
    "@type": "ImageObject",
    "contentUrl": "data:image/...."
}

Due to CIP-119 sha256 property MUST be populated with the SHA256 hash only If the imageObject DOES NOT contain a base64 encoded image.

If the imageObject DOES NOT contain a base64 encoded image, the contentUrl MUST contain the URL where the image can be found and the sha256 property MUST be populated with the SHA256 hash of the image file contents found at the contentUrl. The SHA256 hash is needed in order for readers to verify that the image has not been altered since the metadata anchor was submitted on-chain.

There is no need to check hash of data:image, since the image is in the chain and cannot be changed

dmitrystas avatar Sep 14 '24 18:09 dmitrystas

Indeed we should avoid errors in that case. But I find the CIP a big vague. What does

If the imageObject DOES NOT contain a base64 encoded image

it mean? contain in what key and with any data uri encoding?

kderme avatar Sep 17 '24 13:09 kderme

contain in what key and with any data uri encoding?

image

imageObject contains a base64 encoded image in its contentUrl property in a dataURI format

dmitrystas avatar Sep 17 '24 13:09 dmitrystas

With https://github.com/IntersectMBO/cardano-db-sync/pull/1860 metadata like this are accepted, the off_chain_drep_data.image_url now includes the image base64 (with the data uri header prefix stripped) and the off_chain_drep_data.image_sha256 remains empty.

kderme avatar Sep 17 '24 18:09 kderme