Skip to content

Data authenticity

Mathieu edited this page Jun 15, 2022 · 11 revisions

How the event's certification is carried out

Verification key points

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

To compare them, we use JSON.stringify like :

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

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().

Ultimately, the public_key will be tested with the method CertifyPublicKey(). If the public key is approved, 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, its public key needs 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