nChain Event
Back to All
V.1.3.1
V.1.3.1
  • nChain Event User Guide
  • Overview
    • Introduction
      • Target Audience
    • Features and Benefits
      • Independent Operations
      • Web3 Development
    • Core Concepts
    • Encoded and Unencoded Records
  • Using nChain Event
    • Initial Set-Up
  • Independent Records
    • Introduction
    • Functional Description
      • Write Record
      • Read Record
      • Verify Record
    • Use Cases
      • Lucky Number Tickets
      • Internet of Things (IoT) Data
      • Intellectual Property Rights (IPR) Evidence
      • Car Dealership
    • Tutorials
      • Data Integrity
    • API Workflow
      • Write Record
      • Get Location Status
      • Read Record
      • Verify Record
  • Linked Records
    • Introduction
      • Concept - Link Locations
    • Functional Description
      • Create Link Record
      • Read Link Record
      • Update Link Record
      • Delete Link Record
      • Verify Link Record
    • Use Cases
      • Luxury Handbag Provenance
    • Tutorials
      • Collection Integrity
      • Provenance Integrity
    • API Workflow
      • Create Link Record
      • Get Link Location Status
      • Read Link Record
      • Update Link Record
      • Delete Link Record
      • Verify Link Record
  • API Documentation
    • nChain Event API
  • Bitcoin SV Blockchain
    • Features and Benefits
    • Writing to Blockchain
    • Reading from Blockchain
    • Transaction Format
    • Troubleshooting
    • Glossary
Powered by GitBook
On this page
  • Next Item Registration
  • Nth Item Verification
  • Benefits
  1. Linked Records
  2. Tutorials

Collection Integrity

PreviousTutorialsNextProvenance Integrity

A business wants to be assured about the data integrity (accuracy and authenticity) of a collection of items for a product or service that may be used anywhere, such as a motor vehicle. To achieve that, the business wants to easily verify the collection of items.

This is part of Data Integrity for a collection. It is an extension of the Data Integrity use case described . The solution includes these steps for each item:

  • Next item registration – items are kept hidden but registered and linked on the blockchain

  • Nth item verification – items and links are compared with the blockchain to determine validity

Please be aware that verification always requires the original item.

Class Event(aUrl, aApiKey) {

  upsert(record, salt, location) // register a fingerprint of record on the blockchain
    if location = 0
      location = create(record, salt) // create link location
    else
      location = update(record, salt, location) // update link location
    return location

  verify(record, time, previousLoc, location, nextLoc) // return match/mismatch/error

}

Next Item Registration

Whenever an item is added to the collection in the application database, this procedure is performed to register a fingerprint of the item on the blockchain, and record all collection data:

aRecord = "details of the next item of the collection to register"

aSalt = time.now()

previousLocation = either 0 or collection[count-1].location

nextLocation = event.upsert(aRecord, aSalt, previousLocation) // register fingerprint

// persist aSalt, nextLocation in collection[count]

// increment and persist count

Nth Item Verification

At any arbitrary time later, the business can verify the Nth item (from 0 to count-1) with this procedure:

  nthRecord = "get the Nth item of the collection to verify"

  nthSalt = collection[Nth].salt

  previousLoc = either 0 or collection[Nth - 1].location
  
  nthLocation = collection[Nth].location

  nextLoc = either 0 or collection[Nth + 1].location
  
  result = event.verify(nthRecord, nthSalt, previousLoc, nthLocation, nextLoc)

  if result = match // nthRecord and links are verified as valid
  if result = mismatch // nthRecord or links are verified as invalid
  if result = error // try again later

The business can employ iteration to verify the collection of items.

This example ignores issues like multiple collections and updating individual items.

Benefits

  • Provides high confidence of the validity of a verified collection for the business.

  • Provides high confidence to auditors/users who verify the original collection of its validity.

We will use this class wrapper around the Linked Record REST API (described ):

here
here