# Private Data

# Introduction

Miyabi can be used to store any type of arbitrary data. One use case which has become very common is having the data stored in a traditional database and just storing the proof or the hash of the data entries on the blockchain. This is mainly done because of the secure and immutable nature of the blockchain as a database. It is particularly useful for auditing and proving correctness of the original data. Sometimes, this is referred to as "anchoring the data onto a blockchain".

Miyabi provides a module where original data can be stored privately amongst a set of nodes whereas only the proof of the data will be stored in the Miyabi World State amongst all the nodes.

# Data states in Miyabi

# World State

The World State represents the global common state of Miyabi. A normal Miyabi transaction makes changes to the World State. The data in the World State is shared and eventually consistent among all nodes.

# Private State

The Private State represents the state of the data which is local and private to a specific node(s). However, this storage is handled separately from the World State storage. A number of nodes can share the same Private State. To update the Private State, a Private Transaction is required.

# Concept

The Private State feature addresses the scenario in which a subset of nodes (later defined as Private Data Owners) want to share data amongst themselves and also want the verifiable proof of existence of private data to be available on the World State across all nodes.

Private Data Channel
Figure 1: Private Channel and Private Data Owners

The above diagram represents how the Private State works.

  • Node 1, Node 4 and Node 5 are said to have formed a Private Channel.
  • Each member node of the Private Channel is known as a Private Data Owner(PDO) which maintains a local copy of the Private State.
  • The changes to the Private State occurs in a decentralized manner. Meaning, there is no single central authority for deciding the correctness of the private data.
  • All the Private Channel members (PDOs) need to approve any change that goes through to the Private State.
  • For storing the proof on the World State, A normal Miyabi transaction goes through the general consensus protocol of the blockchain.

# Private channel in SdkConfig

  • The subset of nodes (Private Data Owner(PDO)) is defined in an optional Private Channel section of the SdkConfig.
  • The Miyabi cli tool has dedicated commands for the private data feature which will be explained later on in this document.
  • The cli commands get the private channel information from the SdkConfig to reach PDOs for various requests.
SdkConfig
Figure 2: Private Channel in SdkConfig

# PDO Identity

The PDO represents a cryptographic identity or in simple words an address. In theory, the node can use any delegated identity to sign Private Transactions. Currently, the PDO identity is tied to that of the Consensus Credential mentioned in the node config.

# Private Transaction

A Private Transaction is designed to update the Private State on the PDO members as well as updating the proof in the World State. This transaction is only sent to the PDOs.

Private transaction internally has two subcomponents:

  • Payload: The Payload contains the raw data to be stored in the Private State

  • Miyabi transaction: A Miyabi transaction to update the World State with the proof hash of the Payload.

When a private transaction is successful, the following things are ensured:

  1. All PDOs in the private channel will update their Private State according to the Payload
  2. The Miyabi blockchain's World State will be updated with the proof hash
Private transaction
Figure 3: Components of Private transaction

Private transaction is first sent to PDOs, then the normal tx is derived from the evidences sent back by the PDOs. Finally, this Miyabi tx is then sent to all nodes for updating the World State. The flow is illustrated in the below diagram.

Private transaction flow 2
Figure 4: Private transaction flow: Commit

# Private Data Module

The private data module implements the Private State feature in Miyabi.

The user interacts with the PDOs to update their Private State. For a valid payload to update the Private State, a separate request (transaction) is also created to store the proof(hash) of private data in the World State. The update to the Private State and the World State must happen in synchronized manner. An internal Private State observer acts like a synchronization context to maintain the synchronization of the final commits to Private State and World State.

The following items are implemented in this module:

  • Creating and sending the private transaction to the PDOs of the private channel.
  • Accepting a private transaction through private web API.
  • Processing of the payload and signing the transaction by PDOs.
  • Sending PDOs signed Miyabi tx to blockchain.
  • Execution logic for the World State changes.
  • Internal Observer implementation to maintain consistency between the Private State and the World State.
  • Web API and CLI tools to do various operations.

# API and CLI Commands

The Miyabi Private Data module extension provides a set of CLI commands and APIs. Details regarding the same have been provided in the following sections.