Amazon Quantum Ledger Database (Amazon QLDB)
Developer Guide

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 document revision 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 document 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 document 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 red italicized 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 document 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 To learn more, see Running the Java Sample Application in Amazon QLDB, and follow the steps to download and install the sample application. For an example of requesting a proof for a document revision and then verifying that revision, you can try running the demo code in class GetRevision. 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 Getting Started with the Driver tutorial for Java to create a ledger named vehicle-registration and load it with sample data.