Step 2: Verifying Your Data in QLDB - Amazon Quantum Ledger Database (Amazon QLDB)

Step 2: Verifying Your Data in QLDB

Amazon QLDB provides an API to request a proof for a specified document ID and its associated block. You must also provide the tip address of a digest that you previously saved, as described in Step 1: Requesting a Digest in QLDB.

Then, you can use the proof returned by QLDB to verify the document revision against the saved digest, using a client-side API. This gives you control over the algorithm that you use to verify your data.

AWS Management Console

This section describes the steps to verify a document revision against a previously saved digest using the Amazon QLDB console.

Before you start, make sure that you follow the steps in Step 1: Requesting a Digest in QLDB. Verification requires a previously saved digest that covers the revision that you want to verify.

To verify a document revision (console)

  1. Open the Amazon QLDB console at https://console.aws.amazon.com/qldb.

  2. First, query your ledger for the id and blockAddress of the revision that you want to verify. These fields are included in the document's metadata, which you can query in the committed view.

    The document id is a system-assigned unique identifier. The blockAddress specifies the block location where the revision was committed.

    In the navigation pane, choose Query editor.

  3. Choose the ledger name in which you want to verify a revision.

  4. In the query editor window, enter a SELECT statement in the following syntax, and then choose Run.

    SELECT metadata.id, blockAddress FROM _ql_committed_table WHERE criteria

    For example, the following query returns a document from the vehicle-registration sample ledger created in Getting Started with the Amazon QLDB Console.

    SELECT r.metadata.id, r.blockAddress FROM _ql_committed_VehicleRegistration AS r WHERE r.data.VIN = 'KM8SRDHF6EU074761'
  5. Copy and save the id and blockAddress values that your query returns. Be sure to omit the double quotes for the id field. In Amazon Ion, string data types are delimited with double quotes. For example, you must copy only the alphanumeric text in the following snippet.

    "LtMNJYNjSwzBLgf7sLifrG"

  6. Now that you have a document revision selected, you can start the process of verifying it.

    In the navigation pane, choose Verification.

  7. On the Verify document form, under Specify the document that you want to verify, enter the following input parameters:

    • Ledger—The ledger in which you want to verify a revision.

    • Block address—The blockAddress value returned by your query in Step 4.

    • Document ID—The id value returned by your query in Step 4.

  8. Under Specify the digest to use for verification, select the digest that you previously saved by choosing Choose digest. If the file is valid, this auto-populates all the digest fields on your console. Or, you can manually copy and paste the following values directly from your digest file:

    • Digest—The digest value from your digest file.

    • Digest tip address—The digestTipAddress value from your digest file.

  9. Review your document and digest input parameters, and then choose Verify.

    The console automates two steps for you:

    1. Request a proof from QLDB for your specified document.

    2. Use the proof returned by QLDB to call a client-side API, which verifies your document revision against the provided digest. To examine this verification algorithm, see the following section QLDB API to download the example code.

    The console displays the results of your request in the Verification results card. For more information, see Verification Results.

QLDB API

You can also verify a document revision using the Amazon QLDB API with an AWS SDK. The QLDB API provides the following actions for use by application programs:

  • GetDigest – Returns the digest of a ledger at the latest committed block in the journal. The response includes a 256-bit hash value and a block address.

  • GetBlock – Returns a journal block object at a specified address in a ledger. Also returns a proof of the specified block for verification if DigestTipAddress is provided.

  • GetRevision – Returns a revision data object for a specified document ID and block address. Also returns a proof of the specified revision for verification if DigestTipAddress is provided.

For complete descriptions of these API operations, see the Amazon QLDB API Reference.

For Java code examples, see Installing the Amazon QLDB Java Sample Application, and follow the steps to download and install the sample application. The demo code in class GetRevision provides an example of requesting a proof for a document revision and then verifying that revision. This class runs the following steps:

  1. Requests a new digest from the sample ledger vehicle-registration.

  2. Requests a proof for a sample document revision from the VehicleRegistration table in the vehicle-registration ledger.

  3. Verifies the sample revision using the returned digest and proof.

Before trying a verification, make sure that you follow at least Steps 1–3 in the Java Tutorial to create a ledger named vehicle-registration and load it with sample data.