Skip to content

Data authenticity

Mathieu edited this page Jun 13, 2022 · 11 revisions

How the event's certification is carried out

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 like :

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

If the objects are equal, the creator's public_key of the event will be recovered. For that, 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 within the event object.

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 | Corrupted 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
}

How to certify an entity

To certify an entity, the public key of the entity need to be found. After that you could call out the endpoint bellow :

/blockchains/certify/public-key/:publickey

Products and events own the field certifiedBy that returns the public key of the certifiedEntity.

Clone this wiki locally