The Auditor is a cautious observer of the ledger that routinely checks the ledger's integrity.
For example, instead of requesting transaction-by-transaction (a transaction in PAD means either a data request or a Trustee/Validator response), an Auditor would request the ledger as raw blocks, which can be used to verify the integrity of the ledger. Trustee attestations allow the Auditor to confirm they have been provided with the same ledger used by the Trustees.
Computing digest of a ledger
The Auditor computes a succinct representation of the ledger, which can then be tested for consistency against the Trustee attestations. Since the ledger forms a blockchain, we define this succinct representation as the hash of the most recent block in the blockchain.
Occasionally, an Auditor may want to check on the transaction details. In the following sections, we will show how an Auditor can:
Compute hash of a block
Compute hash of a block's data section
Extract transactions from a block's data
Computing hash of a block
A block is composed of a header and a data section. The block header section contains the block number, previous block's hash, and the hash of the current block's data section.
When we say "hash" of a block, we mean the hash of its header section. Below is a Node.js example of how to compute the hash given a JSON representation of the header. The dependency cryptoUtil is defined here.
When a user has utilised the data section of a block (for example, he/she extracted a data request and used it for some business logic), it is crucial for him/her to check its consistency against the dataHash entry in the block header.
The data section is an array of base64-encoded strings. Its hash is defined as the hash on the concatenation of these binary data. Below is a sample script for computing the data hash of a block:
There are 4 smart contract functions that write on the ledger. Their parameters are as follows:
Init: writes metadata of the instance
stringified Trustee public keys
trustee threshold
stringified Validator public keys
validator threshold
PostDataRequest: posts a data request
a token
PostTrusteeResponse: posts a Trustee response
Trustee response payload
Trustee's digital signature on 1
PostValidatorResponse: posts a Validator response
Validator response payload
Validator's digital signature on 1
A piece of block data may contain one of these functions' invocations and their parameters.
Extracting the transactions
It is possible to extract the invoked smart contract functions and parameters from block data. The resulting value is an array of arrays of strings where the first strings in the inner arrays are the functions and the succeeding strings are the parameters. Since the blocks are protocol-buffer-encoded, we need to use a library protobufjs for decoding.