Skip to content

Data authenticity

Mathieu edited this page Jun 8, 2022 · 11 revisions

How the event's certification is carried out

Endpoint

The endpoint /blockchains/verify/events/:ProductId

Verification key points

The method verifyEvents(id) will verify if the event's products within the blockchain are the same than the event's within our database.

To compare it, we use JSON.stringify as :

if (JSON.stringify(a) === JSON.stringify(b)) {
  console.log('✅ objects are equal');
          ....
}

If the objects are equals, the creator's public_key of the event will be recovered. We use handy methods like getAssets() and getTransactions() to recover it.

Ultimately, the public_key will be test with the method CertifyPublicKey(). In the case of an approuved public key, the tag certified = true will be thrown.

Example

Certified value

{
    "id": "cl45o0ij000197wwkha048z8q",
    "content": "A product has been created",
    "createdAt": "2022-06-08T14:07:21.036Z",
    "productId": "cl45o0i6s00097wwk1qrj8feg",
    "eventTypeId": "cl440e96v0003zowk9zypp237",
    "eventCommercialId": null,
    "eventType": {
        "id": "cl440e96v0003zowk9zypp237",
        "content": "PRODUCT_CREATED",
        "slug": "Created"
    },
    "certified": true
}

Uncertified | corropted value

{
    "id": "cl45o0ij000197wwkha048z8q",
    "content": "A product has been created",
    "createdAt": "2022-06-08T14:07:21.036Z",
    "productId": "cl45o0i6s00097wwk1qrj8feg",
    "eventTypeId": "cl440e96v0003zowk9zypp237",
    "eventCommercialId": null,
    "eventType": {
        "id": "cl440e96v0003zowk9zypp237",
        "content": "PRODUCT_CREATED",
        "slug": "Created"
    },
    "certified": false
}

Clone this wiki locally