Skip to main content

Kachina

Kachina is a data-protecting smart contract solution that enables its users to achieve confidential and general-purpose smart contract functionality without sacrificing decentralization characteristics. Kachina offers a practical protocol for realizing data-protecting smart contracts, utilizing only non-interactive zero knowledge. By design, contracts are structured in a way that gives developers a clear separation between the personal data that stays on the user’s machine, and the data that is processed publicly on-chain.

At the core of the Kachina model is the concept of bridging the gap between the blockchain and users' local machines. This is achieved by representing the system through two distinct states:

  • a public state, which resides on the blockchain and is accessible to all participants
  • a private state, which exists locally on each user's machine.

Kachina’s contribution is to provide a model that connects the private and public states using zero-knowledge proofs. The contract itself can update both the public state and the private state simultaneously.

By definition, a ZKP allows one party (the prover) to make an assertion that a second party (the verifier) can be satisfied is true, without the need to disclose additional information. In the case of Kachina, the assertion is that there has been a change to the private state that justifies a corresponding change to the public state.

To make a valid assertion, parties engaging in the contract must prove in zero-knowledge that their updates to the public state are valid by providing evidence of the existence of a corresponding private state and the associated inputs that justify the update. Kachina facilitates this proof using ZK Snarks. It offers a low-level and versatile framework for building data-protecting systems that is based on the Universally Composable (UC) security framework.

kachina

Figure 1. How Kachina smart contracts work

As outlined in Figure 1, clients can maintain private states for the contracts in which they participate. For each user, the public state operates as a deterministic state machine, which is coupled with the private state. Private data is never shared on the chain. Authorization to perform contract actions is based on ZKPs that verify the transaction's compliance with the rules. Validation begins by checking the proof against the ZK circuit. On-chain validation then executes the public portion of the contract to generate a new public state.

Kachina enables concurrency to enhance the efficiency of smart contracts. Concurrency refers to the ability of multiple actors to perform tasks simultaneously without blocking each other. This ensures increased throughput and efficient transaction and smart contract processing. To enable concurrency, Kachina utilizes transcripts that record the operations performed on the contract's state and interact with queries. By optimizing conflicting transactions and allowing for reorderings, Kachina minimizes information leakage while maximizing concurrency.

The model

Kachina presents smart contracts as reactive state machines. Users interact with these contracts by submitting transactions to Midnight. When a user initiates a transaction, they intend to issue a high-level command to the smart contract, such as casting a vote or withdrawing funds. After the transaction is confirmed by the ledger, the user receives information about the outcome of their command and any computed results based on the contract's current state.

The core protocol idea

To ensure the secure handling of data in smart contracts, Kachina introduces a unique approach, which enables smart contracts to interact with specialized entities, facilitating data access and updates. These entities allow contracts to make inquiries and obtain relevant information. Rather than directly modifying the contract's data, this interaction ensures the integrity and consistency of the contract's state. Users maintain a transcript of these interactions, capturing the queries and expected responses. By providing evidence of their familiarity with inputs that yield the expected responses, users can validate the transcript and verify the reliability of the contract's data management.

In conclusion, Kachina provides a powerful tool for constructing data-protecting smart contract systems. It allows users to interact with contracts securely, protecting their personal data while ensuring the desired functionality of the contracts. Kachina allows for the realization of various contract types, enabling developers to achieve their desired data protection goals while taking advantage of the protocol's strong security foundations.

This model can be applied to a wide range of use cases including TradFi and DeFi applications, supply chain management systems, healthcare applications, and more. See use cases for more information.

For more details, examples, and contract samples, read Kachina – Foundations of Private Smart Contracts.