Skip to main content

Verification

The verification process is done in the following three steps:

  1. Retrieve an integrity proof
  2. Verify the integrity proof
  3. Validate in blockchain

Those steps can be implemented, using our SDKs, both individually or together.

The verification process takes as input a set of Records that you are willing to validate and an optional blockchain network where the validation will be made. If the blockchain network is not set, the SDKs will select Ethereum by default if available.

The output of the process will be a timestamp which is the earliest transaction in the selected blockchain network where all the records are included.

One-step verification

In order to verify one or more records in one step, our SDKs provide the function verifyRecords. This function will take care of managing the 3 steps by itself.

Here are code example of how to implement this function:

import { Bloock, IntegrityClient, Network, RecordClient } from '@bloock/sdk';

try {
// we set the API key and create a client
Bloock.setApiKey(process.env['API_KEY']);
const integrityClient = new IntegrityClient();
const recordClient = new RecordClient();

const record = await recordClient.fromString('Hello world').build();
const records = [record];

const receipts = await integrityClient.sendRecords(records);
const _anchor = await integrityClient.waitAnchor(receipts[0].anchor);

// we can optionally specify a network (if not set, default is Ethereum Mainnet)
const timestamp = await integrityClient.verifyRecords(
records,
Network.ETHEREUM_MAINNET
);
console.log(timestamp);
} catch (e) {
console.log(e);
}

Detailed verification

Retrieve an integrity proof

An integrity proof is a set of data computed by BLOOCK based on one (or more) Records that can later be verified independently to mathematically assure that those Records were included in an anchor in the past.

Once an Integrity proof is computed it's valid over time. You can store it internally and use it for later verification to ensure full independence from our service from this point.

tip

You will not be able to verify a Record that is not fully processed and transacted to Blockchain. See Synchronization for information about how to manage it.

Our SDKs allow to easily retrieve this integrity proof. Here are some code examples of how to implement it:

import { IntegrityClient, Record } from '@bloock/sdk';

const integrityClient = new IntegrityClient();

const records: Record[] = [
/* records */
];
const _proof = await integrityClient.getProof(records);

Verify the integrity proof

The next step in the verification process is to verify the integrity proof retrieved in the previous step. This is made by locally computing the result of the proof, which is the value (root) that, at some point of time, got transacted into blockchain.

tip

For more detail about this process, you can see the Protocol section.

All this process is managed by our SDKs and can be implemented as follows:

import { IntegrityClient, Proof } from '@bloock/sdk';

const integrityClient = new IntegrityClient();

let proof: Proof;
const _root = await integrityClient.verifyProof(proof);

Validate in blockchain

The last step of the verification process is to check if the output of the Verify integrity proof step is actually in the selected blockchain network.

This is made by querying the obtained root on the BLOOCK's Smart Contract deployed on each network available. The result of this query is a timestamp (specifically the block time) when this root was transacted into the network.

Here's some code examples of how to implement this using our SDKs:

import { IntegrityClient, Network } from '@bloock/sdk';

const integrityClient = new IntegrityClient();

const root = 'root';
const _timestamp = await integrityClient.validateRoot(
root,
Network.ETHEREUM_MAINNET
);